float goldenMean = 1.61803399f; float currentShiftValue = (1.0f-goldenMean)*1.0f; float currentAngle=0.0f; float particleSpeed=0.65f; int currentTimer=0; int spawnDelay=3; int numParticles = 200; int toggle=0; color colBack,colA,colB; CParticle [] particles = new CParticle[numParticles]; void setup() { // set size of window. size(400,400); // Allocate the particles. for (int i=0;ispawnDelay) { currentTimer=0; // find a free particle. for (int i=0;iwidth+psize || particles[i].y<-psize || particles[i].y>height+psize) particles[i].mode=0; } } if (keyPressed && key=='r') randomise(); setColours(); } // A very simple particle class. class CParticle { CParticle() { x=0.0f; y=0.0f; vx=0.0f; vy=0.0f; mode=0; time=0; } float x,y,vx,vy; // position and velocity components. int mode,time; } float colAngle=0.0f; void setColours() { colAngle+=0.1f; if (colAngle>100.0f) { colAngle=0.0f; randomise(); } colorMode(HSB, 100); float sep=4.5f; colBack=color(wrap(colAngle,100),50,70,6); colA=color(wrap(colAngle+sep,100),50,100); colB=color(wrap(colAngle-sep,100),50,100); } void randomise() { float multiplier=1.0f+(float)((int)(random(1.0f)*5.0f)); if (random(1.0f)<0.5f) currentShiftValue = goldenMean*multiplier; else currentShiftValue = (1-goldenMean)*multiplier; } float wrap(float val, float range) { if (val<0)return val+range; if (val>range)return val-range; return val; }