ArrayList tree = new ArrayList(); void setup() { size(700,700); background(0); stroke(255); smooth(); //noLoop(); //Generate Tree branch(-1, width/2, height-50, 150, 90, 1); } void draw() { //background(0); fill(0,0,0,100); rect(0,0,width,height); //Draw tree DRAWtree(); //Node s= (Node) tree.get(1); //s.setA(mouseX); //s= (Node) tree.get(0); //s.setRX(mouseX); s.setRY(mouseY); mess(); Altertree(); } void branch(int p, float rx, float ry, float d, float a, int L) { float nx, ny; int indexhold; if(L < 10) { //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(indexhold, p, rx, ry, a, d)); //Recurse branch(indexhold, nx, ny, d*.7, a+random(10,25), L+1); branch(indexhold, nx, ny, d*.7, a-random(10,25), L+1); } }//END branch void DRAWtree() { float x, y; for(int i=0; i= 0) { Node n2= (Node) tree.get(n.getPARENT()); n.setRX(n2.returnx()); n.setRY(n2.returny()); } } }//END Altertree class Node { int me; int parent; float rx; float ry; float a; float d; Node(int me_, int parent_, float rx_, float ry_, float a_, float d_) { me=me_; parent=parent_; rx=rx_; ry=ry_; a=a_; d=d_; } void setME(int me_){me=me_;} int getME(){return me;} void setPARENT(int parent_){parent=parent_;} int getPARENT(){return parent;} void setRX(float rx_){rx=rx_;} float getRX(){return rx;} void setRY(float ry_){ry=ry_;} float getRY(){return ry;} void setA(float a_){a=a_;} float getA(){return a;} void setD(float d_){d=d_;} float getD(){return d;} float returnx() { return rx+d*cos(-1*radians(a)); } float returny() { return ry+d*sin(-1*radians(a)); } }