rendered paste body_root.drawCirc = function(x1:Number,y1:Number,x2:Number,y2:Number,lineThickness,lineColor, choice) {
//get radiusx
trace(x1+","+y1+","+x2+","+y2);
var radius:Number = (x2-x1)/2;
var rightleft = false;
var downup = false;
var x:Number = null;
var y:Number = null;
if(radius < 0)
{
radius = (x1-x2)/2;
rightleft = true;
}
yRadius = (y2-y1)/2;
if(yRadius < 0)
{
yRadius = (y1-y2)/2;
downup = true;
}
//get center
if(!rightleft)
x = radius + x1;
else
x = x2 + radius;
if(!downup)
y = y1 - yRadius;
else
y = yRadius + y2;
trace("Radius: " + radius + " RadiusY: " + yRadius);
trace("Right to left?"+rightleft + "Down up?" + downup);
trace("x: "+x+" y: "+y);
// x, y = center
// radius = radius of oval. If [optional] yRadius is defined, r is the x radius.
// yRadius = [optional] y radius of oval.
if (arguments.length<3) {
return;
}
// init variables
var theta, xrCtrl, yrCtrl, angle, angleMid, px, py, cx, cy;
// if only yRadius is undefined, yRadius = radius
if (yRadius == undefined) {
yRadius = radius;
}
// covert 45 degrees to radians for our calculations
theta = Math.PI/4;
// calculate the distance for the control point
xrCtrl = radius/Math.cos(theta/2);
yrCtrl = yRadius/Math.cos(theta/2);
// start on the right side of the circle
angle = 0;
this.moveTo(x+radius, y);
// this loop draws the circle in 8 segments
for (var i = 0; i<8; i++) {
// increment our angles
angle += theta;
angleMid = angle-(theta/2);
// calculate our control point
cx = x+Math.cos(angleMid)*xrCtrl;
cy = y+Math.sin(angleMid)*yrCtrl;
// calculate our end point
px = x+Math.cos(angle)*radius;
py = y+Math.sin(angle)*yRadius;
// draw the circle segment
if(choice == 1)
{
_root.line_mine.lineStyle(lineThickness,lineColor,100);
_root.line_mine.curveTo(cx, cy, px, py);
}
else
{
_root.line.lineStyle(lineThickness,lineColor,100);
_root.line.curveTo(cx, cy, px, py);
}
}
};