// Source: http://www.somerandomdude.net/processing/helix/helix.pde /* Sketch: Helix Author: P.J. Onori URL: http://www.somerandomdude.net Date: 2007.11.13 Details: 3d visualization based on the rotation of grid elements and colored based on color values derived from captured webcam data. Note: WEBCAM NEEDED FOR THIS APP TO RUN. IF YOU DO NOT HAVE A WEBCAM, REMOVE ALL REFERENCES FROM FILE. */ import processing.video.*; import processing.opengl.*; Capture video; float rot1=0; float rot2=0; float r=0; float g=0; float b=0; void setup() { size(640, 480, OPENGL); hint(ENABLE_OPENGL_4X_SMOOTH); video = new Capture(this, width, height, 30); noStroke(); } void draw() { if (video.available()) { background(255); video.read(); video.loadPixels(); int rows=48; int columns=64; rot1 += 0.005; translate(width/2,height/2); for (int y = 0; y < height; y+=height/rows) { for (int x = 0; x < width; x+=width/columns) { rot2 -= 0.000005; int pixelValue = video.pixels[x*y]; /* r = red(pixelValue); g = green(pixelValue); b = blue(pixelValue); */ rotateX(rot1/400); rotateY(rot2/200); fill(pixelValue); ellipse(x-width/2, y-height/2, width/columns, height/rows); } translate(width/20,height/40); rotateX(rot1/200); rotateZ(rot1/400); } rotateY(-rot1/100); } println(frameCount + "/" + frameRate); }