MDN self-hosted library · e01.org

OffscreenCanvas: getContext() method

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
    const gl = canvas.getContext("webgl", {
      antialias: false,
      depth: false,
    });
js
const offscreen = new OffscreenCanvas(256, 256);
const gl = offscreen.getContext("webgl");

gl; // WebGLRenderingContext
gl.canvas; // OffscreenCanvas