下面是我的代码草图。我想在图像上画一个圆圈。显示图像,但圆圈不是。
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();
我做错了什么?
答案 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();