Created
March 18, 2014 01:03
-
-
Save jacobjoaquin/9611653 to your computer and use it in GitHub Desktop.
Photo to experimental animation.
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
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