Cone
Cone

Reputation: 3

What "2d" means

I understand

var canvas = document.getElementById("myCanvas");

but I don't understand

var ctx = canvas.getContext("2d");

What "2d" means, is it "two dimensional"? I was thinking that getContext(""); is to find some word in the text

English is not my primary language...

<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="200" height="100"
style="border:1px solid #d3d3d3;">
Your browser does not support the canvas element.
</canvas>
<script>
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.arc(95,50,40,0,2*Math.PI);
ctx.stroke();
</script> 
</body>
</html>

Upvotes: 0

Views: 94

Answers (1)

Snow
Snow

Reputation: 4097

What "2d" means, is it "two dimensional"?

Yes

https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext

contextType is a DOMString containing the context identifier defining the drawing context associated to the canvas. Possible values are:

  • "2d", leading to the creation of a CanvasRenderingContext2D object representing a two-dimensional rendering context.

Upvotes: 2

Related Questions