mirror of
https://github.com/processing/processing4.git
synced 2026-02-02 21:29:17 +01:00
34 lines
766 B
Plaintext
34 lines
766 B
Plaintext
/**
|
|
* Pointillism
|
|
* by Daniel Shiffman.
|
|
*
|
|
* Mouse horizontal location controls size of dots.
|
|
* Creates a simple pointillist effect using ellipses colored
|
|
* according to pixels in an image.
|
|
*/
|
|
|
|
// The next line is needed if running in JavaScript Mode with Processing.js
|
|
/* @pjs preload="moonwalk.jpg"; */
|
|
|
|
PImage img;
|
|
int smallPoint, largePoint;
|
|
|
|
void setup() {
|
|
size(640, 360);
|
|
img = loadImage("moonwalk.jpg");
|
|
smallPoint = 4;
|
|
largePoint = 40;
|
|
imageMode(CENTER);
|
|
noStroke();
|
|
background(255);
|
|
}
|
|
|
|
void draw() {
|
|
float pointillize = map(mouseX, 0, width, smallPoint, largePoint);
|
|
int x = int(random(img.width));
|
|
int y = int(random(img.height));
|
|
color pix = img.get(x, y);
|
|
fill(pix, 128);
|
|
ellipse(x, y, pointillize, pointillize);
|
|
}
|