class Tree { ArrayList tree = new ArrayList(); float rootx; float rooty; float rootangle; float branchsize; int maxL; Tree(float rx_, float ry_, float ra_, float bs_, int mL) { rootx=rx_; rooty=ry_; rootangle=ra_; branchsize=bs_; maxL=mL; branch(-1, rootx, rooty, branchsize, rootangle, 1, maxL); childinfo(); } void branch(int p, float rx, float ry, float d, float a, int L, int MAXL) { float nx, ny; int indexhold; if(L < MAXL) { //Calculate and draw branch nx=rx+d*cos(-1*radians(a)); ny=ry+d*sin(-1*radians(a)); //Add to Arraylist indexhold=tree.size(); tree.add(new Node(L, indexhold, p, rx, ry, a, d)); //Recurse branch(indexhold, nx, ny, d*.7, a+random(10,25), L+1, MAXL); branch(indexhold, nx, ny, d*.7, a-random(10,25), L+1, MAXL); } }//END branch void regenerate() { tree.clear(); branch(-1, rootx, rooty, branchsize, rootangle, 1, maxL); childinfo(); }//END regenerate void childinfo() { for(int i=0; i= 0) { Node n2= (Node) tree.get(n.getPARENT()); if(n2.getC1()==-1) { n2.setC1(n.getME()); } else { n2.setC2(n.getME()); } } } } void render() { float x, y; stroke(255); for(int i=0; i= 0) { Node n2= (Node) tree.get(n.getPARENT()); n.setRX(n2.returnx()); n.setRY(n2.returny()); } } }//END alter /////////////////////////////////////////////////////////////////////////////// //Node Control FUNCTIONS /////////////////////////////////////////////////////////////////////////////// void controltree(int arg, int shakepiece) { for(int i=0; i90) { n.setA(n.getA()+random(-5,5)); } }//END angleshake() void levelshake(int i) { Node n= (Node) tree.get(i); if(n.getLEVEL()>4) { n.setA(n.getA()+random(-5,5)); } }//END levelshake() }//END Tree