A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/apis/canvas/CanvasRenderingContext2D/canvas below:

canvas ยท WebPlatform Docs

canvas Summary

A (read-only) reference to the canvas element that the CanvasRenderingContext2D object was created for.

Property of apis/canvas/CanvasRenderingContext2Dapis/canvas/CanvasRenderingContext2D

Syntax

Note: This property is read-only.

var result = CanvasRenderingContext2D.html/elements/canvas;
Return Value

Returns an object of type ObjectObject

Examples

This example gets the id of the canvas object for which the 2D context was created.

<canvas id="myCanvas" width="300" height="150" style="border:1px solid black;"></canvas>
<p>. . .</p>
<script>
var can = document.getElementById("myCanvas");
var ctxt = can.getContext("2d");
ctxt.fillStyle = "#0000ff";
ctxt.fillRect(10,10,150,75);
alert(ctxt.canvas.id); 
</script>
Notes

You can use the canvas property to access the canvas element from functions where you passed in only the current CanvasRenderingContext2D object.

Related specifications
W3C HTML Canvas 2D Context
W3C Candidate Recommendation
Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4