//seed & trunk object //growAgain & display function class Seed { float bx, by; float sSize; color sColor; //minimum distance between the ellipse int MIN_DISTANCE = 1; float angle = 1; Seed() { } Seed(float x, float y, float s) { bx = x; by = y; sSize = s; sColor = color(random(200),40); } //using boolean (grow) to check the second or more release //growing toward the next mouse release void growAgain(float xx, float yy) { if (grow == true) { float x = xx; float y = yy; if ( sqrt( sq(x - bx) + sq(y - by)) > MIN_DISTANCE ) { angle = atan2(x - bx, y - by); bx += MIN_DISTANCE * sin(angle); by += MIN_DISTANCE * cos(angle); bx += noise(bx); by += noise(by); } } } //displaying the ellipse to make the grow animation //translating the 0,0 position to move the ellipse void display() { fill(sColor); pushMatrix(); translate(bx, by); ellipse(0, 0, sSize, sSize); popMatrix(); } }