Creating the perfect circle

using FlashMX’s drawing API here’s a simple way to create a perfect circle

you can store this fla and just copy the code into whatever you’re doing. change the variables and presto … you have a circle

the variables are commented so you should be able to easily figure out how you want to change them =)

i hope this is of use to someone


_root.createEmptyMovieClip("circle", 500);
lcol = 0xFF0000;
// Line color
fcol = 0xFF9900;
// Fill color
lwid = 5;
// Line width
lal = 90;
// Line alpha
fal = 25;
// Fill alpha
x = 275;
// X-coordinate circle center
y = 200;
// Y - coordinate circle center
R = 100;
// Radius of circle
a = R*0.4086;
// Radius multiplied by constant
b = R*0.7071;
// Radius multiplied by constant
with (_root.circle) {
	lineStyle(lwid, lcol, lal);
	beginFill(fcol, fal);
	moveTo(x-R, y);
	curveTo(x-R, y-a, x-b, y-b);
	curveTo(x-a, y-R, x, y-R);
	curveTo(x+a, y-R, x+b, y-b);
	curveTo(x+R, y-a, x+R, y);
	curveTo(x+R, y+a, x+b, y+b);
	curveTo(x+a, y+R, x, y+R);
	curveTo(x-a, y+R, x-b, y+b);
	curveTo(x-R, y+a, x-R, y);
	endFill();
}

i see a little wavy line at top & bottom outline…:rd:
but it’s cool…:player:

have u ever tried to make a rounded rectangle? if u be so kind…:stuck_out_tongue:

i wonder how to animate this? from none to perfect circle??:q: (-:

i don’t see a wavy line anywhere

and no i haven’t tried to turn it into a rectangle. but that’ll be neat to try.

as far as animating … that’s a whole different matter b/c there are so many ways to animate it.

:cool:

its not perfect :wink:

and you wont ever get a ‘perfect’ circle. Any circle made with the Drawing API in Flash, which uses quadratic bezier curves, will be an approximation, though the 8 curve approximation is more than plenty for the human eye.

For a curved box see http://proto.layer51.com
for animation search the forums (or Macromedia.com, there is an article there with drawing api methods and means of animating them - or atleast altering their ‘position’ in the drawing via a value)