<canvas id="myCanvas" width="200" height="200" style="border:1px solid #d3d3d3;"> </canvas>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var currentx;
var currenty;
currentx=0;
currenty=200;
MoveRight();
I have functions that should update the canvas element and the global variables but they are not working. For instance my MoveRight function :
function MoveRight()
{
ctx.moveTo(currentx,currenty);
ctx.lineTo(currentx+40,currenty);
currentx=currentx+40;
}
I want my MoveRight function to draw a horizontal line every time it is called and update the global variables (currentx and currenty).