Fractal Plant

May 6, 2012 at 9:22am

Fractal Plant

I was trying to replicate in Javascript the Fractal Plant example provided by odewahn1 in the O’Reilly forum, originally done in processing. Obviously with little success. Seems the recursion is not working as expected. Any idea how to modify it?

Attachments:
  1. train7.js
#63445
May 15, 2012 at 12:51pm

there is ‘var’ missing in line 54 in function fractal():


for (var i = 0; i < branches; i++)

#228764
May 15, 2012 at 1:00pm

edited the color and position of the tree…

Attachments:
  1. train6.js
#228765
May 17, 2012 at 9:06am

Excellent. Thanks a lot for your help.
Regards
Tim

#228766
Jan 31, 2013 at 10:46am

Great !!!
Thank you for the lesson

I am absolutely new in JavaScript so i have primitive questions:
Is it possible to create inlets for dynamic change of parameters such as
branches, depth, minAngle etc
I guess it should be smth like:

function branches(v)
{
branches = v;
}
and then massage box to the JSobject ( branches $1 ) ……but this doesn`t work

And another question if it possible to “grow” this tree from line to line?

Ps. i know one good answer: “go and learn JS!” )) ….. but anyway

#228767
Jan 31, 2013 at 12:29pm

yes, i think its possible. try
inlets = 0;
if (jsarguments.length >= 2)
inlets = jsarguments[1];
if (!inlets)
inlets = 1; // default value
function branches(v){
inlets = v;
branches = v;
paint();
}

see http://www.tim-schenk.de/max-javascript-reference/symbols/#inlets

#228768
Feb 5, 2013 at 10:45am

Thnx.
I`ll try to understand it…

#228769

You must be logged in to reply to this topic.