/* * 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 = 16; 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[3]; tcolors[0] = color(128,0,0,100); tcolors[1] = color(0,128,0,100); tcolors[2] = color(0,0,128,100); // create tentacles t = new Tentacle[maxtentacles]; for(int i = 0; i < maxtentacles; i++) { createNewTentacle( i ); } } void draw() { noStroke(); // fade background every frame if(framecounter%1==0) { fill(0,30); rect(0,0,width,height); } framecounter++; // move tentacles for(int i = 0; i < t.length; i++) { int prey; while(true) { prey = int(random(0,t.length)); if(prey != i && prey < t.length) { break; } } t[i].move( t[prey].position ); } } void createNewTentacle( int id ) { t[id] = new Tentacle( int(random(50,width-50)), int(random(50,height-50))); t[id].initialize( id, tcolors[int(random(0,tcolors.length-0.000001))], int(life + random(life)), false); } void mousePressed() { noLoop(); } void mouseReleased() { loop(); }