xxxxxxxxxx
42
let cols; let rows;
let size = 50; let offset = 5;
let shapes = [];
function setup() {
createCanvas(400, 400);
angleMode(DEGREES);
cols = width/size;
rows = height/size;
for (let i=0; i<cols; i++) {
shapes[i] = [];
for (let j=0; j<rows; j++) {
let a;
if (j%2 == 0) {
if (i%2 == 0) {
a = 90;
} else {
a = 180;
}
} else {
if (i%2 == 0) {
a = 0;
} else {
a = 270;
}
}
shapes[i][j] = new Shape(size/2 + i*size, size/2 + j*size, 0, 100, 0, 360, a, a + 270);
}
}
}
function draw() {
background(255);
for (let i=0; i<cols; i++) {
for (let j=0; j<rows; j++) {
shapes[i][j].display();
shapes[i][j].move();
}
}
}