OffscreenCanvas
interface
interface OffscreenCanvas extends EventTargetA 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.
See also
variable
var OffscreenCanvas: { … }The constructor object for OffscreenCanvas, used to create a new
offscreen canvas with the given width and height that can be rendered to
without being attached to the DOM.
See also
Constructors
constructor
new OffscreenCanvas(width: number, height: number): OffscreenCanvasProperties
height
height: numberThe height of the canvas.
width
width: numberThe width of the canvas.
prototype
prototype: OffscreenCanvasMethods
convertToBlob
convertToBlob(options?: ImageEncodeOptions): Promise<Blob>Create a Blob object representing the image contained in the canvas.
getContext
getContext(contextId: "bitmaprenderer", options?: any): ImageBitmapRenderingContext | nullGet a drawing context for the canvas. If this was previously called, it will return the same context.
getContext(contextId: "webgpu", options?: any): GPUCanvasContext | nullgetContext(contextId: OffscreenRenderingContextId, options?: any): OffscreenRenderingContext | nullgetContext(contextId: "2d" | "webgl" | "webgl2", options?: any): nulltransferToImageBitmap
transferToImageBitmap(): ImageBitmapCreate an ImageBitmap object representing the image contained in the canvas.