xxxxxxxxxx
let loc = [];
let vel = [];
const NUM = 500;
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
blendMode(BLEND);
background(0);
noStroke();
fill(31, 127, 255, 200);
if (loc.length > NUM) {
loc.shift();
vel.shift();
}
blendMode(ADD);
for (let i = 0; i < loc.length; i++) {
circle(loc[i].x, loc[i].y, width / 200);
loc[i].add(vel[i]);
}
}
function mouseDragged() {
for (let i = 0; i < 10; i++) {
loc.push(createVector(mouseX, mouseY));
vel.push(createVector(random(-width/1000, width/1000), random(-width/1000, width/1000)));
}
}