+ 4

Var ctx=c.getcontext()

c is for getting context or ctx ?

9th Aug 2018, 7:26 PM
Armann
Armann - avatar
5 Respostas
+ 3
To make it more simple, in order to work with a canvas element that you have in HTML file, you have to do this in JavaScript: var can = document.getElementById("..."); var c = can.getContext("2d"); ***Note that variable names(can, c) can be chosen by you (you can change them as you wish).
9th Aug 2018, 9:30 PM
Ledio Deda
Ledio Deda - avatar
+ 10
ctx and c are just variable names they have nothing to do with canvas or context but here c would get the canvas element and ctx would access the canvas '2d' methods
9th Aug 2018, 10:38 PM
D_Stark
D_Stark - avatar
+ 4
thanks everyone.👍🙏
9th Aug 2018, 10:44 PM
Armann
Armann - avatar
+ 2
It can be assumed that 'c' is the variable for the page's Canvas element. If not, then that code is erroneous. var c = document.querySelector("#canvas"); var ctx = c.getContext("2d"); 'ctx' is used to grab the Context of Canvas.
9th Aug 2018, 8:19 PM
ghostwalker13
ghostwalker13 - avatar
+ 1
if you are talking about creating a context for a canvas, c is the html DOM element of the canvas. Then you use getContext("2d") to get a context from the canvas element. 3d canvas is supposedly in work.
9th Aug 2018, 8:20 PM
Bebida Roja
Bebida Roja - avatar