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 CanvasLayer.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
Back to top

._drawDirty()

public ._drawDirty()
  • Triggered by the "RenderScene" event
  • If the number of rects is over 60% of the total number of objects do the naive method redrawing CanvasLayer.drawAll instead
  • Otherwise, clear the dirty regions, and redraw entities overlapping the dirty regions.

See Also