Classes
Methods
drawFocus(ctx)
Draws this objects selection box. To be used when
an object is selected.
Parameters:
| Name | Type | Description |
|---|---|---|
ctx |
* | The canvas context to draw with |
- Source:
drawSelf(ctx)
Draws self on the canvas screen.
Parameters:
| Name | Type | Description |
|---|---|---|
ctx |
* | The canvas context to draw with |
- Source:
export()
Exports this Drawable as a dictionary of values
- Source:
import(data)
Imports values from a dictionary into this drawable
Parameters:
| Name | Type | Description |
|---|---|---|
data |
* | What to import |
- Source:
init(e) → {boolean}
Initializes initial values that depend on positionality.
Distinct from constructor in that it relies on a mousedown
event to tell it where this object is located.
Parameters:
| Name | Type | Description |
|---|---|---|
e |
MouseEvent | The mousedown event |
- Source:
Returns:
Whether to continue dragging this object
after the initial click
- Type
- boolean
moveX(dx)
Moves an object by dx pixels horizontally on the screen
Parameters:
| Name | Type | Description |
|---|---|---|
dx |
Number | The amount to move |
- Source:
moveY(dy)
Moves an objects by dy pixels vertically on the screen
Parameters:
| Name | Type | Description |
|---|---|---|
dy |
Number | The amount to move |
- Source:
onDrag(e)
Handles what happens to the object when the users drags
Parameters:
| Name | Type | Description |
|---|---|---|
e |
MouseEvent | The drag event |
- Source:
onMouseDown(e) → {boolean}
Handles what happens when an object is clicked at first.
Parameters:
| Name | Type | Description |
|---|---|---|
e |
MouseEvent | The mousedown event |
- Source:
Returns:
Whether to continue dragging this object
after the initial click
- Type
- boolean
onMouseUp(e) → {boolean}
Handles what happens when the user lets go of their mouse.
Parameters:
| Name | Type | Description |
|---|---|---|
e |
MouseEvent | The mouseup event |
- Source:
Returns:
Whether to have this object be selected
after letting go
- Type
- boolean
overSelection(x, y) → {boolean}
Same as overSelf, except for if its over the selected bounding
box in particular. Used for objects that have a slightly larger
selection box and to prioritize the selected object, even if it's
below other objects on screen.
Parameters:
| Name | Type | Description |
|---|---|---|
x |
Number | The x position to compare against |
y |
Number | The y position to compare against |
- Source:
Returns:
Whether the click is over this bounding box
- Type
- boolean
overSelf(x, y) → {boolean}
Returns whether a click is over this object
Parameters:
| Name | Type | Description |
|---|---|---|
x |
Number | The x position to compare against |
y |
Number | The y position to compare against |
- Source:
Returns:
Whether the click is over this object
- Type
- boolean