Skip to main content

interface OffscreenCanvas

extends EventTarget

A canvas that can be rendered to off the main thread and without being attached to the DOM. It exposes drawing contexts via OffscreenCanvas.getContext and can produce a Blob or ImageBitmap from its contents.

Properties #

#height: number

The height of the canvas.

#width: number

The width of the canvas.

Methods #

#convertToBlob(options?: ImageEncodeOptions): Promise<Blob>

Create a Blob object representing the image contained in the canvas.

#getContext(
contextId: "bitmaprenderer",
options?: any,
): ImageBitmapRenderingContext | null

Get a drawing context for the canvas. If this was previously called, it will return the same context.

#getContext(
contextId: "webgpu",
options?: any,
): GPUCanvasContext | null
#getContext(
contextId:
"2d"
| "webgl"
| "webgl2"
,
options?: any,
): null

Create an ImageBitmap object representing the image contained in the canvas.

See #

Did you find what you needed?

Privacy policy