Here's the general purpose arc drawing routine. It accepts two additional arguments, bA (begin angle) and eA (end angle), both of which are expressed in degrees (0-360).
code:
degToRad = Math.PI/180;
MovieClip.prototype.drawArc = function(x,y,radius, bA,eA)
{
if (eA < bA) eA += 360;
var r = radius;
var n= Math.ceil((eA-bA)/45);
var theta = ((eA-bA)/n)*degToRad;
var cr = radius/Math.cos(theta/2);
var angle = bA*degToRad;
var cangle = angle-theta/2;
this.moveTo(x+r*Math.cos(angle), y+r*Math.sin(angle));
for (var i=0;i < n;i++)
{
angle += theta;
cangle += theta;
var endX = r*Math.cos (angle);
var endY = r*Math.sin (angle);
var cX = cr*Math.cos (cangle);
var cY = cr*Math.sin (cangle);
this.curveTo(x+cX,y+cY, x+endX,y+endY);
}
}
This is a modified version of the routine I used to make this:
http://krazydad.com/bestiary/bestiary_piechart.html




Reply With Quote