new CanvasPool()
The CanvasPool is a global static object, that allows Phaser to recycle and pool Canvas DOM elements.
- Source:
- src/utils/CanvasPool.js line 13
Members
-
<static> pool : Array
-
The pool into which the canvas elements are placed.
Type:
- Array
- Source:
- src/utils/CanvasPool.js line 207
Methods
-
<static> clear()
-
Empties the pool.
- Source:
- src/utils/CanvasPool.js line 187
-
<static> create(parent, width, height)
-
Creates a new Canvas DOM element, or pulls one from the pool if free.
Parameters:
Name Type Description parent
any The parent of the canvas element.
width
number The width of the canvas element.
height
number The height of the canvas element.
- Source:
- src/utils/CanvasPool.js line 15
Returns:
The canvas element.
- Type
- HTMLCanvasElement
-
<static> getFirst()
-
Gets the first free canvas index from the pool.
- Source:
- src/utils/CanvasPool.js line 57
Returns:
- Type
- number
-
<static> getFree()
-
Gets the total number of free canvas elements in the pool.
- Source:
- src/utils/CanvasPool.js line 148
Returns:
The number of free (un-parented) canvas elements in the pool.
- Type
- number
-
<static> getTotal()
-
Gets the total number of used canvas elements in the pool.
- Source:
- src/utils/CanvasPool.js line 125
Returns:
The number of in-use (parented) canvas elements in the pool.
- Type
- number
-
<static> log()
-
Prints in-use, free, and total counts to console.log.
- Source:
- src/utils/CanvasPool.js line 171
-
<static> remove(parent)
-
Looks up a canvas based on its parent, and if found puts it back in the pool, freeing it up for re-use. The canvas has its width and height set to 1, and its parent attribute nulled.
Parameters:
Name Type Description parent
any The parent of the canvas element.
- Source:
- src/utils/CanvasPool.js line 79
-
<static> removeByCanvas(canvas)
-
Looks up a canvas based on its type, and if found puts it back in the pool, freeing it up for re-use. The canvas has its width and height set to 1, and its parent attribute nulled.
Parameters:
Name Type Description canvas
HTMLCanvasElement The canvas element to remove.
- Source:
- src/utils/CanvasPool.js line 102