Last active
August 29, 2015 14:21
-
-
Save tado/e86aca96764babe3fb96 to your computer and use it in GitHub Desktop.
Drawing photo for processing
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; | |
void setup() { | |
size(800, 600); | |
img = loadImage("photo.jpg"); | |
image(img, 0, 0, width, height); | |
loadPixels(); | |
background(0); | |
} | |
void draw() { | |
noStroke(); | |
for (int i = 0; i < 100; i++) { | |
int x = int(random(width)); | |
int y = int(random(height)); | |
color c = pixels[y * width + x]; | |
float h = brightness(c) / 12.0; | |
float angle = saturation(c) / 80.0; | |
fill(c, 127); | |
pushMatrix(); | |
translate(x, y); | |
rotate(angle); | |
rect(0, 0, h, 2); | |
popMatrix(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
simple and beautiful code!