Recursion...First Attempt
Thursday, July 2, 2009 at 11:49PM
Jeff in Processing, Recursion, code

I have a goal of using cellular autonoma to simulate tree growth. This program is an alpha-draft of that, hyper early on in the development cycle. I am pretty sure none of this code will go onto be used in latter versions, but I learned about recursion and that's a good benefit. It is drawn segment by segment, and each segment calls two more. It recurses (I think that's a word) for a random time (well 50% chance of continuing that branch). I added in the ability to start a segment from where you click, it's kinda fun I think...you can paint with the branches. To get the middle branch to stop drawing new branches just hit the 'o' key. Code after the jump...

Oh and I apologize or the size, it fits poorly on the site, but gives more space to draw with so I feel it's worth it.

 

This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.

 

Source code: Recursion_firstattempt

Built with Processing

 

I haven't checked to thoroughly for errors, it may falt if it trys to recurse to many times.

Article originally appeared on J.B. Wincek (http://this.jeffwincek.com/).
See website for complete article licensing information.