We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › branching effect
Page Index Toggle Pages: 1
branching effect (Read 342 times)
branching effect
Aug 25th, 2008, 4:25am
 
hi, im basically trying to create a tree like structure.

i have written some code that bulids the trunk out of rectangles, each one stacked ontop of the other and gradually getting smaller. i am doin this by using a class that is called each time the program loops.

to create the branches i am randomly generating a number between 1 and 50, if the number is above 45 i call a class that gets the trunk to 'sprout' a branch, that i want to continue growing in the same fashion as the trunk but on an angle.

the problem is, i can only get it to draw a box where there should be a branch. is there a way to 'create' a new class that will continue to be implemented even when a new branch is created later on in the programs cycle?

if need be i can post my code
Re: branching effect
Reply #1 - Aug 25th, 2008, 9:37pm
 
mmm... Think of your trunk as a branch (with angle = 0). So you only need one class.

And this branch keeps growing.

You need to find a way to prevent this trunk-branch from growing when you get a random number above 45. Maybe a boolean could solve this.

Then, just instanciate two other branches (that are going to grow). Etc...
Page Index Toggle Pages: 1