xxxxxxxxxx
48
const ballCount = 1000;
let x = [];
let y = [];
let xDir = 1;
let yDir = 1;
let size = [];
let h = [];
let s = [];
let b = [];
let hueDir = 1;
let sizeDir = 1;
function setup() {
createCanvas(windowWidth, windowHeight);
for(let i = 0; i < ballCount; i++){
x[i] = width/2;
y[i] = height/2;
size[i] = random(50);
h[i] = random(170, 200);
s[i] = random(80, 100);
b[i] = 60;
}
}
function draw() {
background(0, 50);
noStroke();
colorMode(HSB);
for(let i = 0; i < ballCount; i++){
if(x[i] < 0 || x[i] > width) xDir = -xDir;
x[i] = x[i] + random(-3, 3)*xDir;
if(y[i] < 0 || y[i] > height) yDir = -yDir;
y[i] = y[i] + random(-3, 3)*yDir;
if(size[i] >= width/1.5 || size[i] < width/6) sizeDir = -sizeDir;
size[i] = size[i] + random(-4, 3)*sizeDir;
if(h[i] >= 360 || h[i] <= 1) hueDir = -hueDir;
h[i] = h[i] + random(1)*hueDir;
fill(h[i], s[i], b[i]);
ellipse(x[i], y[i], size[i], size[i]);
}
}