Back to Content

GPUCanvasContext: canvas property

files/en-us/web/api/gpucanvascontext/canvas/index.md

latest646 B
Original Source

{{APIRef("WebGPU API")}}{{SecureContext_Header}}{{AvailableInWorkers}}

The canvas read-only property of the {{domxref("GPUCanvasContext")}} interface returns a reference to the canvas that the context was created from.

Value

An {{domxref("HTMLCanvasElement")}} or {{domxref("OffscreenCanvas")}} object instance.

Examples

js
const canvas = document.querySelector("#gpuCanvas");
const context = canvas.getContext("webgpu");

// returns an HTMLCanvasElement reference
context.canvas;

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also