views:

162

answers:

1

i'm trying to build a circle using lines. each line starts in the centre of the circle and is as long as the circle's radius. using a loop along with sine and cosign waves, i can build the circle using the sine and cosign to mark the coordinates of the lineTo parameter.

my problem is with the line thickness parameter of lineStyle. i would like the ends of the lines to match up perfectly, no matter how big the circumference of the circle, but i can't figure out a proper method for the line thickness.

//this is what makes sense to me, but it still creates some gaps
lineThickness = 1 + (((nRadius * 2) * Math.PI) - 360) / 359;

for(var i:int = 0; i < 360; i++)
{
    // Convert the degree to radians.
    nRadians = i * (Math.PI / 180);

    // Calculate the coordinate in which the line should be drawn to.
    nX = nRadius * Math.cos(nRadians);
    nY = nRadius * Math.sin(nRadians);

    // Create and drawn the line.
    graphics.lineStyle(lineThickness, 0, 1, false, LineScaleMode.NORMAL, CapsStyle.NONE);
    graphics.moveTo(0, 0);
    graphics.lineTo(nX, nY);
}

to make the ends of the lines meet up at the circles circumference, without any gaps, i need to widen the lines to fill in the space that's remaining. what makes sense to me, but doesn't work, is to subtract the 360 from the circumference, then divide that number by the amount of empty slots between the lines (which is 359) and adding that number the the thickness of 1.

what's concerning me is that the lineStyle thickness parameter is a Number, but seems to take only values between 0 and 255, so i'm not sure if a floating point number like 1.354 is a valid thickness.

any ideas?

+1  A: 
jolyonruss