xxxxxxxxxx
31
let angle1, angle2;
let diamonds = [];
function setup() {
createCanvas(600, 600);
angleMode(DEGREES);
for (i = 0; i < 10; i++) {
let d = new Diamond(random(3 / 2 * width), random(3 / 2 * height), random(width / 2), random(150, 255), random(50, 100), random(150, 255), random(1, 2))
diamonds.push(d);
}
}
function draw() {
background(20, 30);
for (let d in diamonds) {
diamonds[d].show();
diamonds[d].move();
let overlapping = false;
for (let other in diamonds) {
if (diamonds[d] !== diamonds[other] && diamonds[d].intersect(diamonds[other])) {
overlapping = true;
}
}
if (overlapping) {
diamonds[d].fillColor();
} else {
diamonds[d].show();
}
}
}