/* * ARTS 102 - Aesthetics of the Algorithmic Image * Johannes Goerz (johannes.goerz@gmail.com) * 2005-12-04 */ Tentacle[] t; int maxtentacles, framecounter, life; int[][] startpoints; Vector target; boolean showcenter; void setup() { // general procesing parameters size(400,600); smooth(); background(0); framerate(25); noStroke(); // animation parameters maxtentacles = 6; life = 25; // setup starting positions; startpoints = new int[2][2]; startpoints[0][0] = width/2; startpoints[0][1] = 80; startpoints[1][0] = width/2; startpoints[1][1] = height-80; // create tentacles t = new Tentacle[maxtentacles]; for(int i = 0; i < maxtentacles; i++) { createNewTentacle( i ); } } void draw() { noStroke(); // fade background every 5 frames if(framecounter%5==0) { fill(0,15); rect(0,0,width,height); } framecounter++; // move tentacles target = new Vector(); float z = 2*PI * (framecounter%100) / 100; float x = width/2 + sin(z) * width/3; float y = height/2; fill(255,0,0,100); ellipse(x,y,5,5); target.init(x,y); for(int i = 0; i < t.length; i++) { t[i].move( target ); } } void createNewTentacle( int id ) { int _point = int(random(0,startpoints.length)); if (_point > startpoints.length -1 ) { _point = startpoints.length - 1; } t[id] = new Tentacle( startpoints[_point][0] + int( random(-20,20) ), startpoints[_point][1] + int( random(-20,20) )); t[id].initialize( id, color(255,100), int(life + random(life)), false); } void mousePressed() { noLoop(); } void mouseReleased() { loop(); }