/** * 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;
PFont f;
void setup() {
size(600, 800);
img = loadImage("D:\\myphoto\\The-Iphone-Portrait.jpg");
smallPoint = 4;
largePoint = 40;
imageMode(CENTER);
noStroke();
background(255);
// Create the font
printArray(PFont.list());
f = createFont("Georgia", 9);
textFont(f);
textAlign(CENTER, CENTER);
}
void draw() {
float value;
color pix;
// if (mousePressed == true) {
background(80);
int counter = 0;
char letter;
float pointillize = map(mouseX, 0, width, smallPoint, largePoint);
for (int x = 0; x < img.width; x+=10) {
for (int y = 0; y < img.height; y+=10){
pix = img.get(x, y);
value = brightness(pix);
if (value > 80)
fill(0, 255, 0);
else fill(0);
//ellipse(x, y, 5, 5);
counter = int(random(66, 123));
letter = char (counter);
text(letter, x, y);
}
}
// }
}
/**
回覆刪除* 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(600, 800);
img = loadImage("D:\\myphoto\\The-Iphone-Portrait.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));
int xWidth = int(random(10, 200));
int yHeight = int(random(10, 200));
int xShift = int(random(-20, +20));
int yShift = int(random(-20, +20));
for (int i = 0; i< xWidth; i++) {
for (int j = 0; j< yHeight; j++) {
color pix = img.get(x+i, y+j);
stroke(pix);
// ellipse(x, y, pointillize, pointillize);
point(xShift+x+i, yShift+y+j);
}
}
}