// Simplified from Greenberg 2-01 // how many recursions drawing branches, and overall (rest drawing "leaves") int branchDepth=4, leafDepth=6; void setup() { size(450,300); } void draw() { if(frameCount % 60 != 0) return; background(255); strokeWeight(20); stroke(30,10,5); float trunkLength = random(65,90); int numTrunkSegments = floor(random(7,12)); float x = orgLine(width/2,height, width/2,height-trunkLength, numTrunkSegments, 22); branch(x, height-trunkLength, 0, 12, 25, 15); } // x and y are start of branch // depth is how many recursive calls // thickness is weight of stroke for branch // xo and yo are initial offsets for incrementing x and y (plus an additional random amount) void branch(float x, float y, int depth, float thickness, float xo, float yo) { if (depth <= leafDepth) { int numBranches=2; // more numerous branches higher up if (depth>branchDepth) numBranches = floor(random(2,17)); int dir=1; // alternate left/right for (int i=0; i