Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
npapajani
npapajani's Profile
1
Posts
2
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Problem with a random tree program....
[4 Replies]
02-Dec-2011 12:51 PM
Forum:
Programming Questions
I have a quick question about this code if anyone could help me with it:
void setup()
{
size(600,600);
smooth();
noLoop();
}
void draw()
{
background(204);
strokeWeight(10);
stroke(140,50,0);
translate(width/2,height);
branch(0);
}
void branch(double depth)
{
if (depth < 10) {
line(0,0,0,-height/3);
//int x = 0;
pushMatrix();
{
translate(0,-height/5);
rotate(random(-PI/4,PI/4));
scale(0.7);
branch(depth + 1);
}
popMatrix();
pushMatrix();
{
translate(0,-height/3);
rotate(random(-PI/4,PI/4));
scale(0.7);
branch(depth + .5);
}
popMatrix();
/* x++;
if (x >= 9)
{
stroke(20,200,0);
}
*/
}
}
void mouseClicked()
{
redraw();
}
I am trying to get the last few branches to be green however I haven't figured out how to do that yet...
Anyone help?? I will be forever grateful
«Prev
Next »
Moderate user : npapajani
Forum