Skip to content

Instantly share code, notes, and snippets.

@fukuchi
Created January 26, 2015 08:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fukuchi/b1f80fca3b61949a8661 to your computer and use it in GitHub Desktop.
Save fukuchi/b1f80fca3b61949a8661 to your computer and use it in GitHub Desktop.
pseudo translation
import processing.video.*;
Capture cam;
int[] noise;
int ticks = 0;
void setup() {
size(640, 480);
cam = new Capture(this, width, height, 30);
cam.start();
noise = new int[width * height];
for (int i=0; i<width * height; i++) {
noise[i] = (int)random(256);
}
}
void draw() {
if (cam.available() == true) {
cam.read();
cam.loadPixels();
int index = 0;
for (int y=0; y<height; y++) {
for (int x=0; x<width; x++) {
int v = (cam.pixels[index] >> 8) & 0xff;
color c;
if(v > 128) {
c = (random(2)>1)?0xffffff:0;
} else {
c = (noise((float)index * 1 + ticks) > 0.5)?0xffffff:0;
}
set(x, y, c);
index++;
}
}
}
ticks = (ticks + 1) & 0xff;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment