class Branch { float xp1, xp2; float yp1, yp2; float sangle, eangle; float startw; Branch() { }; void setX1(float x) { this.xp1 = x; } void setX2(float x) { this.xp2 = x; } void setY1(float y) { this.yp1 = y; } void setY2(float y) { this.yp2 = y; } void setSW(float s) { this.startw = s; } void calcSAngle() { this.sangle = atan2( (this.yp2 - this.yp1), (this.xp2 - this.xp1)); } void render() { float hyp = sqrt(pow((xp2 - xp1),2) + pow((yp2 - yp1),2)); pushMatrix(); translate(xp1,yp1); rotate(sangle); for (float i=0; i < hyp; i+=3) { rectMode(CENTER); noStroke(); fill(gStemred, gStemgreen, gStemblue, gStemalpha); float bheight = (startw - (i * ((startw - pow(startw,0.9))/hyp))); // if (gReactive) { // bheight = ((startw + gBranchThinkness) - (i * (((startw + gBranchThinkness) - pow((startw + gBranchThinkness),0.9))/hyp))); // } //float extraThinkness = (gBranchThinkness * SOUND_SENSITIVITY); // print ("extraThinkness = "+ extraThinkness); rect(i,0,3 + random(2), bheight); /* rect(i,0,3 + random(2), extraThinkness + (startw - (i * ((startw - pow(startw,0.9))/hyp))));*/ // } // else { // rect(i,0,3 + random(2), (startw - (i * ((startw - pow(startw,0.9)) / hyp)))); // } }; popMatrix(); }; };