问答详情
源自:6-3 绘制一角弯月

怎么没有月亮

drawMoon(context,2,200,200,150,30);

function drawMoon(cxt,d,x,y,r,rot){

cxt.save();

cxt.translate(x,y);

cxt.scale(R,R);

cxt.rotate(rot*Math.PI/180);

moon(cxt,d);

cxt.fillStyle = "#fb5";

cxt.fill();

cxt.restore();

}

function moon(cxt,d){

cxt.beginPath();

cxt.arc(0,0,1,0.5*Math.PI,Math.PI*1.5,true);

cxt.moveTo(0,-1);

cxt.arcTo(d,0,0,1,dis(0,-1,d,0)/d);

cxt.closePath();

}

function dis(x1,x2,y1,y2){

return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));

}


提问者:宝慕林2917688 2016-12-22 09:55

个回答

  • 陈思语
    2016-12-22 09:59:25
    已采纳

    cxt.scale(R,R);    哪来的R???