【发布时间】:2015-09-19 09:18:49
【问题描述】:
我想在二次曲线的每个点上做一个圆,因为我正在制作一个掷圈游戏。 这是我的问题的示例代码:
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
我该如何解决这个问题?
对不起我的英语,谢谢你的回答!
【问题讨论】:
-
嗨,我发现这个教程看起来和你想要的很相似:html5code.nl/canvas-tutorial/…
-
这不是二次贝塞尔曲线,但是谢谢。
-
我说的差不多,不准确:)
标签: javascript html canvas quadratic-curve