xxxxxxxxxx
32
let circles = [];
let count = 12;
let angles = [];
let colors = [];
let btn;
function setup() {
createCanvas(400, 400);
btn = createButton("save as GIF");
btn.mousePressed(saveAsGIF);
colors = [color(0, 255, 255), color(0, 255, 0), color(0, 0, 255)];
for (let i=0; i<count; i++){
angles[i] = (TWO_PI/count) * i;
circles[i] = new Circle(angles[i], colors[i%3]);
}
}
function draw() {
background(0);
translate(width/2, height/2);
push();
blendMode(DIFFERENCE);
for (let i=0; i<count; i++){
circles[i].update();
circles[i].display();
}
pop();
}
function saveAsGIF() {
saveGif('bgcircles.gif', 6);
}