Var ctx=c.getcontext() | Sololearn: Learn to code for FREE!

+4

Var ctx=c.getcontext()

c is for getting context or ctx ?

8/9/2018 7:26:02 PM

Armann

5 Answers

New Answer

+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).

+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

+4

thanks everyone.๐Ÿ‘๐Ÿ™

+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.

+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.