Forums > Javascript

Fractal Plant

May 6, 2012 | 9:22 am

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

May 15, 2012 | 12:51 pm

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


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


May 15, 2012 | 1:00 pm

edited the color and position of the tree…

Attachments:
  1. train6.js

May 17, 2012 | 9:06 am

Excellent. Thanks a lot for your help.
Regards
Tim


January 31, 2013 | 10:46 am

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


January 31, 2013 | 12:29 pm

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


February 5, 2013 | 10:45 am

Thnx.
I`ll try to understand it…


Viewing 7 posts - 1 through 7 (of 7 total)