开发者

using action script how to draw a semi circle

using action script how to draw a semi circle...i need to add tha semicircle in another circle the 开发者_如何学Ccircle looks like this ![alt text][1]

how to draw a semi circle inside that circle


Use the following function to draw the required arc.

  function drawArc(centerX, centerY, radius, startAngle, arcAngle, steps){
        startAngle -= .25;
        var twoPI = 2 * Math.PI;
        var angleStep = arcAngle/steps;
        var xx = centerX + Math.cos(startAngle * twoPI) * radius;
        var yy = centerY + Math.sin(startAngle * twoPI) * radius;
        moveTo(xx, yy);
        for(var i=1; i<=steps; i++){
            var angle = startAngle + i * angleStep;
            xx = centerX + Math.cos(angle * twoPI) * radius;
            yy = centerY + Math.sin(angle * twoPI) * radius;
            lineTo(xx, yy);
        }
    }
    lineStyle(0, 0xFF0000);
    drawArc(250, 250, 200, 45/360, -90/360, 20);

Semicircle? Well its joining the end points isn't it. Use lineto.


Thank you so much loxxy.. I have made a few alteration and got dashed line too.

function drawArc(centerX, centerY, radius, startAngle, arcAngle, steps){

           centerY=centerY+radius
    startAngle -= .25;
    var twoPI = 2 * Math.PI;
    var angleStep = arcAngle/steps;
          trace(angleStep)
    var xx = centerX + Math.cos(startAngle * twoPI) * radius;
    var yy = centerY + Math.sin(startAngle * twoPI) * radius;
   mc.graphics.moveTo(xx, yy);
    for(var i=1; i<=steps; i++){
        var angle = startAngle + i * angleStep;
        xx = centerX + Math.cos(angle * twoPI) * radius;
        yy = centerY + Math.sin(angle * twoPI) * radius;
        if(i%2==0){
              mc.graphics.moveTo(xx, yy);
        }else{
      mc.graphics.lineTo(xx, yy);
        }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜