Back to Content

ImageBitmapRenderingContext: canvas property

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

latest967 B
Original Source

{{APIRef("Canvas API")}}{{AvailableInWorkers}}

The ImageBitmapRenderingContext.canvas property, part of the Canvas API, is a read-only reference to the {{domxref("HTMLCanvasElement")}} or {{domxref("OffscreenCanvas")}} object that is associated with the given context.

Value

A {{domxref("HTMLCanvasElement")}} or {{domxref("OffscreenCanvas")}} object.

Examples

Given this {{HTMLElement("canvas")}} element:

html
<canvas id="canvas"></canvas>

You can get a reference to the canvas element within the ImageBitmapRenderingContext by using the canvas property:

js
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("bitmaprenderer");
console.log(ctx.canvas === canvas); // true

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{domxref("ImageBitmapRenderingContext")}} interface
  • Canvas API