其实TAMA酱不是我名字
2016-05-22 11:05
function drawMoon(cxt,x,y,R,rot){
cxt.save();
cxt.translate(x,y);
cxt.scale(R,R);
cxt.rotate(rot/180*Math.PI);
moonPath(cxt);
cxt.fillStyle = "white";
cxt.fill();
cxt.restore();
}
function moonPath(cxt){
cxt.beginPath();
cxt.arc(0,0,1,1.5*Math.PI,0.5*Math.PI,false);
cxt.moveTo(0,-1);
cxt.arcTo(1.2,0,0,1,dis(1.2,0,0,-1)/1.2);
cxt.closePath();
}
function dis(x1,y1,x2,y2){
return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
cxt.arc(0,0,1,1.5*Math.PI,0.5*Math.PI,false);
最后一个参数改成true
cxt.arc(0,0,1,0.5*Math.PI,1.5*Math.PI,true);
Canvas绘图详解
72881 学习 · 422 问题
相似问题