Skip to content

Instantly share code, notes, and snippets.

@tado
Last active August 29, 2015 14:21
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 tado/e86aca96764babe3fb96 to your computer and use it in GitHub Desktop.
Save tado/e86aca96764babe3fb96 to your computer and use it in GitHub Desktop.
Drawing photo for processing
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();
}
}
@MorimasaAketa
Copy link

simple and beautiful code!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment