// Garden of Recursive Trees // Based on Daniel Shiffman's Recursive Tree (arraylist) ArrayList a; float branchWidth = 2; float timetoBranch = 100; void setup() { size(1200,600); frameRate(30); colorMode(RGB,255,255,255,100); background(0); smooth(); // Setup the arraylist and add one tree to it a = new ArrayList(); // A branch has a starting location, a starting "velocity", and a starting "timer" Tree t = new Tree(new Vector3D(width/2,height),new Vector3D(0,-1),timetoBranch, branchWidth); // Add to arraylist a.add(t); } void draw() { for (int i = a.size()-1; i >= 0; i--) { // Get the tree and draw it Tree t = (Tree) a.get(i); t.run(); } } void mousePressed(){ int treeHeight = -height/mouseY/2; Tree t = new Tree(new Vector3D(mouseX,height),new Vector3D(0,constrain(treeHeight,-2,-0.5)),random(timetoBranch-50,timetoBranch+50), random(branchWidth-5,branchWidth+5)); a.add(t); }