CanvasState.js
CanvasState
Kind: global class
- CanvasState
- new CanvasState()
- .setParent(parent) ⇒
void
- .setCanvas(canvas) ⇒
void
- .setSize(width, height) ⇒
void
- .setBackgroundColor(color) ⇒
void
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
Param | Type | Description |
---|---|---|
parent | string | 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
Param | Type | Description |
---|---|---|
canvas | string | HTMLElement | The canvas element |
CanvasState.setSize(width, height) ⇒ void
Change the canvas width and height.
Kind: static method of CanvasState
Param | Type | Default | Description |
---|---|---|---|
width | number | 800 | The width of the canvas. Default 800 |
height | number | 600 | The height of the canvas. Default 600 |
CanvasState.setBackgroundColor(color) ⇒ void
Change the background color of the canvas.
Kind: static method of CanvasState
Param | Type | Default | Description |
---|---|---|---|
color | number | string | 0 | The background color of the canvas. Default black |