Pages to see:
« Found this in my pocket: | Main | A Circular Vortex...spinning...spinning. »
Thursday
Jul022009

Recursion...First Attempt

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.

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>