let c, clouds, nClouds;
function setup() {
clouds = [];
nClouds = int(random(5, 20));
c = min(min(windowWidth, windowHeight) * 0.9, 800);
cnv = createCanvas(c, c);
angleMode(DEGREES);
r1 = random(250, 300);
g1 = random(250, 300);
b1 = random(250, 300);
noStroke();
for (let i = 0; i < nClouds; i++) {
clouds.push(new Cloud());
}
}
function draw() {
translate(width / 2, height / 2);
for (let i = c * 2; i > 0; i--) {
fill(r1 - i / 3, g1 - i / 3, b1 - i / 3);
circle(0, 0, i);
}
for (let i = 0; i < clouds.length; i++) {
push();
translate(clouds[i].x, clouds[i].y);
clouds[i].display();
clouds[i].move();
pop();
}
}
class Cloud {
constructor() {
this.x = random(-c, c);
this.y = random(-c / 2, c / 2);
this.pos = [];
this.cSize = [];
for (let i = 0; i < 500; i++) {
let x = random(-c / 3, c / 3);
let y = randomGaussian(5, 10);
this.pos[i] = createVector(x, y);
this.cSize[i] = random(0, (c / 3 - abs(x)) / 2);
}
this.delta = random(0.01, 1);
}
display() {
for (let i = 0; i < this.pos.length; i++) {
fill(r1 / 3, g1 / 3, b1 / 3, 3 + 2 * abs(sin(this.y)));
circle(this.pos[i].x, this.pos[i].y, this.cSize[i]);
}
}
move() {
if (this.x > -c * 2) {
this.x -= this.delta;
} else {
this.x = c * 2;
}
}
}
function mousePressed() {
setup();
draw();
}