Canvas Particle
const canvas = document.createElement('canvas'),
c = canvas.getContext('2d');
canvas.width = 500;
canvas.height = 500;
document.body.appendChild(canvas);
c.fillStyle = 'black';
c.fillRect(0, 0, canvas.width, canvas.height);
let a = 0.29, b = 0.22;
function f(x, y) {
if (Math.random() < 0.001) b = Math.random();
return Math.cos((x + Math.sin(x) * 0.01 + Math.cos(x * a)) * b);
}
let x = 1, y = 0;
setInterval(() => {
if (Math.random() < 0.03) {
x = 1;
y = 0;
}
if (Math.random() < 0.001) a = Math.random();
for (let i = 0; i < 1e3; i++) {
x = x + f(y);
y = y + f(x);
c.save();
c.translate(150, 250);
c.scale(0.5, 0.5);
c.fillStyle = 'rgba(255, 255, 255, 0.01)';
c.fillRect(x, y, 5, 5);
c.restore();
}
}, 20);
A single particle moves around and leaves a trail