Crafty.DrawManager

Crafty.DrawManager

An internal object manage objects to be drawn and implement the best method of drawing in both DOM and canvas

Back to top

Crafty.DrawManager.total2D

Total number of the entities that have the 2D component.

Back to top

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

Back to top

Crafty.DrawManager.merge

public Object Crafty.DrawManager.merge(Object set)

set
an array of rectangular regions

Merged into non overlapping rectangular region Its an optimization for the redraw regions.

Back to top

Crafty.DrawManager.add

public Crafty.DrawManager.add(old, current)

old
Undocumented
current
Undocumented

Calculate the bounding rect of dirty data and add to the register of dirty rectangles

Back to top

Crafty.DrawManager.debug

public Crafty.DrawManager.debug()

Back to top

Crafty.DrawManager.draw

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.

See Also

Back to top

Crafty.DrawManager.boundingRect

public Crafty.DrawManager.boundingRect(set)

set
Undocumented
- Calculate the common bounding rect of multiple canvas entities.
- Returns coords
Back to top

Crafty.DrawManager.draw

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.

See Also