I want to run a circle through every point of a quadric curve because I'm making a circle-throw game. This is an example code of my problem:
canvas.width = 200;
canvas.height = 200;
ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.moveTo(20,20);
ctx.quadraticCurveTo(20,200,200,200);
ctx.stroke();
ctx.closePath();
ctx.beginPath();
ctx.fillStyle = "orange";
ctx.arc(20,20,20,Math.PI*2,0);
ctx.fill();
function loop(){
//Code to move circle through the quadric curve
//???
//???
ctx.beginPath();
ctx.fillStyle = "orange";
ctx.arc(20,20,20,Math.PI*2,0);
ctx.fill();
requestAnimationFrame(loop);
}
*{
margin: 0;
padding: 0;
}
<canvas id="canvas"></canvas> Run that circle through the curve
How can I solve this?
Sorry for my English and thanks for the answers!