xxxxxxxxxx
37
let circles = [];
let total = 9;
function setup() {
createCanvas(400, 400);
let col1 = [100, 100, 255, 255];
let col2 = [255, 100, 255, 255];
let w = width / total;
let h = height / total;
for (let i = 0; i < total; i++) {
let x = i * w;
for (let j = 0; j < total; j++) {
let y = j * h;
let circle = new Circle(x, y, w, h, col1, col2);
circles.push(circle);
}
}
let iMiddle = total * floor(total / 2) + floor(total / 2);
circles[iMiddle].w = 60;
circles[iMiddle].h = 60;
for (let i = 1; i <= floor(total / 2); i++) {
circles[iMiddle + i].w = 20;
}
}
function draw() {
background(220);
translate(width / total / 2, height / total / 2);
for (let c of circles) {
c.show();
}
}