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.
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.
Recreate internal buffers in reaction to a change in our target HTMLCanvasElement
.
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.
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.