April 16, 2003
drawEgg()

After it works so nicely on Mike Chambers' site I'll also give Sean Voisen's MTCodeBeautifier a try.

As an example here's a little prototype that helps you to draw eggs:


MovieClip.prototype.drawEgg = function(x, y, r) {
var rx = r/1.618;
var ry = r;
var ry1 = 2*ry*.618;
var ry2 = 2*ry*.382;
this.moveTo(x+rx, y);
this.curveTo(rx+x, -0.4142*ry1+y, 0.7071*rx+x, -0.7071*ry1+y);
this.curveTo(0.4142*rx+x, -ry1+y, x, -ry1+y);
this.curveTo(-0.4142*rx+x, -ry1+y, -0.7071*rx+x, -0.7071*ry1+y);
this.curveTo(-rx+x, -0.4142*ry1+y, -rx+x, y);
this.curveTo(-rx+x, 0.4142*ry2+y, -0.7071*rx+x, 0.7071*ry2+y);
this.curveTo(-0.4142*rx+x, ry2+y, x, ry2+y);
this.curveTo(0.4142*rx+x, ry2+y, 0.7071*rx+x, 0.7071*ry2+y);
this.curveTo(rx+x, 0.4142*ry2+y, rx+x, y);
};

And this is how it's used:

this.clear();
for (var i = 0; i<100; i++) {
this.lineStyle(0, 0);
this.beginFill(0xffffff);
var y = 100+Math.random()*300;
this.drawEgg(100+Math.random()*500, y, y/10);
this.endFill();
}

Posted at April 16, 2003 08:25 PM | Further reading
Comments

Hmmmm. These [BR] look a bit strange...

Posted by: coma2mario on April 16, 2003 08:41 PM

Yeah, yeah ... there is a bug when using Convert Line Breaks. I don't know how to get around it.

Posted by: Sean Voisen on April 16, 2003 10:51 PM

turn off "convert line breaks" and then wrap your non-code text in

that should do it.

mike chambers

mesh@macromedia.com

Posted by: mike chambers on April 17, 2003 12:21 AM

Thanks guys. I already turned "convert line breaks" off, but i'll try it again.

Posted by: coma2mario on April 17, 2003 10:17 AM

Mario,

I had been thinking about how to draw an egg shape just last week. Thanks for posting this - now I can deliver an easter themed screen saver to our clients. If you'd like to see it I've posted it on Flazoom.com here:

http://www.flazoom.com/cooler/1050590738,38563,.shtml

Thanks,

CHris

Posted by: CHris on April 17, 2003 04:50 PM
Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?



Thank you!

Most Visited Entries
Sketches, Works & Source Code
Lectures
Contact
Backlog
In Love with
Powered by
Movable Type 2.661

© Copyright Mario Klingemann

Syndicate this site:
RSS 1.0 - RSS 2.0

Quasimondo @ flickr
Quasimondo @ LinkedIn
Quasimondo @ Twitter
Quasimondo @ Facebook
Quasimondo @ MySpace
Quasimondo is a Bright
Citizen of the TRansnational Republic
My other blog in german
Impressum


My family name is written Klingemann,
not Klingelmann, Klingeman, Klingaman, Kingemann,
Kindermann, Killingaman, Klingman, Klingmann, Klingonman
Klingemman, Cleangerman, Klingerman or Kleangerman

profile for Quasimondo at Stack Overflow, Q&A for professional and enthusiast programmers