color col[];
void setup() {
size(1200, 1600);
col = new color[] {
color(239, 128, 111),
color(191, 48, 16),
color(191, 175, 175),
color(255, 207, 48),
color(64, 176, 191)
};
go();
}
void draw() {}
void mousePressed() {
go();
}
void go() {
background(col[2]);
int w = 4, h = 6, margin = 50, padding = 30;
int imgwid = (width - margin * 2 - (padding * (w - 1))) / w;
int imghei = (height - margin * 2 - (padding * (h - 1))) / h;
for (int j = 0; j < h; j++)
for (int i = 0; i < w; i++)
image(square(imgwid, imghei), margin + i * (imgwid + padding), margin + j * (imghei + padding));
noFill();
}
PImage square(int w, int h) {
PGraphics aux = createGraphics(w, h);
aux.beginDraw();
aux.background(242);
aux.smooth();
aux.noStroke();
for (int i = 0; i < 22; i++) {
float diam = random(0.5, 2);
aux.fill(col[int(random(col.length))]);
aux.ellipse(random(w), random(h), diam, diam);
}
for (int num = (int) random(1, 3), i = 0; i < num; i++)
eye(aux, random(0, w), random(0, h), random(10, 30));
aux.noFill();
for (int i = 0; i < 8; i++) {
float ang = random(TWO_PI), dist = random(30, w/2), diam = random(30, w/4*3);
aux.strokeWeight(random(3, w/30));
aux.stroke(col[(int)(random(col.length))]);
aux.ellipse(w / 2 + cos(ang) * dist, h / 2 + sin(ang) * dist, diam, diam);
}
for (int num = (int) random(1, 4), i = 0; i < num; i++)
eye(aux, random(0, w), random(0, h), random(10, 100));
aux.endDraw();
return aux;
}
void eye(PGraphics p, float x, float y, float s) {
p.fill(255);
circle(p, x, y, s, int(random(3, 6)));
float a = -PI / 4;
float d = s * 0.22;
p.fill(0);
circle(p, x + cos(a) * d, y + sin(a) * d, s * random(0.32, 0.43), int(random(3, 5)));
p.fill(255);
circle(p, x + cos(a) * (d * 1.22), y + sin(a) * (d * 1.22), s * random(0.12, 0.2), int(random(3, 5)));
}
void circle(PGraphics p, float x, float y, float d, int sec) {
float r = d * 0.5, da = TWO_PI / sec;
float kappa = 0.5522847498, k = 4 * kappa / sec;
PVector points[] = new PVector[sec];
for (int i = 0; i < sec; i++)
points[i] = new PVector(x + cos(da * i) * r + r * random(-0.1, 0.1), y + sin(da * i) * r + r * random(-0.1, 0.1));
p.stroke(0);
p.beginShape();
p.vertex(points[0].x, points[0].y);
for (int i = 0; i < sec; i++) {
p.bezierVertex(
points[i].x + cos(da * i + PI / 2) * r * k, points[i].y + sin(da * i + PI / 2) * r * k,
points[(i + 1) % sec].x + cos(da * (i + 1) - PI / 2) * r * k, points[(i + 1) % sec].y + sin(da * (i + 1) - PI / 2) * r * k,
points[(i + 1) % sec].x, points[(i + 1) % sec].y
);
}
p.endShape(CLOSE);
}