int bailout = 8; float segmentLength = 100; float theta = PI/3; float scaleFactor = 0.75; void setup() { size(512, 512); } void draw() { background(255); stroke(64); translate(width/2, height-64); renderSegment(0); scaleFactor = mouseY/(float)height; theta = PI/3 * (mouseX/(float)width); } void renderSegment(int depth) { if (depth >= bailout) { return; } line(0, 0, 0, -segmentLength); pushMatrix(); translate(0, -segmentLength); rotate(-theta); scale(scaleFactor); renderSegment(depth+1); popMatrix(); pushMatrix(); translate(0, -segmentLength); rotate(theta); scale(scaleFactor); renderSegment(depth+1); popMatrix(); return; }