//based on Explode for images by Daniel Shiffman import processing.video.*; int cellsize = 15; int cols, rows; Capture video; PFont word; float eyeX = 500.0; float eyeY = 350.0; float eyeZ = 1800.0; float centX = 500.0; float centY = 350.0; float centZ = 10.0; float upX = 0.0; float upY = 1.0; float upZ = 0.0; float sval = 0.0; int bounce = 0; void setup(){ size(1024, 768, P3D); framerate(10); word = loadFont("Courier-24.vlw"); textFont(word, 24); //set up columns and rows cols = width/cellsize; rows = height/cellsize; colorMode(RGB,255,255,255,100); // use default capture device video = new Capture(this, 1024, 768, 12); camera(eyeX, eyeY, eyeZ, centX, centY, centZ, upX, upY, upZ); } void captureEvent(Capture cam){ cam.read(); } void draw(){ // clear background background(255); if(bounce == 1){ sval -= 0.01; } else { sval += 0.01; } if(sval > 2.5) { sval = 2.5; bounce = 1; } if(sval < 1.0) { sval = 1.0; bounce = 0; } /* scale(sval); //rotateX(PI/9-sval+1.0); rotateY(PI*sval); rotateZ(PI*sval/9-0.125); translate(0, 0, -200); rotateY(PI/9); //rotateX(PI/6); */ // columns for ( int i = 0; i < cols;i++) { // rows for ( int j = 0; j < rows;j++) { int x = i*cellsize + cellsize/2; int y = j*cellsize + cellsize/2; int loc = (video.width - x - 1) + y*video.width; // mirror float r = video.pixels[loc] >> 16 & 0xFF;; float g = video.pixels[loc] >> 8 & 0xFF; float b = video.pixels[loc] & 0xFF; if (r > 0 && r < 50) { r = 25; } if (r > 50 && r < 100) { r = 75; } if (r > 100 && r < 150) { r = 125; } if (r > 150 && r < 200) { r = 175; } if (r > 200 && r < 255) { r = 215; } if (g > 0 && g < 50) { g = 25; } if (g > 50 && g < 100) { g = 75; } if (g > 100 && g < 150) { g = 125; } if (g > 150 && g < 200) { g = 175; } if (g > 200 && g < 255) { g = 225; } if (b > 0 && b < 50) { b = 25; } if (b > 50 && b < 100) { b = 75; } if (b > 100 && b < 150) { b = 125; } if (b > 150 && b < 200) { b = 175; } if (b > 200 && b < 255) { b = 225; } // make new color // color c = color(r*3,g*1.5,b*.125,75); color c = color(r*2,g*1.5,b*.25,75); // z position as function of mouse position on x axis and pixel brightness // float z = 3 * (mouseX / (float) width) * brightness(c) - 100.0f; float z = 4 * (mouseX / (float) width) * brightness(c) - 100.0f; //System.out.println(brightness(c)); // Translate to the location, set fill and stroke, and draw the rect pushMatrix(); translate(x,y,z); // rotate(tan(PI*60/360.0)); fill(c); noStroke(); rectMode(CENTER); //rect(0,0,cellsize,cellsize); // box(cellsize,cellsize,(255/brightness(c))*cellsize); // box(cellsize,cellsize,(brightness(c))); ellipse(i,j, (brightness(c)/6), (brightness(c))/6); //camera(500.0, 768.0, 1200.0, 500.0, 500.0, 10.0, 0.0, 1.0, 0.0); //camera(eyeX-(tan(PI*60/360.0)), eyeY, eyeZ-(tan(PI*60/360.0)), centX, centY, centZ, upX, upY, upZ); popMatrix(); } } }