/* Attractors IV created in 2005 by Marcus Graf marcus[AT]florito.net // click on screen to create new dots // press [i] to restart // press [p] to toggle pause */ // preset colors: // preset[x]=new color(5028/256.0,22876/256.0,27789/256.0); // nice blue // preset[x]=new color(8139/256.0,7963/256.0,21750/256.0); // purple blue dark ink // preset[x]=new color(14245/256.0,20093/256.0,687/256.0); // jungly green // preset[x]=new color(27931/256.0,12559/256.0,24505/256.0); // nice wine red int nr_att=16; int max_nr_dot=5000; int splotSize=500; int mainTypes=12; Particle[] dot; int dotToSteal; int nr_dot=0; color dotCol; color[] dotColVar; int W,H,W2,H2; int maxpix; float xToW,yToH; boolean newSplot=false; boolean initializeAll=true; boolean paused=false; void setup() { size(400,300); W=width; H=height; xToW=1.2*W/100.0; yToH=1.2*H/100.0; W2=W/2; H2=H/2; maxpix=W*H; } void draw() { if (initializeAll) { initializeAll=false; background(255); setupColors(); setupAttractors(); setupDots(); setupBgBuf(); setupDissolve(); nr_dot=0; } if (!paused) { if (newSplot) { newSplot=false; createNewSplot(); //println("dots: "+nr_dot); } // bgBufCounter++; if (bgBufCounter%3==0) { bgBufFade(0.985074875,0,1); } bgBufCounter++; float steps=50.0; float from=(bgBufCounter%steps)/steps; float to=((bgBufCounter%steps)+1)/steps; bgBufFadeDissolve(0.95,from,to); // bgBufFade(0.995,0,1); drawbgBuf(); updateAttractors(); updateAndDrawDots(); } } void mousePressed() { newSplot=true; } void keyPressed() { if (key=='i') {initializeAll=true; paused=false;} if (key=='p') {paused=!paused;} } void createNewSplot() { for (int i=0;imax_nr_dot) {nr_dot=max_nr_dot;} dotToSteal++; if (dotToSteal==nr_dot) {dotToSteal=0;} } } // PARTICLES void setupDots() { dot=new Particle[max_nr_dot]; for (int i=0;i=0&&x=0&&y