Created
January 26, 2015 08:41
-
-
Save fukuchi/b1f80fca3b61949a8661 to your computer and use it in GitHub Desktop.
pseudo translation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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