ReadonlyheightThe height of the canvas, in pixels
ReadonlywidthThe width of the canvas, in pixels
Completely clears the canvas.
The zero-indexed layer to clear, if unset, will clear all layers
Clear all saved data. This action is permanent!
An optional "namespace" to clear data from.
Draw an object onto the canvas.
Any drawable object
The zero-indexed layer to draw to
Get the current cursor position.
Cursor position as [x, y]
Determine whether a key is currently pressed.
The key to check
True if key is down
Determine whether a mouse button is currently pressed.
The button ID
True if button is down
Determines whether audio is muted
True if currently muted
Determines whether the media recorder is active
True if currently recording
Load arbitrary data from the browser storage. Warning: The loaded data object is not strictly type-checked or sanitized, so it may have missing fields or contain extra fields. It's good practice to manually validate the data once it's loaded from storage.
An optional "namespace" to load data from, assigned when saving data
The data object loaded from browser storage
Mute all audio
Play an audio file
The path of the audio file
Whether to play the audio on loop
The normalized [0-1] volume
The track number to play on
Save arbitrary data to the browser storage. Warning: This will overwrite any existing data under these object keys.
The arbirary data object to save
An optional "namespace" to store the data, which can be assigned when a user has multiple profiles, for example
Take a screenshot of the canvas contents and save to a .png file.
The file name of the screenshot
Start recording all layers on the canvas
Stop all audio tracks from playing
Stop recording and download screen capture
Unmute all audio
Represents a canvas for drawing and animating