Crafty.DrawManager
Crafty.DrawManager
An internal object manage objects to be drawn and implement the best method of drawing in both DOM and canvas
Methods and Properties
Crafty.DrawManager.addCanvas
public Crafty.DrawManager.addCanvas(ent)
- ent
The entity to add
Add an entity to the list of Canvas objects to draw
Crafty.DrawManager.addDom
public Crafty.DrawManager.addDom(ent)
- ent
The entity to add
Add an entity to the list of DOM object to draw
Crafty.DrawManager.boundingRect
public Crafty.DrawManager.boundingRect(set)
- set
Undocumented
- Calculate the common bounding rect of multiple canvas entities.
- Returns coords
Crafty.DrawManager.drawAll
public Crafty.DrawManager.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
Crafty.DrawManager.mergeSet
public Object Crafty.DrawManager.mergeSet(Object set)
- set
an array of rectangular regions
Merge any consecutive, overlapping rects into each other. Its an optimization for the redraw regions.
The order of set isn't strictly meaningful, but overlapping objects will often cause each other to change, and so might be consecutive.
Crafty.DrawManager.onScreen
public Crafty.DrawManager.onScreen(Object rect)
- rect
A rectangle with field {_x: x_val, _y: y_val, _w: w_val, _h: h_val}
Test if a rectangle is completely in viewport
Crafty.DrawManager.renderCanvas
public Crafty.DrawManager.renderCanvas()
- Triggered by the "RenderScene" event
- If the number of rects is over 60% of the total number of objects
do the naive method redrawing
Crafty.DrawManager.drawAll
- Otherwise, clear the dirty regions, and redraw entities overlapping the dirty regions.
See Also
Crafty.DrawManager.renderDOM
public Crafty.DrawManager.renderDOM()
When "RenderScene" is triggered, draws all DOM entities that have been flagged