0
Why it is not drawing a line? Please help 🙏
2 odpowiedzi
+ 3
1. When u declare a variable inside window.onload u cannot use it outside because it is out of scope
2. U need to use
ctx.lineto()
not
ctx=lineto()
[SAME WITH OTHERS .stroke() , .moveTo() ]
window.onload = function() {
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.moveTo(0,0);
ctx.lineTo(600,400);
ctx.stroke();
}
+ 1
Thanks 😊