Note: This feature is available in Web Workers.
The OffscreenCanvas() constructor returns a newly instantiated OffscreenCanvas object.
new OffscreenCanvas(width, height)widthThe width of the offscreen canvas.
heightThe height of the offscreen canvas.
This example creates a new offscreen canvas using the OffscreenCanvas() constructor. We then initialize a WebGL context on it using the getContext() method.
const offscreen = new OffscreenCanvas(256, 256);
const gl = offscreen.getContext("webgl");OffscreenCanvas, the interface this constructor belongs to