OffscreenCanvas: OffscreenCanvas() constructor
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