+ 3
How to animate in canvas????
I want to make a line move in a 360 degree motion. How do I do this I only know how to draw it so please write out the program so I can see how it works.
8 RĂ©ponses
+ 2
are trying to do a clock?that's very complex
+ 2
you would have to plot Math.sin values against Math.cosine values then create points and switch the lineTo() between each of those points
+ 1
you would have to know how to use functions,where's the code?
+ 1
This would work
0
No..just trying to move it around. Or even move it forward or something. I just want to get familiar with animating on it
0
I donât have the code yet. I know how to use JavaScript functions...but not how to animate with the canvas and JavaScript
0
function animate(){
ctx.clearRect(0,0,canvas.width,canvas.height);
ctx.beginPath();
ctx.moveTo(100,100);
ctx.lineTo(Math.random()*100,100);
ctx.stroke();
requestAnimationFrame(animate);
}
0
Would that make it spin in a 360 degree motion?????