請(qǐng)問(wèn)為什么月亮變成了一個(gè)大半圓?用stroke畫(huà)出來(lái)沒(méi)問(wèn)題,一填色就是半圓
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));
?? ?}
2016-09-19
最后一個(gè)參數(shù)改成true
2016-05-23
cxt.arc(0,0,1,0.5*Math.PI,1.5*Math.PI,true);