xxxxxxxxxx
28
let trail = [];
let numParticles = 100;
function setup() {
createCanvas(windowWidth, windowHeight);
noStroke();
fill(255, 150); // Semi-transparent white
}
function draw() {
background(0); // Black background
// Add a point to the trail at the current mouse position
trail.push(createVector(mouseX, mouseY));
// If the trail gets too long, remove the oldest point
if (trail.length > numParticles) {
trail.shift();
}
// Draw and update the particles
for (let i = 0; i < trail.length; i++) {
let sparkleSize = random(5, 20); // Vary the size of the sparkle
fill(255, 150); // Random sparkling color
ellipse(trail[i].x, trail[i].y, sparkleSize, sparkleSize);
}
}