/* * ARTS 102 - Aesthetics of the Algorithmic Image * Johannes Goerz (johannes.goerz@gmail.com) * 2005-12-04 */ Tentacle[] t; int maxtentacles, framecounter, life; int[][] startpoints; color[] tcolors; void setup() { // general procesing parameters size(600,600); smooth(); background(0); framerate(25); noStroke(); // animation parameters maxtentacles = 8; life = 30; // setup starting positions; startpoints = new int[4][2]; startpoints[0][0] = 80; startpoints[0][1] = 80; startpoints[1][0] = width-80; startpoints[1][1] = height-80; startpoints[2][0] = 80; startpoints[2][1] = height-80; startpoints[3][0] = width-80; startpoints[3][1] = 80; // setup tentacle colors tcolors = new color[2]; tcolors[0] = color(255,100); tcolors[1] = color(255,0,0,100); // create tentacles t = new Tentacle[maxtentacles]; for(int i = 0; i < maxtentacles; i++) { createNewTentacle( i ); } } void draw() { noStroke(); // fade background every 2 frames if(framecounter%2==0) { fill(0,20); rect(0,0,width,height); } framecounter++; // move tentacles for(int i = 0; i < t.length; i++) { int x; if(i == 0) { Vector v = new Vector(); v.init(width/2, height/2); t[i].move(v); } else { t[i].move( t[0].position ); } } } 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) )); if(id == 0) { t[id].initialize( id, tcolors[1], int(life + random(life)), true); } else { t[id].initialize( id, tcolors[0], int(life + random(life)), false); } } void mousePressed() { noLoop(); } void mouseReleased() { loop(); }