+ 1
Why this lines? Can anyone one explain each code and its work?
var c=document.getElementById("canvas1"); var ctx=c.getContext("2d"); ctx.fillRect(20,20,100,100);
3 Respuestas
+ 3
var c = document.getElementById("canvas1");
this gets your html canvas element(by its id which is canvas1), and stores it in the var c.
var ctx = c.getContext("2d");
this creates your drawing context of the canvas
ctx.fillRect(20,20,100,100);
this draws a rectangle in your canvas context, at the position (x)20, (y)20, size of (width)100,(height)100
+ 1
wow.! thank you buddy
+ 1
you're welcome :)