CanvasRenderer

rekapi. CanvasRenderer

new CanvasRenderer(rekapi, contextopt)

You can use Rekapi to render animations to an HTML5 <canvas>. To do so, just provide a CanvasRenderingContext2D instance to the rekapi.Rekapi constructor to automatically set up the renderer:

const rekapi = new Rekapi(document.createElement('canvas').getContext('2d'));

To use this renderer's API, get a reference to the initialized object:

const canvasRenderer = rekapi.getRendererInstance(CanvasRenderer);

Note: rekapi.CanvasRenderer is added to rekapi.Rekapi#renderers automatically, there is no reason to call the constructor yourself in most cases.

Source:
Parameters:
Name Type Attributes Description
rekapi rekapi.Rekapi

The rekapi.Rekapi instance to render for.

context CanvasRenderingContext2D <optional>

See the canvas docs.

Extends

Methods

clear() → {rekapi.CanvasRenderer}

Erase the <canvas>.

Source:
Returns:
Type:
rekapi.CanvasRenderer

height(heightopt) → {number}

Get and optionally set the height of the associated <canvas> element.

Source:
Parameters:
Name Type Attributes Description
height number <optional>

The height to optionally set.

Returns:
Type:
number

width(widthopt) → {number}

Get and optionally set the width of the associated <canvas> element.

Source:
Parameters:
Name Type Attributes Description
width number <optional>

The width to optionally set.

Returns:
Type:
number