Skip to main content

CanvasState.js

CanvasState

Kind: global class

new CanvasState()

A class to manage canvas state.

CanvasState.setParent(parent) ⇒ void

Change the parent element of the canvas. If not specified, the canvas will be appended to the body.

Kind: static method of CanvasState

ParamTypeDescription
parentstring | HTMLElement

The parent element of the canvas

CanvasState.setCanvas(canvas) ⇒ void

Initialize the canvas state. If the canvas is not specified, a new canvas will be created.

Kind: static method of CanvasState

ParamTypeDescription
canvasstring | HTMLElement

The canvas element

CanvasState.setSize(width, height) ⇒ void

Change the canvas width and height.

Kind: static method of CanvasState

ParamTypeDefaultDescription
widthnumber800

The width of the canvas. Default 800

heightnumber600

The height of the canvas. Default 600

CanvasState.setBackgroundColor(color) ⇒ void

Change the background color of the canvas.

Kind: static method of CanvasState

ParamTypeDefaultDescription
colornumber | string0

The background color of the canvas. Default black