CanvasLayer System
An object for creating the canvas layer system.
Mostly contains private methods to draw entities on a canvas element.
Properties
Methods
.attach()
public .attach(ent)
- ent
The entity to add
Sets the entity's draw context to this layer
.detach()
public .detach(ent)
- ent
The entity to detach
Removes an entity to the list of Canvas objects to draw
.dirty()
public .dirty(ent)
- ent
The entity to add
Add an entity to the list of Canvas objects that need redrawing
.context
This will return the 2D context associated with the canvas layer's canvas element.
._drawAll()
public ._drawAll([Object rect])
- rect
a rectangular region {_x: x_val, _y: y_val, _w: w_val, _h: h_val}
- If rect is omitted, redraw within the viewport
If rect is provided, redraw within the rect.
Triggered by the "RenderScene" event
- This method is invoked if the number of rects is over 60% of the total number of objects.
- Clear the whole viewport, and redraw entities overlapping it by default.
See Also
._drawDirtyCells()
public ._drawDirtyCells([Object rect])
- rect
a rectangular region {_x: x_val, _y: y_val, _w: w_val, _h: h_val}
- If rect is omitted, redraw within the viewport
If rect is provided, redraw within the rect.
Triggered by the "RenderScene" event
- This method is invoked if the number of rects is under 60% of the total number of objects and the total number of objects is greater than 16.
- Clear the dirty spatial grid cells, and redraw entities overlapping the dirty spatial grid cells.