xxxxxxxxxx
29
let minDiameter;
let maxDiameter;
let myDiameters = [];
function setup() {
createCanvas(400, 400);
maxDiameter = width / 10;
minDiameter = maxDiameter / 3;
}
function draw() {
background(220, 20, 100);
let spacing = width / (myDiameters.length + 1);
for (let i = 0; i < myDiameters.length; i++) {
let x = i * spacing + spacing;
ellipse(x, height / 2, myDiameters[i], myDiameters[i]);
}
}
function mouseClicked() {
if (myDiameters.length > 9) {
myDiameters.shift();
}
myDiameters.push(random(minDiameter, maxDiameter));
myDiameters.sort();
}