// seed parameters float seedGravity = 0.03; // how fast seeds "fall" to the central axis, before growing float seedEnergyThreshhold = 40; // how much spectrum energy a seed needs to start growing float seedSize = 0.15; // seed circle size as a proportion of segment length int growAge = 2000; // time steps before a seed can grow int maxAge = 6000; int yGrowLimit = -1000; // horizontal threshhold - only seeds left of this position can grow float driftfriction = 0.002; class Seed{ float ypos; float xpos; float curlx; // store the x dimension of the curl here float seedangle; // initial rotation float angle; // equivalent to segment angle int band; // freq band float spin; int age; float driftvelocity; float xspin; Seed(float xdim_in, float xpos_in, float ypos_in, float seedangle_in, float angle_in, int band_in, float spin_in){ // constructor xpos = xpos_in; curlx = xdim_in; ypos = ypos_in; seedangle = seedangle_in; angle = angle_in; band = band_in; spin = spin_in; age = 0; Seeds.add(this); // add yourself to the arraylist driftvelocity = random(0.01,0.2); xspin = 0; } void drawSeed(){ float instantEnergy = (spectrum.getAvg(band)*(band+1)); age++; if (age > maxAge && Seeds.size() > 5) Seeds.remove(this); xpos = max(0,xpos-seedGravity); // seeds "fall" towards the central axis over time driftvelocity = constrain(driftvelocity+((0.0001*instantEnergy)-driftfriction),0,0.15); ypos += max(0,driftvelocity-driftfriction); xspin += driftvelocity*0.1; angle = (angle+(driftvelocity*0.05))%TWO_PI; //seedangle += driftvelocity*0.1; if (ypos > 200) ypos = -1300;//(ypos < -1200) ypos = 0; // if you're at the central axis, energy is over the threshhold, and there's room in the world if (xpos == 0 && instantEnergy > seedEnergyThreshhold && Curls.size() < maxCurls && age > growAge && ypos > yGrowLimit){ Curl newCurl = new Curl(band,curlx,ypos,seedangle,angle,spin); // grow! //println(curlx); Seeds.remove(this); // remove the seed from the array } float segmentlength = 50-band;//lengthfactor/float(band+1); float seeddiam = seedSize*(segmentlength+instantEnergy); // length for seed radius pushMatrix(); rotateY(seedangle); translate(xpos,ypos); rotateZ(angle); rotateX(xspin); float growFactor = min(age,growAge)/float(growAge);//min(age-(growAge*0.5),growAge*0.5)/(growAge*0.5); float stalkLength = growFactor*seedSize*seeddiam*0.5; int seedsteps = 30; for (int s=0; s<(growFactor*seedsteps); s++){ float spiralramp = s/float(seedsteps); if (s==seedsteps-1) { strokeWeight(baseStrokeWeight+(instantEnergy*strokeWeightEnergyFactor)); line(seeddiam*0.5,0,(seeddiam*0.5)+(seeddiam*growFactor*2),0); strokeWeight(baseStrokeWeight); } else { line(seeddiam*0.5,0,(seeddiam*0.5)+(growFactor*seeddiam*spiralramp),0);//line(seeddiam*0.5,0,(seeddiam*0.5)+(growFactor*seeddiam*0.3),0); } rotateZ(TWO_PI/seedsteps); } ellipse(0,0,seeddiam,seeddiam); // draw the seed popMatrix(); } }