OffscreenCanvas: OffscreenCanvas() constructor
Baseline 2023
Newly available
Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Note: This feature is available in Web Workers.
The OffscreenCanvas()
constructor returns a newly instantiated OffscreenCanvas
object.
Syntax
js
new OffscreenCanvas(width, height)
Parameters
Examples
This example creates a new offscreen canvas using the OffscreenCanvas()
constructor.
We then initialize a WebGL context on it using the getContext()
method.
js
const offscreen = new OffscreenCanvas(256, 256);
const gl = offscreen.getContext("webgl");
Specifications
Specification |
---|
HTML Standard # dom-offscreencanvas-dev |
Browser compatibility
BCD tables only load in the browser
See also
OffscreenCanvas
, the interface this constructor belongs to