Created
April 4, 2018 17:48
-
-
Save antoinefortin/96e55bd79ce51a842a00ce2c3842bf29 to your computer and use it in GitHub Desktop.
[ImageDrawin-Processing]
This file contains hidden or 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 pointillize = 4; | |
int noise = 1; | |
int gravity = 0; | |
int pressedCounter = 0; | |
void setup() { | |
size(600,600); | |
img = loadImage("loud.jpeg"); | |
background(0); | |
smooth(); | |
} | |
void draw() { | |
for(int i = 0; i < 500; i++) { | |
// Pick a random point | |
int x = int(random(img.width)); | |
int y = int(random(img.height)); | |
int loc = x + y*img.width; | |
// Look up the RGB color in the source image | |
loadPixels(); | |
float r = red(img.pixels[loc]); | |
float g = green(img.pixels[loc]); | |
float b = blue(img.pixels[loc]); | |
noStroke(); | |
// Draw an ellipse at that location with that color | |
fill(r,g,b,100); | |
if(mousePressed == true ) { | |
if(pressedCounter < 5) { | |
background(0); | |
} | |
pressedCounter++; | |
ellipse(x + gravity, y + gravity,pointillize ,pointillize); | |
if(gravity <= (width - img.width)) { | |
gravity++; | |
} | |
} else { | |
ellipse(x + gravity,y + gravity,pointillize ,pointillize); | |
pressedCounter = 0; | |
if(gravity >= 0) { | |
gravity--; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment