ImageBitmapRenderingContext: canvas property

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{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