Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
/********************************************************/ /* Erik Kastner. Processing fun - processing.org/download /********************************************************/ import processing.video.*; Capture video; int vidSize; int numBlocks; int numColumns; void setup() { size(640, 480, P3D); // also try with other video sizes video = new Capture(this, 64, 48); numBlocks = (height * width) / (video.height * video.width); numColumns = width / video.width; vidSize = video.height * video.width - 1; loadPixels(); for (int i = 0; i < width*height; i++) { pixels[i] = #000000; } updatePixels(); background(0); frameRate(10); // try different frame rates for different effects } void draw() { // by using video.available, only the frame rate need be set inside setup() if (video.available()) { video.read(); set(0, 0, video); loadPixels(); for (int j=numBlocks-1; j > 0; j--) { //println("Copying from " + (j-1) + " to: " + j); copyBlock(j-1, j); } updatePixels(); } } void copyBlock(int from, int to) { int toX = to % numColumns; int toY = to / numColumns; int tOffset = (toX * video.width) + (toY * width * video.height); int fromX = from % numColumns; int fromY = from / numColumns; int fOffset = (fromX * video.width) + (fromY * width * video.height); for (int vOffset=0; vOffset<video.height; vOffset++) { arraycopy(pixels, (vOffset * width) + fOffset, pixels, (vOffset * width) + tOffset, video.width - 1); } }
Pasted December 15, 200712:31AM EDT