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?

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

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

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

May 15, 2012 at 1:00pm

edited the color and position of the tree…

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

Excellent. Thanks a lot for your help.

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

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;


Feb 5, 2013 at 10:45am

I`ll try to understand it…


You must be logged in to reply to this topic.