+ 1
I canât get this to work??
Whenever I try to use the canvas to draw a shape or something it never works. I always do something like this... var canvas=document.getElementById("canvas"); var ctx=canvas.getContext("2d"); ctx.beginPath(); ctx.moveTo(300, 100); ctx.lineTo(100, 200); ctx.stroke(); Please tell me how to set it up so that I can draw a line like a tried to above???
7 Answers
+ 2
Try embedding your code in a window.onload function
+ 1
window.onload normally is worse than window.addEventListener("DOMContentLoaded",function(){});
0
Ok
0
What do you mean @Brains by embedding?? Can you write it out for me
0
window.onload=function(){
//all your code is here
}
0
Ok
0
Draphar can you help me. Please show me how to animate on canvas