Class: Mask

Mask()

new Mask()

A mask can be used to set the drawing region. Masks are treated as objects their shape is used to filter other objects shape. Multiple mask objects can be active simulatenously, they have to be attached to the object mask list to filter the render region. A mask objects is draw using the context.clip() method.
Source:

Extends

Members

beingDragged

Flag to indicate if the object is currently being dragged.
Inherited From:
Source:

children

List of children objects attached to the object.
Inherited From:
Source:

draggable

Indicates if its possible to drag the object around. If true the onPointerDrag callback is used to update the state of the object.
Inherited From:
Source:

globalMatrix

Global transformation matrix multiplied by the parent matrix. Used to transform the object before projecting into screen coordinates.
Inherited From:
Source:

ignoreViewport

Flag to indicate wheter this objet ignores the viewport transformation.
Inherited From:
Source:

inverseGlobalMatrix

Inverse of the global matrix. Used to convert pointer input points into object coordinates.
Inherited From:
Source:

layer

Layer of this object, objects are sorted by layer value. Lower layer value is draw first.
Inherited From:
Source:

level

Depth level in the object tree, objects with higher depth are drawn on top. The layer value is considered first.
Inherited From:
Source:

masks

Masks being applied to this object. Multiple masks can be used simultaneously.
Inherited From:
Source:

matrix

Local transformation matrix applied to the object.
Inherited From:
Source:

matrixNeedsUpdate

If true the matrix is updated before rendering the object.
Inherited From:
Source:

onAdd

Method called when the object its added to a parent.
Inherited From:
Source:

onButtonDown

Callback method called when the pointer button is pressed down (single time). Receives (pointer, viewport) as arguments.
Inherited From:
Source:

onButtonPressed

Callback method called while the pointer button is pressed. Receives (pointer, viewport) as arguments.
Inherited From:
Source:

onButtonUp

Callback method called when the pointer button is released (single time). Receives (pointer, viewport) as arguments.
Inherited From:
Source:

onDoubleClick

Callback method called while the pointer button is double clicked. Receives (pointer, viewport) as arguments.
Inherited From:
Source:

onPointerEnter

Callback method called when the pointer enters the object. Receives (pointer, viewport) as arguments.
Inherited From:
Source:

onPointerLeave

Callback method called when the was inside of the object and leaves the object. Receives (pointer, viewport) as arguments.
Inherited From:
Source:

onPointerOver

Callback method while the pointer is over (inside) of the object. Receives (pointer, viewport) as arguments.
Inherited From:
Source:

onRemove

Method called when the object gets removed from its parent
Inherited From:
Source:

onUpdate

Callback method called every time before the object is draw into the canvas. Can be used to run preparation code, move the object, etc.
Inherited From:
Source:

origin

Origin of the object used as point of rotation.
Inherited From:
Source:

parent

Parent object, the object position is affected by its parent position.
Inherited From:
Source:

pointerEvents

Indicates if this object uses pointer events. Can be set false to skip the pointer interaction events.
Inherited From:
Source:

pointerInside

Flag indicating if the pointer is inside of the element. Used to control object event.
Inherited From:
Source:

position

Position of the object.
Inherited From:
Source:

restoreContextState

Flag to indicate if the context of canvas should be restored after render.
Inherited From:
Source:

rotation

Rotation of the object relative to its center.
Inherited From:
Source:

saveContextState

Flag to indicate if the context of canvas should be saved before render.
Inherited From:
Source:

scale

Scale of the object.
Inherited From:
Source:

uuid

UUID of the object.
Inherited From:
Source:

visible

Indicates if the object is visible.
Inherited From:
Source:

Methods

add(object)

Attach a children to this object. The object is set as children of this object and the transformations applied to this object are traversed to its children.
Parameters:
Name Type Description
object Object2D Object to attach to this object.
Inherited From:
Source:

clip(context, viewport, canvas)

Clip the canvas context, to ensure that next objects being drawn are cliped to the path stored here.
Parameters:
Name Type Description
context CanvasContext Canvas 2d drawing context.
viewport Viewport Viewport applied to the canvas.
canvas DOM DOM canvas element where the content is being drawn.
Source:

draw(context, viewport, canvas)

Draw the object into the canvas. Has to be implemented by underlying classes.
Parameters:
Name Type Description
context CanvasContext Canvas 2d drawing context.
viewport Viewport Viewport applied to the canvas.
canvas DOM DOM canvas element where the content is being drawn.
Inherited From:
Source:

getChildByUUID(uuid) → {Object2D}

Get a object from its children list by its UUID.
Parameters:
Name Type Description
uuid String UUID of the object to get.
Inherited From:
Source:
Returns:
The object that has the UUID specified, null if the object was not found.
Type
Object2D

isInside() → {boolean}

Check if a point is inside of the object. Used to update the point events attached to the object.
Inherited From:
Source:
Returns:
True if the point is inside of the object.
Type
boolean

onPointerDrag(pointer, viewport, delta)

Callback method while the object is being dragged across the screen. By default is adds the delta value to the object position (making it follow the mouse movement). Delta is the movement of the pointer already translated into local object coordinates. Receives (pointer, viewport, delta) as arguments.
Parameters:
Name Type Description
pointer Pointer Pointer object that receives the user input.
viewport Viewport Viewport where the object is drawn.
delta Vector2 Pointer movement in world space.
Inherited From:
Source:

remove(object)

Remove object from the children list.
Parameters:
Name Type Description
object Object2D Object to be removed.
Inherited From:
Source:

transform(context, viewport)

Apply the transform to the rendering context. It is assumed that the viewport transform is pre-applied to the context. Can also be used for pre rendering logic.
Parameters:
Name Type Description
context CanvasContext Canvas 2d drawing context.
viewport Viewport Viewport applied to the canvas.
Inherited From:
Source:

traverse(callback)

Traverse the object tree and run a function for all objects.
Parameters:
Name Type Description
callback function Callback function that receives the object as parameter.
Inherited From:
Source:

updateMatrix(context)

Update the transformation matrix of the object.
Parameters:
Name Type Description
context CanvasContext
Inherited From:
Source: