Constructs a new Canvas2D
.
The canvas to wrap.
The configuration for this canvas.
Our back buffer.
Readonly
canvasThe canvas element we're interacting with.
Readonly
optionsThe configuration that was used for this canvas.
Retrieves the rendering context of the canvas.
The rendering context of the canvas.
Retrieves the height of the canvas.
The height of the canvas.
Retrieves the width of the canvas.
The width of the canvas.
Fills the entire back buffer with the given color.
The color to fill the back buffer with.
Reads the front buffer back into the back buffer.
Fills the entire back buffer with the given color.
The color to fill the back buffer with.
Draws a slightly transparent, black rectangle over the canvas, and then reads the result back into the buffer.
The color to fade the buffer with. The alpha component of
the color defines how strong the fade is. 0
is not at all, 255
makes
it instantly black.
Returns the color of a pixel in the back buffer.
The X coordinate to retrieve.
The X coordinate to retrieve.
The color of the pixel at the given local.
Recreate internal buffers in reaction to a change in our target HTMLCanvasElement
.
Draws the offscreen canvas into the DOM canvas.
Draw FPS information onto the canvas.
Durations of previous frame draws.
The duration of the previous frame draw.
The time elapsed since the last frame.
Colors a pixel in the back buffer.
The X coordinate to color.
The Y coordinate to color.
The color to place at the coordinate.
Draws the back buffer onto the canvas.
The
Canvas2D
is a double-buffered construct to help with drawing to aHTMLCanvasElement
with best possible performance. We utilize anOffscreenCanvas
with aOffscreenCanvasRenderingContext2D
to draw frames and expect to render them back to the DOM in regular intervals.