176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.
HTML ai-promptsanimationcss-animationsfrontendgithub-pagesjavascriptmicrointeractionsmotion-designno-dependenciesreferencescroll-animationui-animationweb-animationweb-developmentwebgl
docs: Canvas Particle Effect README computes the Trails fade from the unslowed step
matin8619b6aa1ccc
diff --git a/animations/06-3d-advanced/canvas-particle-effect/README.md b/animations/06-3d-advanced/canvas-particle-effect/README.mdindex 515e3643..c4b5f742 100644--- a/animations/06-3d-advanced/canvas-particle-effect/README.md+++ b/animations/06-3d-advanced/canvas-particle-effect/README.md@@ -35,8 +35,10 @@ class Particle {}}-const k = Math.min(elapsed, 50) / (1000 / 60); // elapsed: ms since the last drawn frame; a long gap counts for at most 50 ms+const steps = Math.min(elapsed, 50) / (1000 / 60); // elapsed: ms since the last drawn frame; a long gap counts for at most 50 ms+const k = steps * (slow ? 1 / 3 : 1); // Slow motion slows the dots ...particles.forEach(p => p.update(k));+draw(1 - Math.pow(1 - 0.15, steps)); // ... but not the Trails fade, which follows the frame's time alone```**Connections** — O(n²) distance check per frame:@@ -80,7 +82,7 @@ Stroking each link on its own costs one draw call per line, thousands a frame; g- **Phones and tablets**: the demo draws 30 to 60 dots on phones (screens 600px wide or less, or 500px tall or less when held sideways) and 60 to 120 on other screens up to 1024px wide, and strokes the links in six batches instead of one call per line.- **Canvas vs DOM**: `<canvas>` is mandatory for 50+ particles. DOM elements at that density create thousands of layout calculations per frame — the browser cannot keep up.- **Particles.js / tsParticles**: the dominant production library. Handles everything in this demo plus themes, shape variety, responsive density, and performance at high counts.-- **`ctx.clearRect` vs `fillRect`**: using `fillRect` with a semi-transparent background instead of `clearRect` creates a motion-trail effect where older frames linger (turn on Trails in the demo). The wash's opacity is 1 - 0.85^k, so the streaks last as long on a 30 Hz phone as on a 60 Hz screen.+- **`ctx.clearRect` vs `fillRect`**: using `fillRect` with a semi-transparent background instead of `clearRect` creates a motion-trail effect where older frames linger (turn on Trails in the demo). The wash's opacity is 1 - 0.85^steps, from the frame's time alone (Slow motion slows the dots, not the fade), so the streaks last as long on a 30 Hz phone as on a 60 Hz screen.- **Time, not frames**: a fixed step per frame follows the screen's refresh rate, so the dots would drift twice as fast at 120 Hz and half as fast at 30 Hz. Cap the time of one frame (this demo uses 50 ms) so a tab that comes back does not lurch, and let a returning tab start from its next frame.- **Device pixel ratio**: size the backing store to `clientWidth * devicePixelRatio` (capped at 2) and scale the context, or sub-pixel dots and 0.5px connection lines blur on retina screens.- **`prefers-reduced-motion`**: stop all particle movement. Consider keeping the static dot layout visible as a texture.