xxxxxxxxxx
let vecLocation = [];
let vecVelocity = [];
let R = [];
let G = [];
let B = [];
let sizeX = [];
let sizeY = [];
const NUM = 500;
function setup() {
createCanvas(windowWidth, windowHeight);
for (let i=0; i < NUM; i++) {
vecLocation[i] = createVector(width/2, height/2);
vecVelocity[i] = createVector(random(-10, 10), random(-10, 10));
R[i] = random(255);
G[i] = random(255);
B[i] = random(255);
sizeX[i] = random(15,60);
sizeY[i] = random(25,50);
}
}
function draw() {
background(0);
noStroke();
for (let i=0; i < NUM; i++) {
fill(R[i], G[i], B[i], 127);
ellipse(vecLocation[i].x, vecLocation[i].y, sizeX[i], sizeY[i]);
vecLocation[i].add(vecVelocity[i]);
if (vecLocation[i].x > width || vecLocation[i].x < 0) {
vecVelocity[i].x *= -1;
}
if (vecLocation[i].y > height || vecLocation[i].y < 0) {
vecVelocity[i].y *= -1;
}
}
}