Skip to content

Instantly share code, notes, and snippets.

@jacobjoaquin
Created March 18, 2014 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacobjoaquin/9611653 to your computer and use it in GitHub Desktop.
Save jacobjoaquin/9611653 to your computer and use it in GitHub Desktop.
Photo to experimental animation.
PImage img;
int[] b;
int p = 0;
void setup() {
size(500, 333);
img = loadImage("me2.jpg");
int l = width * height;
b = new int[l];
image(img, 0, 0);
loadPixels();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
b[y * width + x] = (int) brightness(pixels[y * width + x]);
}
}
}
void draw() {
colorMode(HSB);
background(0);
loadPixels();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int v = ((b[y * width + x] + (int) (256 - p)) * 4) % 256;
if (v > 128) {
v = 256 - v;
}
v = 128 - v;
color c = color(v, 0, v);
pixels[y * width + x] = c;
if (random(1.0) < 0.25) {
c = color(0, 0, random(32) + 32);
pixels[y * width + x] = c;
}
}
}
updatePixels();
p = (p + 2) % 256;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment