Navigation
These archived docs are for Phaser 2.4.8 Phaser 3 docs can be found on newdocs.phaser.io.
Phaser CE docs can be found on the Phaser CE Documentation site.

Constructor

PIXI. CanvasPool

new CanvasPool()

The CanvasPool is a global static object that allows Pixi and Phaser to pool canvas DOM elements.

Source code: pixi/utils/CanvasPool.js (Line 7)

Public Properties

<static> pool : Array

The pool into which the canvas dom elements are placed.

Source code: pixi/utils/CanvasPool.js (Line 173)

Public Methods

<static> create(parent, width, height) → {HTMLCanvasElement}

Creates a new Canvas DOM element, or pulls one from the pool if free.

Parameters
Name Type Description
parent

The parent of the canvas element.

width Number

The width of the canvas element.

height Number

The height of the canvas element.

Returns
HTMLCanvasElement -

The canvas element.

Source code: pixi/utils/CanvasPool.js (Line 15)

<static> getFirst() → {Number}

Gets the first free canvas index from the pool.

Returns
Number -
Source code: pixi/utils/CanvasPool.js (Line 58)

<static> getFree() → {Number}

Gets the total number of free canvas elements in the pool.

Returns
Number -

The number of free (un-parented) canvas elements in the pool.

Source code: pixi/utils/CanvasPool.js (Line 147)

<static> getTotal() → {Number}

Gets the total number of used canvas elements in the pool.

Returns
Number -

The number of in-use (parented) canvas elements in the pool.

Source code: pixi/utils/CanvasPool.js (Line 123)

<static> remove(parent)

Removes the parent from a canvas element from the pool, freeing it up for re-use.

Parameters
Name Type Description
parent

The parent of the canvas element.

Source code: pixi/utils/CanvasPool.js (Line 81)

<static> removeByCanvas(canvas)

Removes the parent from a canvas element from the pool, freeing it up for re-use.

Parameters
Name Type Description
canvas HTMLCanvasElement

The canvas element to remove

Source code: pixi/utils/CanvasPool.js (Line 102)