CanvasLayer System

An object for creating the canvas layer system.

Mostly contains private methods to draw entities on a canvas element.

Properties

Methods

Back to top

.attach()

public .attach(ent)
ent

The entity to add

Sets the entity's draw context to this layer

Back to top

.detach()

public .detach(ent)
ent

The entity to detach

Removes an entity to the list of Canvas objects to draw

Back to top

.dirty()

public .dirty(ent)
ent

The entity to add

Add an entity to the list of Canvas objects that need redrawing

Back to top

._canvas

The canvas element associated with the canvas layer.

Back to top

.context

This will return the 2D context associated with the canvas layer's canvas element.

Back to top

._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

Back to top

._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.

See Also