| 1 |
/** |
| 2 |
* Pointillism |
| 3 |
* by Daniel Shiffman. |
| 4 |
* |
| 5 |
* Mouse horizontal location controls size of dots. |
| 6 |
* Creates a simple pointillist effect using ellipses colored |
| 7 |
* according to pixels in an image. |
| 8 |
*/ |
| 9 |
|
| 10 |
PImage img; |
| 11 |
int smallPoint, largePoint; |
| 12 |
|
| 13 |
void setup() { |
| 14 |
size(640, 360); |
| 15 |
img = loadImage("moonwalk.jpg"); |
| 16 |
smallPoint = 4; |
| 17 |
largePoint = 40; |
| 18 |
imageMode(CENTER); |
| 19 |
noStroke(); |
| 20 |
background(255); |
| 21 |
} |
| 22 |
|
| 23 |
void draw() { |
| 24 |
float pointillize = map(mouseX, 0, width, smallPoint, largePoint); |
| 25 |
int x = int(random(img.width)); |
| 26 |
int y = int(random(img.height)); |
| 27 |
color pix = img.get(x, y); |
| 28 |
fill(pix, 128); |
| 29 |
ellipse(x, y, pointillize, pointillize); |
| 30 |
} |
| 31 |
|
| 32 |
// https://processing.org/examples/pointillism.html |