GraphicsManager

GraphicsManager

Class for interacting with Graphics.

Constructor

new GraphicsManager(options)

Source:
Set up an instance of the graphics library.
Parameters:
Name Type Description
options Object Options, primarily .canvas, the selector string for the canvas. If multiple are returned, we'll take the first one. If none is passed, we'll look for any canvas tag on the page.

Methods

addEventListeners()

Source:
Add all handlers to the window for triggering functions on the instance.

cleanup()

Source:
Remove all handlers from the window and clean up any memory.

getCanvas() → {HTMLCanvasElement}

Source:
Return the current canvas we are using. If there is no canvas on the page this will return null.
Returns:
The current canvas.
Type
HTMLCanvasElement

getContext() → {CanvasRenderingContext2D}

Source:
Return the 2D graphics context for this graphics object, or null if none exists.
Returns:
The 2D graphics context.
Type
CanvasRenderingContext2D

getPixel(x, y) → {Array.<number>}

Source:
Return the RGBA value of the pixel at the x, y coordinate.
Parameters:
Name Type Description
x number X coordinate
y number Y coordinate
Returns:
pixel - the [r, g, b, a] values for the pixel.
Type
Array.<number>

setCurrentCanvas(canvasSelector)

Source:
Set the current canvas we are working with. If no canvas tag matches the selectorv then we will just have the current canvas set to null.
Parameters:
Name Type Description
canvasSelector string String representing canvas class or ID. Selected with jQuery.

waitingForClick() → {boolean}

Source:
Whether the graphics instance is waiting for a click.
Returns:
Whether or not the instance is waiting for a click.
Type
boolean