DISCLAIMER:
This have not much to do with our today’s assignment

Also, to be perfectly clear, I found this sketch in my sketches folder, from long, long ago, so I don’t remember how exactly it came to be.
Because this sketch will generate a PDF file in your computer, it cannot be run from in Javascript mode. To try it out, please copy the following code and run it from your computer. Remember you need to have a JPG on hand.
import processing.pdf.*;
float maxBallDiam =8; // max size for each dot
float spacer = maxBallDiam *0.8; // spacing between circles
float margin = 16; // margin
float ang = 0;
PImage myImage; //objeto imagen
void setup() {
// Drag a JPG or PNG to this sketch, and adjust the filename in the following two lines accordingly
myImage = loadImage("asli-sergio.png");
size(myImage.width, myImage.height, PDF, "asli-sergio.pdf"); // this is what your PDF file will be named
noStroke();
fill(0);
//smooth();
}
void draw() {
/*
I think it's OK to have these variables within the draw loop,
because we are only running the loop once. WHAT?
Yes! We are. You'll see later.
*/
float initX;
int rowCount = 0;
int par;
for (float y = margin; y < height-margin; y+= spacer * 0.854 ) {
rowCount ++;
par = rowCount % 2;
// % is Modulo. It is used to calculate the remainder of a division. That way you can tell
// when things are odd/even
if ( par == 0) {
initX = margin + spacer/2;
}
else {
initX = margin;
}
// Now we do a for loop to go through the images pixels, each x and y represents that
for (float x = initX; x < width - margin; x += spacer) {
// We get the color from the image
color gray = myImage.get(round(x), round(y));
// But we are NOT using color, but insted will map the color brightness into size
float ballDiam = map(brightness(gray), 0, 255, maxBallDiam, 0);
ellipse (x, y, ballDiam, ballDiam);
}
}
println("Done! --- USER: press APPLE + K to view the PDF file in your sketch folder");
exit();
}