let colors = [];
let array1;
let alpha1 = 100;
let minRadius = 1;
let cnt = 0;
let font1;
function setup() {
colors = [
color(114, 112, 123, alpha1),
color(209, 205, 227, alpha1),
color(192, 222, 246, alpha1),
color(133, 216, 241, alpha1),
color(90, 211, 235, alpha1),
color(164, 217, 233, alpha1)
];
createCanvas(500, 500);
background(255);
array1 = [];
for (i = 0; i < 1000; i++) {
array1[i] = {
x: random(-width / 2, width / 2),
y: random(-width / 2, width / 2),
r: random(2, 20),
c: random(colors),
c2: random(colors),
s: random(0.025, 0.05),
max: random(25, 40),
rad: random(2, 20),
dir: random([-1, 1])
};
}
}
function draw() {
translate(width / 2, height / 2);
t = frameCount / 100;
background(150 + 100 * sin(t), 180 + 100 * sin(t), 210 + 100 * sin(t), 100);
for (i = 0; i < array1.length; i++) {
push();
rotate(t * array1[i].s * array1[i].dir);
fill(array1[i].c);
stroke(array1[i].c2);
strokeWeight(Math.floor(array1[i].r / 2));
let x = array1[i].x + array1[i].dir * array1[i].rad * sin(t * array1[i].s);
let y = array1[i].y + array1[i].dir * array1[i].rad * cos(t * array1[i].s);
circle(x, y, array1[i].r);
stroke(255, 255, 255, 50);
noFill();
arc(x, y, array1[i].r, array1[i].r, 0, PI / 2);
if (array1[i].r < array1[i].max) {
array1[i].r += array1[i].s;
} else {
array1[i].r = minRadius;
}
pop();
if (x > -width / 2 && x < width / 2 && y > -height / 2 && y < height / 2) {
cnt++;
if (cnt >= 1000000) {
console.log("1,000,000 drawn!");
text("1,000,000 drawn!", -50, 0);
noLoop();
}
}
}
}
function mousePressed() {
array1[array1.length] = {
x: mouseX - width / 2,
y: mouseY - height / 2,
r: random(2, 20),
c: random(colors),
c2: random(colors),
s: random(0.025, 0.05),
max: random(25, 40),
rad: random(2, 20),
dir: random([-1, 1])
};
}
function keyPressed() {
if (keyCode === 82) {
setup();
draw();
}
}