xxxxxxxxxx
float thetaa;
void branches(float k) {
// Each branch will be 2/3rds the size of the previous one
k *= 0.66;
// All recursive functions must have an exit condition!!!!
// Here, ours is when the length of the branch is 2 pixels or less
if (k > 2) {
pushMatrix(); // Save the current state of transformation (i.e. where are we now)
rotate(thetaa); // Rotate by theta
line(0, 0, 0, -k); // Draw the branch
// translate(0, -h); // Move to the end of the branch
branches(k); // Ok, now call myself to draw two new branches!!
popMatrix(); // Whenever we get back here, we "pop" in order to restore the previous matrix state
// Repeat the same thing, only branch off to the "left" this time!
pushMatrix();
//rotate(-thetaa);
line(0, 0, 0, -k);
translate(0, -k);
branches(k);
popMatrix();
}
}