Particle System
First appeared 1983 · William Reeves — William Reeves, "Particle Systems" (SIGGRAPH 1983). · timeline ↗
inventor-coined Name · coined by William Reeves (1983) — Descriptive name coined by its author: Reeves titled the 1983 SIGGRAPH paper "Particle Systems".
In one line A general framework that simulates many small particles, each with properties like position, velocity and lifespan, updated together each frame. It is the umbrella under which flow fields, boids, and physics sketches sit.
The code
The actual sketch behind the demo above — sandboxed and reproducible. This is the whole thing.
particle-system/index.html
const SEED = Math.floor(Math.random()*1e9);
let particles = [];
let attractors = [];
function setup() {
randomSeed(SEED);
const s = Math.min(windowWidth, windowHeight);
createCanvas(s, s);
background('#0a0a0a');
// Particles with velocity/lifetime, pulled toward a few attractor points.
const N_ATTR = 3 + Math.floor(random(3));
for (let i = 0; i < N_ATTR; i++) {
attractors.push({ x: random(width * 0.2, width * 0.8), y: random(height * 0.2, height * 0.8) });
}
for (let i = 0; i < 1200; i++) {
particles.push({
x: random(width), y: random(height),
vx: 0, vy: 0,
life: random(150, 350),
hue: random(360),
});
}
colorMode(HSB, 360, 100, 100, 100);
noStroke();
}
function draw() {
// Faint trails by drawing a translucent black rectangle each frame.
fill(0, 0, 0, 8);
rect(0, 0, width, height);
for (const p of particles) {
for (const a of attractors) {
const dx = a.x - p.x;
const dy = a.y - p.y;
const d2 = dx * dx + dy * dy + 50;
const f = 24 / d2;
p.vx += dx * f;
p.vy += dy * f;
}
p.vx *= 0.98; p.vy *= 0.98;
p.x += p.vx; p.y += p.vy;
p.life--;
if (p.life <= 0 || p.x < 0 || p.y < 0 || p.x >= width || p.y >= height) {
p.x = random(width); p.y = random(height);
p.vx = 0; p.vy = 0;
p.life = random(150, 350);
}
fill(p.hue, 80, 95, 75);
circle(p.x, p.y, 1.6);
}
// Hide attractors for cleaner look (uncomment to see):
// fill(0,0,100); for (const a of attractors) circle(a.x, a.y, 6);
}How it works
Maintain an array of particles, each holding state (position, velocity, age, colour, size…). Each frame: 1. Emit: spawn new particles from one or more sources, with initial values (often randomised within ranges). 2. Update: for every particle, accumulate forces (gravity, drag, a flow field, attraction/repulsion), integrate velocity then position, and age it. 3. Cull: remove particles past their lifespan or out of bounds. 4. Render: draw each particle (point, sprite, or a trail of past positions). The visual character comes entirely from the forces and emission rules; swapping the force function turns the same engine into smoke, sparks, flocking or flow-field art.
Parameters
count: number — Number of particles simulated.lifetime: number — How long each particle lives before it dies or respawns.emissionRate: number — Particles spawned per unit time.gravity: number — Constant directional acceleration applied each step.velocity: number — Initial speed imparted at emission.
Lineage
Frequently combined with
- Flow Field / Vector Field · 14 works
- Perlin / Simplex Noise · 13 works
- Bezier / Catmull-Rom Splines · 11 works
- HSL / Hue Cycle · 7 works
- 3D Mesh / Geometry · 5 works
- Fragment Shader (GLSL) · 5 works
- Fractal / Recursive Subdivision · 4 works
- Boids / Flocking · 4 works
- Audio-Reactive · 4 works
- Glitch / Datamosh · 3 works
- Marching Squares / Contours · 3 works
- Strange Attractor · 2 works
Works using this algorithm (63)
References
Last updated 2026-07-16