+ 1
Var and ctx
Which language do these to belong..
3 Respostas
+ 5
ctx is just a variable name
but mostly it is used when getting context for a canvas element in a html page:
<canvas id="myCanvas" width="200" height="100"></canvas>
and in the Javascript code:
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
the getContext("2d") method provides tools to draw 2 dimensional objects on the canvas.
any actions like
drawing line:
ctx.moveTo(0,0); // start from point 0,0
ctx.lineTo(200,100); // draw a line from current location to (200, 100
ctx.stroke(); // draw the line
notice that to draw on the canvas, we are using the ctx object to draw and not the canvas object.
+ 2
var is of javascript and ctx of canvas js
you were seeing canvas it is controlled by js codes
ctx was general name any keyword can be used as Burey Said
+ 1
K thanks