xxxxxxxxxx
91
let circles = [];
function setup() {
createCanvas(600, 700);
for (let i = 0; i < 25; i++) {
background(255, 238, 5);
let circle = {
x: random(width),
y: random(height),
r: random(15, 36),
};
let overlapping = false;
for (var j = 0; j < circles.length; j++) {
let other = circles[j];
let d = dist(circle.x, circle.y, other.x, other.y);
if (d < circle.r + other.r) {
overlapping = true;
}
if (!overlapping) {
circles.push(circle);
}
}
for (let i = 0; i < circles.length; i++) {
fill(255);
noStroke();
ellipse(circles[i].x, circles[i].y, circles[i].r * 2, circles[i].r * 2);
}
}
function createEyes() {
let newWidth = width;
let newHeigh = height;
minX = (width - newWidth) / 2;
minY = (height - newHeight) / 2;
maxX = minX + newWidth;
maxY = minY + newHeight;
}
class Eye {
constructor(x, y, size, color, pupilSize) {
this.x = x;
this.y = y;
this.size = size;
this.color = color;
this.pupilSize = pupilSize;
this.redEye = 0;
this.setColor = random(colors);
this.isBlinking = false;
this.blinkTimer = random(params.maxBlinkWait + eyes.length * 30);
this.curBlink = 0;
this.newX = map(x, 0, width, minX, maxX);
this.newY = map(y, 0, height, minY, maxY);
this.eyelidTop = random();
if (this.eyelidTop > 0.5) {
this.eyelidTop = max(
(this.size / 4) * 0.25,
((this.size / 4) * random(3)) / 2.5
);
} else {
this.eyelidTop = this.size / 4;
}
this.eyelidBottom = random();
if (this.eyelidBottom > 0.5) {
this.eyelidBottom = max(
(this.size / 4) * 0.25,
((this.size / 4) * random(3)) / 2.5
);
} else {
this.eyelidBottom = this.size / 4;
}
}
draw() {
noStroke();
eyeMask.clear();
eyeMask.noStroke();
eyeMask.push();
eyeMask.translate(this.x, this.y);
this.redEye -= 2;
this.redEye = max(0, this.redEye);
}
}