import processing.video.*; //two arrays for x positions and y positions int MAX = 50; int[] xpos = new int[MAX]; int[] ypos = new int[MAX]; Capture video; void setup() { size(500,500); framerate(15); smooth(); video = new Capture(this, "IIDC FireWire Video", 100, 100); //fill everything with 0 at the start for (int i = 0; i < xpos.length; i++) { xpos[i] = 0; ypos[i] = 0; } } void captureEvent(Capture video) { video.read(); } void draw() { float brightest; int bx, by; //initializes brightness brightest = brightness(video.pixels[0]); bx = by = 0; for (int x = 0; x < video.width; x = x + 2) { for (int y = 0; y < video.height; y = y + 2) { color c = video.pixels[x + y * video.width]; if (brightness(c) > brightest) { brightest = brightness(c); bx = x*5; by = y*5; } } } background(0); //image(video, 0, 0); //fill(0); //ellipse(bx,by,50,50); //move all values in the array down one spot (i.e. x[0] = x[1], x[1] = x[2], etc.) for (int i = 0; i < xpos.length-1; i++) { xpos[i] = xpos[i+1]; ypos[i] = ypos[i+1]; } //fill the last spot of the array with the current brightest pixel location xpos[xpos.length-1] = bx; ypos[xpos.length-1] = by; //draw a square with variable size and color for every element of each array for (int i = 0; i < xpos.length; i++) { rectMode (CENTER); stroke(200); if( i % 5 == 0 && i != 0 ) fill( i*5, 0, i*5 ); else fill(255,i*5); //if( i % 10 == 0 && i != 0 ) //ellipse(xpos[i],ypos[i],(MAX-i)*4,(MAX-i)*2); if( i % 3 == 0 && i != 0 ) rect( xpos[i], ypos[i], (MAX-i)*2, (MAX-i)*2); else ellipse(xpos[i],ypos[i],(MAX-i)*2,(MAX-i)*2); /* if( i == 49 ) { fill(0,0); for( int j = 0; j < xpos.length; j++ ) ellipse(xpos[j],ypos[j],(MAX-j)*2,(MAX-j)*2); } */ } }