PDA

View Full Version : Fractal Tree



jerez_z
January 18th, 2006, 02:56 AM
Here is a growing fractal tree...with pretty strong wind at the end:


vars = {len:200, h:120, max:4, age:80};
function generateBranch(clip, level) {
temp = clip.createEmptyMovieClip("branch"+clip.getNextHighestDepth(), clip.getNextHighestDepth());
(clip == _root) ? temp._x=275 : null;
(clip == _root) ? temp._y=400 : temp._y=(Math.random()*vars.h+(vars.len-vars.h))*-1;
(clip != _root) ? temp._rotation=Math.random()*90-45 : null;
temp.lineStyle(3, 0x000000, 100);
temp.lineTo(0, -200);
temp._xscale = temp._yscale=0;
temp.stats = {l: level, c: 0}
temp.onEnterFrame = function() {
this._xscale = (this._yscale += ((100/this.stats.l)-this._yscale)/5);
(this._yscale/(100/level)>.9 && this.stats.c<=this.stats.l*6+1 && this.stats.l<_root.vars.max) ? this.stats.c++ : null;
(this._yscale/(100/level)>.9 && this.stats.c<=this.stats.l*6+1 && this.stats.l<_root.vars.max) ? generateBranch(this, this.stats.l+1) : null;
if (this._yscale/(100/level)>.99) {
(this.stats.l == _root.vars.max) ? addWind(this) : delete this.onEnterFrame;
}
};
}
generateBranch(_root, 1);
function addWind(clip) {
if (clip.stats.l>_root.vars.max-1) {
clip.stats = {age:0, yv:0, xv:0, rv:0};
clip.onEnterFrame = function() {
this.localToGlobal(p={x:this._x, y:this._y});
(this.stats.age>_root.vars.age) ? this.stats.yv += .7 : this.stats.age++;
(this.stats.age>_root.vars.age) ? this.stats.xv += Math.random() : null;
(p.x>750 || p.x>600) ? addWind(this._parent) : null;
(p.y>600) ? this.removeMovieClip() : this._y += this.stats.yv;
(p.x>750) ? this.removeMovieClip() : this._x += this.stats.xv;
};
}
}


EDIT: bedtime

Ben H
January 18th, 2006, 03:04 AM
dang, i was gonna do that :P

-ben

treatkor
January 18th, 2006, 05:22 AM
nice tree! reminds me of bamboo shapes

hybrid101
January 18th, 2006, 08:13 AM
a fractal tree...nice...i was waiting for this submission! nice man!

jerez_z
January 18th, 2006, 10:35 AM
i'm thinking about removing the wind at the end. what do you guys think

treatkor
January 18th, 2006, 10:40 AM
i'm not seeing the wind at all. ? i just see the branches grow and that's it.

jerez_z
January 18th, 2006, 10:41 AM
well it takes a few seconds to start... and its pretty computer intensive

McGiver
January 18th, 2006, 12:13 PM
damn, I wanted to do fractals ...

nice one nevertheless :)

NiñoScript
January 18th, 2006, 01:15 PM
beautiful :)
i like the *wind* at the end, but its really processor intensive.. maybe you could let the leaves fall one by one instead of all at the same time.

:party:


edit:
for example, i added a modified version, which lets the leaves fall one by one :) (its still processor intensive, but not THAT much :geek: )

kdd
January 18th, 2006, 02:10 PM
Nineo, that's really "kool". :) jerez_z, your entry is nice too.

jerez_z
January 18th, 2006, 04:52 PM
wow take my fire nino jeez :P

creativeFuzion
January 19th, 2006, 03:59 AM
Is that wheat growing? It really does look like wheat.

Argh, it still kicks my AS skills anyday. :)

~Philip

Seb Hughes
January 19th, 2006, 09:55 AM
Very nice Jeremy, but what ninoscript did, by making it fall one by one was better then all falling at once, bvut very nice, idea it was just a matter of time before a freactel was posted.

NiñoScript
January 19th, 2006, 03:31 PM
wow take my fire nino jeez :P
haha, sorry :lol:

touseef
December 12th, 2006, 12:57 PM
I want to ask.. HOW Could i ZOOM the Treee.. i want to Appear it along with Zoom in and then Zoom out.
could any one help me about this? :puzzled:

touseef
December 12th, 2006, 05:23 PM
is any one can tell me how to terminate the Tree, means i want to Disapper it and appear it again along with differnt colours ..

Thanks in Advance.:cap:

jasvarghese
January 25th, 2007, 01:39 AM
good buddy....