Crafty.DrawManager
An internal object manage objects to be drawn and implement the best method of drawing in both DOM and canvas
public Crafty.DrawManager.onScreen(Object rect)
Test if a rectangle is completely in viewport
public Object Crafty.DrawManager.mergeSet(Object set)
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.
public Crafty.DrawManager.addCanvas(ent)
Add an entity to the list of Canvas objects to draw
public Crafty.DrawManager.addDom(ent)
Add an entity to the list of DOM object to draw
public Crafty.DrawManager.drawAll([Object rect])
- If rect is omitted, redraw within the viewport
- If rect is provided, redraw within the rect
public Crafty.DrawManager.boundingRect(set)
- Calculate the common bounding rect of multiple canvas entities.
- Returns coords
public Crafty.DrawManager.draw()
- 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.