HTML5 Canvas:为什么我的圆圈没有画出来?

时间:2013-11-29 10:09:09

标签: javascript html5-canvas

下面是我的代码草图。我想在图像上画一个圆圈。显示图像,但圆圈不是。

ctx=can.getContext('2d');
backpic=document.getElementById('canpic');
ctx.drawImage(backpic,0,0);
pos=[100,100];
ctx.save();
ctx.beginPath();
ctx.lineWidth=2;
ctx.strokeStyle="green";
ctx.arc(pos[0],pos[1],40,0,2 * Math.PI,false);
ctx.stroke();
ctx.restore();

我做错了什么?

1 个答案:

答案 0 :(得分:1)

你的圈子适合小提琴。

can = document.getElementById("can");
ctx=can.getContext('2d');
pos=[100,100];
ctx.save();
ctx.beginPath();
ctx.lineWidth=2;
ctx.strokeStyle="green";
ctx.arc(pos[0],pos[1],40,0,2 * Math.PI,false);
ctx.stroke();
ctx.restore();

http://jsfiddle.net/8TNdZ/