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
feat: Lightning (07.26), a new Ambient & Background page
Claude890ad412ea6f
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.ymlindex a0dbc39b..2ca29a4c 100644--- a/.github/ISSUE_TEMPLATE/config.yml+++ b/.github/ISSUE_TEMPLATE/config.yml@@ -5,7 +5,7 @@ contact_links:about: "Saw an animation on a website and don't know its name? Answer three short questions and see the ones that match."- name: Browse the live handbookurl: https://matinmonshizadeh.github.io/animation-handbook/- about: See all 175 techniques running before filing an issue.+ about: See all 176 techniques running before filing an issue.- name: Ask a question or share an ideaurl: https://github.com/matinmonshizadeh/animation-handbook/discussionsabout: Questions, ideas and things you made with the handbook go to Discussions.diff --git a/404.html b/404.htmlindex 90e141ea..05f58aba 100644--- a/404.html+++ b/404.html@@ -133,7 +133,7 @@ button,input{font:inherit;color:inherit}</form><nav class="ways" aria-label="Ways back"><a class="way" href="/animation-handbook/">Go to the home page</a>- <a class="way" href="/animation-handbook/?view=all#results">Browse all 175 animations</a>+ <a class="way" href="/animation-handbook/?view=all#results">Browse all 176 animations</a><a class="way" href="/animation-handbook/?view=find">Find an animation by what you saw</a></nav></main>diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 797c9dc7..00c3fab6 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -33,6 +33,8 @@ The main steps of Animation Handbook, newest first, with the number of animationCompare from the start.- A new animation, Fire Effect (175 in all): flames flicker and rise as heat climbs and cools, with See inside and Comparefrom the start.+- A new animation, Lightning (176 in all): jagged bolts strike from the clouds and light up the sky, with See inside and+ Compare from the start.## 1.0.0 — 2026-10-10diff --git a/README.md b/README.mdindex 9c0c44fb..8168de6b 100644--- a/README.md+++ b/README.md@@ -1,10 +1,10 @@<div align="center">-<a href="https://matinmonshizadeh.github.io/animation-handbook/"><picture><source media="(prefers-reduced-motion: reduce) and (max-width: 600px)" srcset="docs/hero-phone-still.webp"><source media="(prefers-reduced-motion: reduce)" srcset="docs/hero-still.webp"><source media="(max-width: 600px)" srcset="docs/hero-phone.webp"><img src="docs/hero.webp" alt="Six animations from the handbook playing at once: Text Particles, Synthwave Grid, Liquid Glass, Shatter Effect, Holographic Card, and Dynamic Island, six of its 175 web animation techniques" width="820"></picture></a>+<a href="https://matinmonshizadeh.github.io/animation-handbook/"><picture><source media="(prefers-reduced-motion: reduce) and (max-width: 600px)" srcset="docs/hero-phone-still.webp"><source media="(prefers-reduced-motion: reduce)" srcset="docs/hero-still.webp"><source media="(max-width: 600px)" srcset="docs/hero-phone.webp"><img src="docs/hero.webp" alt="Six animations from the handbook playing at once: Text Particles, Synthwave Grid, Liquid Glass, Shatter Effect, Holographic Card, and Dynamic Island, six of its 176 web animation techniques" width="820"></picture></a># Animation Handbook-**A visual reference of 175 web animation techniques: watch each one play live, change most of them with plain settings, and copy a ready-made prompt for your AI assistant. Free to use, with no sign-up.**+**A visual reference of 176 web animation techniques: watch each one play live, change most of them with plain settings, and copy a ready-made prompt for your AI assistant. Free to use, with no sign-up.**[**Open the live handbook →**](https://matinmonshizadeh.github.io/animation-handbook/)@@ -14,7 +14,7 @@ Add it to your AI coding assistant (run in your project folder; needs Node.js):npx skills add matinmonshizadeh/animation-handbook```-[](https://matinmonshizadeh.github.io/animation-handbook/) [](https://github.com/matinmonshizadeh/animation-handbook) [](LICENSE) [](#full-catalog) [](#design-principles) [](#design-principles)+[](https://matinmonshizadeh.github.io/animation-handbook/) [](https://github.com/matinmonshizadeh/animation-handbook) [](LICENSE) [](#full-catalog) [](#design-principles) [](#design-principles)</div>@@ -22,7 +22,7 @@ npx skills add matinmonshizadeh/animation-handbook## What this is-Here are 175 web animation techniques in one place, each shown working. Every page plays its animation live and gives you a ready-made prompt to paste into your AI assistant, so you can add the animation to your own site without writing the code yourself. Most pages also let you change the animation with a few plain settings, and the prompt you copy lists your choices. Each folder's `README.md` explains how the technique works, the values that matter, and the production gotchas, for anyone who wants to build it by hand.+Here are 176 web animation techniques in one place, each shown working. Every page plays its animation live and gives you a ready-made prompt to paste into your AI assistant, so you can add the animation to your own site without writing the code yourself. Most pages also let you change the animation with a few plain settings, and the prompt you copy lists your choices. Each folder's `README.md` explains how the technique works, the values that matter, and the production gotchas, for anyone who wants to build it by hand.Everything is plain HTML, CSS, and JavaScript: no build step, no frameworks, no CDN. Open any page's `index.html` from a copy of this repository and its demo runs offline; [Run it locally](#run-it-locally) covers the parts that need a local server. Built to *inspire* and *teach*, not to sell a library.@@ -65,11 +65,11 @@ Then ask for an animation in plain words, like "make the cards fade in as they s| 04 | [Micro-Interactions](#04) | 44 || 05 | [Text & Typography](#05) | 19 || 06 | [3D & Advanced](#06) | 28 |-| 07 | [Ambient & Background](#07) | 25 |+| 07 | [Ambient & Background](#07) | 26 |## Full catalog-All 175 techniques, each linked to its live demo.+All 176 techniques, each linked to its live demo.Each technique's code and README are in its folder under [animations/](animations/).@@ -291,11 +291,11 @@ Each technique's code and README are in its folder under [animations/](animation<a id="07"></a>-### 07 · Ambient & Background · 25 techniques+### 07 · Ambient & Background · 26 techniques<sub>Passive, looping effects that hold visual interest without demanding attention — gradients, particles, grain, and glows.</sub>-<details><summary>Browse all 25 techniques in Ambient & Background</summary>+<details><summary>Browse all 26 techniques in Ambient & Background</summary>- **[Animated Gradient Background](https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/animated-gradient-background/)** — Colors slowly drift across a soft gradient background. Best for hero sections.- **[Mesh Gradient Animation](https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/mesh-gradient/)** — Blurred blobs of color drift and melt together. Best for landing pages.@@ -322,6 +322,7 @@ Each technique's code and README are in its folder under [animations/](animation- **[Game of Life](https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/game-of-life/)** — Cells live and die by their neighbors, and patterns grow. Best for tech sites.- **[Ken Burns Effect](https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/ken-burns/)** — Photos slowly zoom and pan, then fade into the next. Best for hero slideshows.- **[Fire Effect](https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/fire-effect/)** — Flames flicker and rise as heat climbs and cools. Best for game and event pages.+- **[Lightning](https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/lightning/)** — Jagged bolts strike from the clouds and light up the sky. Best for dramatic intros.</details>diff --git a/animations/07-ambient-background/README.md b/animations/07-ambient-background/README.mdindex 2af694a4..1db5dbac 100644--- a/animations/07-ambient-background/README.md+++ b/animations/07-ambient-background/README.md@@ -31,6 +31,7 @@ Passive, looping effects that hold visual interest without demanding attention.| [Game of Life](game-of-life/) | Cells live and die by their neighbors, and patterns grow. Best for tech sites. || [Ken Burns Effect](ken-burns/) | Photos slowly zoom and pan, then fade into the next. Best for hero slideshows. || [Fire Effect](fire-effect/) | Flames flicker and rise as heat climbs and cools. Best for game and event pages. |+| [Lightning](lightning/) | Jagged bolts strike from the clouds and light up the sky. Best for dramatic intros. |## The ambient mindset@@ -51,7 +52,7 @@ Passive, looping effects that hold visual interest without demanding attention.| Pure CSS keyframes | Animated gradient, mesh gradient, aurora, breathing glow, scanline, wave layers, Ken Burns (the script only sets each photo's start and end framing) || CSS transition + JS timers | Light leak (random timing) || JS moving elements with `transform` | Floating elements, grid parallax (pointer events and a slow drift) |-| Canvas 2D | Grain (or an SVG noise filter), starfield, ambient ripple, abstract geometric, particle constellation, flow field, synthwave grid, matrix rain, plasma, snow and rain, fireworks, topographic lines, light rays, game of life, fire effect |+| Canvas 2D | Grain (or an SVG noise filter), starfield, ambient ripple, abstract geometric, particle constellation, flow field, synthwave grid, matrix rain, plasma, snow and rain, fireworks, topographic lines, light rays, game of life, fire effect, lightning |## See also- [06 — 3D & Advanced](../06-3d-advanced/) — GPU-intensive effects; WebGL shaders and particlesdiff --git a/animations/07-ambient-background/fire-effect/index.html b/animations/07-ambient-background/fire-effect/index.htmlindex 7849f372..2ee54e68 100644--- a/animations/07-ambient-background/fire-effect/index.html+++ b/animations/07-ambient-background/fire-effect/index.html@@ -46,7 +46,7 @@<body class="hb" data-hb-kind="loop"><nav class="hb-bar" aria-label="Animation Handbook"><a class="hb-home" href="../../../"><svg class="hb-mark" viewBox="0 0 32 32" aria-hidden="true"><g class="g"><circle cx="11.16" cy="20.84" r="6.1"/><circle cx="15.12" cy="16.88" r="6.1"/><circle cx="18.51" cy="13.49" r="6.1"/></g><circle class="b" cx="21.2" cy="10.8" r="6.6"/></svg><span>Animation Handbook</span></a>- <span class="hb-pager"><a href="../ken-burns/" rel="prev" aria-label="Previous: Ken Burns Effect"><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg><span><span class="hb-dir">Previous: </span>Ken Burns Effect</span></a></span>+ <span class="hb-pager"><a href="../ken-burns/" rel="prev" aria-label="Previous: Ken Burns Effect"><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg><span><span class="hb-dir">Previous: </span>Ken Burns Effect</span></a><a href="../lightning/" rel="next" aria-label="Next: Lightning"><span><span class="hb-dir">Next: </span>Lightning</span><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg></a></span><a class="hb-star" href="https://github.com/matinmonshizadeh/animation-handbook" target="_blank" rel="noopener" aria-label="Star on GitHub"><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1-4.4-4.3 6.1-.9z"/></svg><span>Star on GitHub</span></a></nav><main class="hb-page">diff --git a/animations/07-ambient-background/lightning/README.md b/animations/07-ambient-background/lightning/README.mdnew file mode 100644index 00000000..4db6840e--- /dev/null+++ b/animations/07-ambient-background/lightning/README.md@@ -0,0 +1,56 @@+# Lightning++[Live demo](https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/lightning/)++## What it is+Lightning draws jagged bolts that strike from the clouds to the ground every few seconds, flicker once and fade, while the sky lights up softly behind them. Each bolt is new: it starts as a straight line that is split again and again, every split pushing its middle aside by a little less, which gives the big bends and the fine jitter of real lightning. A click or tap makes a bolt strike where the visitor points.++## When to use it+- Game sites and trailers that want a dramatic opening+- Storm, weather and night themes+- Event and launch intros with a burst of energy+- Halloween and fantasy pages++## How it works+A bolt is built once per strike, by midpoint displacement. It starts as one segment from a point in the clouds to the spot it strikes. Each round splits every segment in two and pushes the new midpoint sideways, at random, by up to a set distance; that distance halves every round. Seven rounds turn the straight line into 129 points: the first rounds make the large bends, the later ones the fine jitter. Every round is kept, so the demo's See inside can draw them one after another:++```js+function split(x0, y0, x1, y1, rounds, off) {+ let pts = [[x0, y0], [x1, y1]]; const steps = [pts];+ for (let k = 0; k < rounds; k++, off /= 2) {+ const next = [pts[0]];+ for (let i = 1; i < pts.length; i++) {+ const [ax, ay] = pts[i - 1], [bx, by] = pts[i], l = Math.hypot(bx - ax, by - ay) || 1, o = (rand() * 2 - 1) * off;+ next.push([(ax + bx) / 2 - (by - ay) / l * o, (ay + by) / 2 + (bx - ax) / l * o], pts[i]);+ }+ steps.push(pts = next);+ }+ return steps;+}+```++The first push is about a fifth of the bolt's length. Forks start at points along the finished bolt and are split five times on their own, shorter and thinner. Once built, the whole strike is moved sideways, or narrowed, so that it stays inside the box (in Compare, inside its half). Each bolt is drawn twice on the canvas, with no shadow blur: a wide, faint stroke in the bolt's color for the glow, then a thin one on top in that color mixed halfway to white. Its brightness follows the time since the strike: full, dim, full again within a fifth of a second, then a fade to nothing by half a second. The sky's light is a white layer over the scene whose opacity is that brightness times 0.3, so it is never more than 30% white; a still bolt keeps a steady 10% glow. Rain is a set of short lines moved by the time that passed; the clouds are two soft layers slid sideways with transforms.++**Safety.** A strike starts at least 1.5 seconds after the one before, whatever is pressed: a click that comes sooner waits its turn. One strike flashes twice (bright, dim, bright), so the scene never flashes more than twice in any second, well within the limit of three that keeps flashing content safe for people with photosensitive epilepsy.++## Key parameters+| Parameter | Default | Effect |+|-----------|---------|--------|+| How often | Sometimes | The wait between strikes, picked at random: rarely is 5 to 8 seconds, sometimes 2.6 to 4.4 seconds and often 1.6 to 2.4 seconds; never less than 1.5 seconds |+| Branches | Some | How many thinner forks split off the bolt: few is 2, some 4 and many 7 |+| Bolt color | White | The color of the glow and of the core, which is that color mixed halfway to white: white, blue or violet |+| Lights up the sky | on | The sky turns at most 30% white with each strike and follows its flicker (15% under See inside's drawing, a steady 10% behind a still bolt, and a soft fade to 10% under reduced motion); off, only the bolt flashes |+| Rain | on | 160 thin raindrops fall at a slant (70 on phones); off, the sky is clear of rain |++## Production notes+- **Flash safely.** Keep strikes at least a second and a half apart, cap the sky's light (here 30% white) and never flash a large area at full white. Under reduced motion, show a still bolt and fade bolts in and out with no flicker, the sky's glow at most 10%.+- **No shadow blur.** Canvas `shadowBlur` on a long path is slow on phones; a wide, faint stroke under the bright one gives the glow for the cost of one more line.+- **Build once per strike.** The bolt's points are worked out when it strikes, not every frame; each frame only draws the saved lines.+- **Layers that need no redraw.** The clouds and hills are elements of their own, moved with transforms or not at all; only the rain and the bolt are drawn on the canvas each frame.+- **Libraries.** Three.js and PixiJS draw the same polylines as lines or meshes with additive blending; GSAP can drive the flicker and the sky's opacity with a short timeline.++## See also+- [Fireworks](../fireworks/) — bright strokes with a soft glow on a canvas+- [Snow / Rain](../snow-rain/) — rain and snow falling over a scene+- [Flash / Light Leak Transition](../../03-page-transitions/flash-transition/) — a flash kept within safe limits+- [Fire Effect](../fire-effect/) — a canvas effect over a dark box, flames instead of boltsdiff --git a/animations/07-ambient-background/lightning/index.html b/animations/07-ambient-background/lightning/index.htmlnew file mode 100644index 00000000..50d15e47--- /dev/null+++ b/animations/07-ambient-background/lightning/index.html@@ -0,0 +1,431 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <title>Lightning — Animation Handbook</title>+ <meta name="description" content="Jagged bolts strike from the clouds and light up the sky. Best for dramatic intros.">+ <link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/lightning/">+ <link rel="icon" type="image/png" sizes="96x96" href="../../../favicon.png">+ <link rel="icon" type="image/svg+xml" href="../../../favicon.svg">+ <link rel="apple-touch-icon" href="../../../apple-touch-icon.png">+ <meta property="og:type" content="article">+ <meta property="og:site_name" content="Animation Handbook">+ <meta property="og:title" content="Lightning — Animation Handbook">+ <meta property="og:description" content="Jagged bolts strike from the clouds and light up the sky. Best for dramatic intros.">+ <meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/lightning/">+ <meta property="og:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png">+ <meta name="twitter:card" content="summary_large_image">+ <meta name="twitter:title" content="Lightning — Animation Handbook">+ <meta name="twitter:description" content="Jagged bolts strike from the clouds and light up the sky. Best for dramatic intros.">+ <meta name="twitter:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png">+ <script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Lightning", "name": "Lightning", "description": "Jagged bolts strike from the clouds and light up the sky. Best for dramatic intros.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/lightning/", "inLanguage": "en", "articleSection": "Ambient & Background", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, Ambient & Background, Lightning"}</script>+ <style>+ :root{--ui-accent:#ffce5a}+ *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}+ .stage{position:relative;overflow:hidden;background:linear-gradient(#0b1020,#1a2236 55%,#262c40)}+ /* The storm in layers: clouds (moved by the script), the rain on one canvas, the bolts on another, the hills in front, and+ the light of the sky as a white layer whose opacity the script sets (never above 30%) */+ .clouds{position:absolute;left:0;top:-4%;width:200%;height:44%;background-size:50% 100%;background-repeat:repeat-x;pointer-events:none}+ .c1{background-image:radial-gradient(30% 46% at 18% 30%,#3a4258,#0000 70%),radial-gradient(26% 38% at 52% 20%,#323a50,#0000 70%),radial-gradient(34% 44% at 84% 34%,#3a4258,#0000 70%)}+ .c2{top:4%;opacity:.8;background-image:radial-gradient(24% 34% at 30% 46%,#2a3146,#0000 70%),radial-gradient(30% 40% at 72% 40%,#2e354b,#0000 70%)}+ #cvs,.rain{position:absolute;inset:0;width:100%;height:100%;display:block}+ .rain{pointer-events:none}+ #cvs:focus-visible{outline:2px solid var(--ui-accent);outline-offset:-3px}+ .hills{position:absolute;left:0;bottom:0;width:100%;height:30%;display:block;pointer-events:none}+ .flash{position:absolute;inset:0;background:#fff;opacity:0;pointer-events:none}+ /* See inside and Compare: plain words over the picture */+ .lt-lbl{display:none;position:absolute;max-width:46%;padding:3px 8px;border-radius:6px;background:rgba(8,10,18,.9);color:#f4f4f2;+ font:600 13px/1.25 var(--hb-font);pointer-events:none}+ .stage[data-hb-mode="inside"] .in,.stage[data-hb-mode="compare"] .half{display:block}+ .half{top:10px}.half.first{left:10px}.half.second{left:calc(50% + 10px)}+ </style>+ <link rel="stylesheet" href="../../../assets/css/demo-page.css?v=10">+ <script src="../../../assets/js/demo-page.js?v=10" defer></script>+</head>+<body class="hb" data-hb-kind="loop">+<nav class="hb-bar" aria-label="Animation Handbook">+ <a class="hb-home" href="../../../"><svg class="hb-mark" viewBox="0 0 32 32" aria-hidden="true"><g class="g"><circle cx="11.16" cy="20.84" r="6.1"/><circle cx="15.12" cy="16.88" r="6.1"/><circle cx="18.51" cy="13.49" r="6.1"/></g><circle class="b" cx="21.2" cy="10.8" r="6.6"/></svg><span>Animation Handbook</span></a>+ <span class="hb-pager"><a href="../fire-effect/" rel="prev" aria-label="Previous: Fire Effect"><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg><span><span class="hb-dir">Previous: </span>Fire Effect</span></a></span>+ <a class="hb-star" href="https://github.com/matinmonshizadeh/animation-handbook" target="_blank" rel="noopener" aria-label="Star on GitHub"><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1-4.4-4.3 6.1-.9z"/></svg><span>Star on GitHub</span></a>+</nav>+<main class="hb-page">+ <header class="hb-head">+ <p class="hb-cat">07.26 · Ambient & Background</p>+ <h1>Lightning</h1>+ <p class="hb-lede">Jagged bolts strike from the clouds and light up the sky. Best for dramatic intros.</p>+ </header>++ <section class="hb-step hb-watch" aria-labelledby="hb-watch-title">+ <div class="hb-step-head">+ <span class="hb-num" aria-hidden="true">1</span>+ <div><h2 id="hb-watch-title">Watch it</h2><p>It moves by itself. Click or tap the sky to make a bolt strike there.</p></div>+ </div>+ <div class="seg hb-modes" role="group" aria-label="What the box shows" data-hb-modes>+ <button type="button" data-hb-mode="normal" class="on" aria-pressed="true">Normal</button>+ <button type="button" data-hb-mode="inside" aria-pressed="false">See inside</button>+ <button type="button" data-hb-mode="compare" aria-pressed="false">Compare</button>+ </div>+ <div class="stage">+ <i class="clouds c1" aria-hidden="true"></i><i class="clouds c2" aria-hidden="true"></i>+ <canvas class="rain" aria-hidden="true"></canvas>+ <canvas id="cvs" role="img" tabindex="0" aria-label="A storm over dark hills where a bolt strikes every few seconds. Click, or press Enter or Space, to make one strike."></canvas>+ <svg class="hills" viewBox="0 0 1000 300" preserveAspectRatio="none" aria-hidden="true"><path fill="#141a2a" d="M0 120Q140 40 300 110T620 90T1000 110V300H0Z"/><path fill="#0b0f1a" d="M0 190Q200 130 380 180T760 160T1000 170V300H0Z"/></svg>+ <i class="flash" aria-hidden="true"></i>+ <p class="lt-lbl in" id="l-straight" aria-hidden="true" data-hb-caption>Starts straight</p>+ <p class="lt-lbl in" id="l-split" aria-hidden="true" data-hb-caption>Each split pushes the middle aside, less each time</p>+ <p class="lt-lbl in" id="l-fork" aria-hidden="true" data-hb-caption>Forks branch off</p>+ <p class="lt-lbl in" id="l-glow" aria-hidden="true" data-hb-caption>Glow · a wide, faint copy</p>+ <p class="lt-lbl half first" aria-hidden="true" data-hb-caption>Even zigzag</p>+ <p class="lt-lbl half second" aria-hidden="true" data-hb-caption>Random splits</p>+ </div>+ <div class="hb-player">+ <button class="hb-play" type="button" id="btn-pause" data-hb-pause data-state="playing"><svg class="hb-ic hb-i-pause" viewBox="0 0 24 24" aria-hidden="true"><rect x="6" y="4" width="4" height="16" rx="1"/><rect x="14" y="4" width="4" height="16" rx="1"/></svg><svg class="hb-ic hb-i-play" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 3l14 9-14 9z"/></svg><span class="hb-pause-label">Pause</span></button>+ <label class="hb-toggle"><input class="hb-switch" type="checkbox" role="switch" id="slow-tog" data-hb-slowmo autocomplete="off"><span>Slow motion</span></label>+ </div>+ <div class="hb-mode-notes" aria-live="polite">+ <p data-hb-for="inside" hidden>Inside, each bolt is drawn round by round: a straight line, split again and again with each middle pushed aside by less, then forks and a soft glow.</p>+ <p data-hb-for="compare" hidden>On the left, Even zigzag bends in equal steps, so it looks drawn. On the right, Random splits pushes each split aside by less, so it has big bends and fine jitter.</p>+ </div>+ </section>++ <section class="hb-step hb-try" aria-labelledby="hb-try-title">+ <div class="hb-step-head">+ <span class="hb-num" aria-hidden="true">2</span>+ <div><h2 id="hb-try-title">Try it</h2><p>Change a setting and see the difference as it moves.</p></div>+ </div>+ <div class="hb-settings">+ <div class="hb-setting">+ <p class="hb-setting-name" id="often-lbl">How often</p>+ <div class="seg" id="often-seg" role="group" aria-labelledby="often-lbl">+ <button type="button" data-often="rarely" aria-pressed="false">Rarely</button>+ <button type="button" data-often="sometimes" class="on" aria-pressed="true">Sometimes</button>+ <button type="button" data-often="often" aria-pressed="false">Often</button>+ </div>+ <p class="hb-hint">Rarely keeps it calm behind text.</p>+ </div>+ <div class="hb-setting">+ <p class="hb-setting-name" id="forks-lbl">Branches</p>+ <div class="seg" id="forks-seg" role="group" aria-labelledby="forks-lbl">+ <button type="button" data-forks="2" aria-pressed="false">Few</button>+ <button type="button" data-forks="4" class="on" aria-pressed="true">Some</button>+ <button type="button" data-forks="7" aria-pressed="false">Many</button>+ </div>+ <p class="hb-hint">How many thinner forks split off.</p>+ </div>+ <div class="hb-setting">+ <p class="hb-setting-name" id="color-lbl">Bolt color</p>+ <div class="swatches" id="color-sw" role="group" aria-labelledby="color-lbl">+ <button type="button" class="on" aria-pressed="true" aria-label="White" data-rgb="235,240,255" style="background:#ebf0ff"></button>+ <button type="button" aria-pressed="false" aria-label="Blue" data-rgb="140,196,255" style="background:#8cc4ff"></button>+ <button type="button" aria-pressed="false" aria-label="Violet" data-rgb="200,164,255" style="background:#c8a4ff"></button>+ </div>+ <p class="hb-hint">The bolt and its glow.</p>+ </div>+ </div>+ <details class="hb-options">+ <summary><span class="hb-more-label">More options</span><span class="hb-less">Fewer options</span><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg></summary>+ <div class="hb-settings">+ <div class="hb-setting">+ <label class="hb-switch-row"><span>Lights up the sky</span><input class="hb-switch" type="checkbox" role="switch" id="sky-tog" checked autocomplete="off"></label>+ <p class="hb-hint">The sky glows softly with each strike.</p>+ </div>+ <div class="hb-setting">+ <label class="hb-switch-row"><span>Rain</span><input class="hb-switch" type="checkbox" role="switch" id="rain-tog" checked autocomplete="off"></label>+ <p class="hb-hint">Light rain falls through the storm.</p>+ </div>+ </div>+ </details>+ </section>++ <section class="hb-step hb-prompt-step" aria-labelledby="hb-prompt-title">+ <div class="hb-step-head">+ <span class="hb-num" aria-hidden="true">3</span>+ <div><h2 id="hb-prompt-title">Copy the prompt</h2><p>Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.</p></div>+ </div>+ <div class="hb-card">+ <p class="hb-prompt">Add lightning to [the dark section or storm scene you want it in]. Every so often, draw a jagged bolt from the clouds to the ground on a canvas: start from a straight line, split it again and again, pushing each new midpoint sideways at random by less each time, and let thinner forks branch off. Draw a wide, faint stroke under a thin bright one for the glow; the bolt flickers once and fades within half a second. When the settings include it, light the sky softly, never more than twice a second. A click or tap strikes where the visitor points. If the visitor has reduced motion turned on, show a still bolt with no flash. Match the settings listed below.</p>+ <div class="hb-chips-box" hidden>+ <p class="hb-chips-title">Your settings</p>+ <ul class="hb-chips"></ul>+ </div>+ <div class="hb-copy-row">+ <button class="hb-copy" type="button"><svg class="hb-ic hb-i-copy" viewBox="0 0 24 24" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg><svg class="hb-ic hb-i-done" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg><span class="hb-copy-label" aria-live="polite">Copy prompt</span></button>+ <p class="hb-hint">Replace the words in brackets with your own element. Your settings are added at the end.</p>+ </div>+ </div>+ <div class="hb-star-row"><p>Free and open source. If this helped, a star on GitHub helps other people find it.</p><a class="hb-star-btn" href="https://github.com/matinmonshizadeh/animation-handbook" target="_blank" rel="noopener"><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1-4.4-4.3 6.1-.9z"/></svg>Star on GitHub</a></div>+ </section>++ <section class="hb-about" aria-labelledby="hb-what-title">+ <div class="hb-what">+ <h2 id="hb-what-title">What it is</h2>+ <div class="hb-what-text"><p>The full explanation is in <a href="README.md">README.md</a>.</p></div>+ </div>+ <div class="hb-fit">+ <h2>Good for</h2>+ <ul class="hb-tags hb-good"><li>Game sites</li><li>Storm and weather themes</li><li>Dramatic intros</li></ul>+ <h3>Avoid on</h3>+ <ul class="hb-tags hb-avoid"><li>Reading pages</li><li>Calm or health sites</li></ul>+ </div>+ </section>++ <section class="hb-related" aria-labelledby="hb-related-title" hidden>+ <h2 id="hb-related-title">Similar animations</h2>+ <div class="hb-rel-list"></div>+ </section>+</main>+<footer class="hb-foot"><span>Animation Handbook</span><a href="https://github.com/matinmonshizadeh/animation-handbook" target="_blank" rel="noopener">Source on GitHub</a><a href="#top">Back to top ↑</a></footer>+<script>+ const cvs=document.getElementById('cvs'),ctx=cvs.getContext('2d'),stage=cvs.parentElement,rain=stage.querySelector('.rain'),rctx=rain.getContext('2d');+ const clouds=[...stage.querySelectorAll('.clouds')],flash=stage.querySelector('.flash');+ const slowTog=document.getElementById('slow-tog'),skyTog=document.getElementById('sky-tog'),rainTog=document.getElementById('rain-tog');+ const reduceMQ=matchMedia('(prefers-reduced-motion: reduce)'),phone=matchMedia('(max-width:600px),(max-height:500px)');+ const FRAME=1000/60,GAP=1500; // safety: strikes start at least 1.5 s apart, whatever is pressed, so at most two flashes in any second+ const EVERY={rarely:[5000,8000],sometimes:[2600,4400],often:[1600,2400]}; // the wait between strikes, in ms, picked at random+ const LABELS={normal:'A storm over dark hills where a bolt strikes every few seconds. Click, or press Enter or Space, to make one strike.',+ inside:'The bolt drawn round by round: a straight line split again and again, its forks numbered and its glow. Click, or press Enter or Space, to strike.',+ compare:'Two bolts strike together: an even zigzag on the left and random splits on the right. Click, or press Enter or Space, to strike.'};+ let often='sometimes',forks=4,rgb=[235,240,255],mode='normal',paused=false;+ let W=0,H=0,raf=0,lastT=null,t=0,lastStrike=-1e9,nextAt=900,pending=null,strike=null,drops=[],shownKey='';+ let seed=5;const rand=()=>{seed=seed+0x6D2B79F5|0;let x=Math.imul(seed^seed>>>15,1|seed);x=x+Math.imul(x^x>>>7,61|x)^x;return((x^x>>>14)>>>0)/4294967296};+ // A bolt from (x0, y0) to (x1, y1), split rounds times: each segment's midpoint is pushed sideways at random by up to off,+ // and off halves every round. Every round is kept, so See inside can draw them one after another.+ function split(x0,y0,x1,y1,rounds,off){+ let pts=[[x0,y0],[x1,y1]];const steps=[pts];+ for(let k=0;k<rounds;k++,off/=2){+ const next=[pts[0]];+ for(let i=1;i<pts.length;i++){const [ax,ay]=pts[i-1],[bx,by]=pts[i],l=Math.hypot(bx-ax,by-ay)||1,o=(rand()*2-1)*off;+ next.push([(ax+bx)/2-(by-ay)/l*o,(ay+by)/2+(bx-ax)/l*o],pts[i])}+ steps.push(pts=next);+ }+ return steps;+ }+ // The common mistake: the same line bent in equal steps, from side to side, like an icon+ function zigzag(x0,y0,x1,y1){+ const n=8,l=Math.hypot(x1-x0,y1-y0),a=l*.06,pts=[];+ for(let i=0;i<=n;i++){const s=i%2?a:-a,k=i/n,e=i===0||i===n?0:s;pts.push([x0+(x1-x0)*k-(y1-y0)/l*e,y0+(y1-y0)*k+(x1-x0)/l*e])}+ return [pts];+ }+ // A whole strike in a rectangle (x, w): the main bolt from the clouds to (tx, ty), and its forks from points along it (fp: where+ // along the bolt each fork starts, its side and its length as a share of the bolt's); even: the mistake, zigzags in equal steps+ function makeBolt(x,w,tx,ty,even,fp){+ // it starts low enough in the clouds to stay clear of Compare's labels+ const sx=Math.min(x+w-8,Math.max(x+8,tx+(rand()-.5)*w*.25)),sy=Math.max(H*.1,46),len=Math.hypot(tx-sx,ty-sy);+ const main=even?zigzag(sx,sy,tx,ty):split(sx,sy,tx,ty,7,len*.22),line=main[main.length-1],fk=[];+ for(const [at,side,k] of fp){const p=line[Math.floor(at*(line.length-1))],fl=len*k,ex=p[0]+side*fl*.6,ey=p[1]+fl*.8;+ fk.push(even?zigzag(p[0],p[1],ex,ey):split(p[0],p[1],ex,ey,5,fl*.2))}+ const b={main,forks:fk};fitX(b,x+8,x+w-8);return b;+ }+ // The whole strike, glow and all, kept inside its rectangle: moved sideways if it pokes out, narrowed if it is wider than the+ // rectangle (the rounds share their points, so each point is moved once)+ function fitX(b,x0,x1){+ const ps=new Set([...b.main.flat(),...b.forks.flat(2)]);let lo=1e9,hi=-1e9;+ for(const p of ps){lo=Math.min(lo,p[0]);hi=Math.max(hi,p[0])}+ const k=Math.min(1,(x1-x0)/(hi-lo||1)),c=(lo+hi)/2,r=(hi-lo)*k/2,nc=Math.min(x1-r,Math.max(x0+r,c));+ for(const p of ps)p[0]=nc+(p[0]-c)*k;+ }+ // The bolts of a strike that lands at (tx, ty): one for Normal and See inside, and for Compare one in each half, at the same place+ // in its half, with forks in the same places. A resize or a new number of branches draws them again for the same spot, keeping+ // the strike's time. On a narrow box the bolt keeps to 60% of the width on its side, which leaves See inside's labels room.+ function bolts(tx,ty){+ const half=W/2,u=tx/W,fp=[...Array(forks)].map(()=>[.18+.55*rand(),rand()<.5?-1:1,.22+.2*rand()]),x=W<600&&u>=.5?W*.4:0;+ return {tx,ty,bolt:makeBolt(x,W<600?W*.6:W,tx,ty,false,fp),left:makeBolt(0,half,u*half,ty,true,fp),right:makeBolt(half,half,half+u*half,ty,false,fp)};+ }+ // A strike where the visitor pointed, or on the ground under a random spot+ function strikeNow(at){+ strike={at:t,still:false,full:false,...bolts(at?at.x:W*(.25+.5*rand()),at?Math.min(H*.9,at.y):H*(.74+.06*rand()))};+ lastStrike=t;nextAt=t+EVERY[often][0]+rand()*(EVERY[often][1]-EVERY[often][0]);+ placeLabels();+ }+ function redrawBolts(){if(strike){Object.assign(strike,bolts(strike.tx,strike.ty));placeLabels()}draw()}+ // How bright a strike is, age ms after it began: a flicker (bright, dim, bright) that fades within half a second; under reduced+ // motion a soft fade in and out with no flicker+ function bright(age){+ if(reduceMQ.matches)return age<250?age/250:age<600?1:age<1100?1-(age-600)/500:0;+ return age<60?1:age<120?.35:age<180?.9:age<500?.9*(1-(age-180)/320):0;+ }+ // the glow in the bolt's color, and the core that color mixed halfway to white, so the color shows in both+ const col=a=>`rgba(${rgb.join()},${a})`,core=a=>`rgba(${rgb.map(v=>Math.round(v+(255-v)*.5)).join()},${a})`;+ let numFont='700 12px sans-serif'; // the site font for the forks' numbers, read once the page's styles are in (resize)+ function stroke(pts,w,style,dash){ctx.lineWidth=w;ctx.strokeStyle=style;ctx.setLineDash(dash||[]);ctx.beginPath();pts.forEach(([x,y],i)=>i?ctx.lineTo(x,y):ctx.moveTo(x,y));ctx.stroke()}+ // A bolt as it looks: a wide, faint stroke for the glow under a thin bright one (no shadow blur); forks thinner, all of them in+ // one path, so a frame of a flash strokes four paths a bolt+ function strokeAll(lines,w,style){ctx.lineWidth=w;ctx.strokeStyle=style;ctx.setLineDash([]);ctx.beginPath();for(const pts of lines)pts.forEach(([x,y],i)=>i?ctx.lineTo(x,y):ctx.moveTo(x,y));ctx.stroke()}+ function drawBolt(b,a){+ if(a<=0)return;+ const main=[b.main[b.main.length-1]],forks=b.forks.map(f=>f[f.length-1]);+ strokeAll(main,11,col(.24*a));strokeAll(forks,6.5,col(.24*a));strokeAll(main,2.2,core(a));strokeAll(forks,1.3,core(a));+ }+ // See inside: the bolt round by round (the straight line dashed, each later round lighter, the pushed points dotted), then the+ // forks numbered, then the glow. A strike builds it a round every 110 ms; between strikes the last drawing stays, faint.+ function drawRounds(b,age){+ const shown=age===null?99:age/110,f=age===null||age>1800?.7:1,main=b.main;+ main.forEach((pts,k)=>{if(k>shown)return;+ if(k===0)stroke(pts,1.5,`rgba(220,226,240,${.8*f})`,[6,6]);+ else stroke(pts,k===7?2.2:1.2,k===7?core(f):`rgba(${rgb.join()},${(.15+.08*k)*f})`);+ if(k>0&&k<5){ctx.fillStyle=`rgba(255,206,90,${.9*f})`;pts.forEach((p,i)=>{if(i%2){ctx.beginPath();ctx.arc(p[0],p[1],k<3?3:2,0,6.283);ctx.fill()}})}});+ const nums=[]; // the fork's number sits a little way along the fork, clear of the main bolt and of the numbers before it+ if(shown>8)b.forks.forEach((fk,i)=>{const pts=fk[fk.length-1],at=k=>pts[Math.floor(pts.length*k)];stroke(pts,1.2,col(.8*f));+ const q=[.5,.72,.35,.88].map(at).find(p=>nums.every(n=>Math.hypot(n[0]-p[0],n[1]-p[1])>24))||at(.5);nums.push(q);+ ctx.fillStyle=`rgba(8,10,18,${.9*f})`;ctx.beginPath();ctx.arc(q[0],q[1],9,0,6.283);ctx.fill();+ ctx.fillStyle=`rgba(255,255,255,${f})`;ctx.font=numFont;ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText(i+1,q[0],q[1]+.5)});+ if(shown>9)stroke(main[7],11,col(.24*f));+ }+ // The rain has its own canvas, drawn every frame; the bolts' canvas is drawn only when it changes+ function drawRain(){+ rctx.clearRect(0,0,W,H);+ if(!rainTog.checked)return;+ rctx.strokeStyle=mode==='inside'?'rgba(170,190,230,.15)':'rgba(170,190,230,.35)';rctx.lineWidth=1;rctx.beginPath();+ for(const d of drops){rctx.moveTo(d.x,d.y);rctx.lineTo(d.x-2,d.y+d.l)}rctx.stroke();+ }+ function drawBolts(){+ ctx.clearRect(0,0,W,H);+ // a still bolt (paused, under reduced motion or after a click while paused) shows at full strength with no flash+ const age=strike?t-strike.at:1e9,a=strike?(strike.still?1:bright(age)):0;+ ctx.lineCap=ctx.lineJoin='round';+ if(mode==='inside'&&strike)drawRounds(strike.bolt,age<2000&&!strike.still&&!strike.full?age:null);+ else if(mode==='compare'&&strike){+ // each half's bolt stays inside its own half, even where its bends or forks reach toward the other+ [strike.left,strike.right].forEach((b,i)=>{ctx.save();ctx.beginPath();ctx.rect(i?W/2+1:0,0,W/2-1,H);ctx.clip();drawBolt(b,Math.max(a,.3));ctx.restore()}); // faint between strikes+ ctx.fillStyle='#05070d';ctx.fillRect(W/2-1,0,2,H)}+ else if(strike)drawBolt(strike.bolt,a);+ // The sky's light: at most 30% white, following the flicker (half that under See inside's drawing); a still bolt keeps a+ // steady faint glow, and under reduced motion the glow only fades in and out with the bolt, never above 10%+ let sky=0;+ if(skyTog.checked&&strike)sky=strike.still?.1:reduceMQ.matches?.1*a:.3*a*(mode==='inside'?.5:1);+ flash.style.opacity=sky.toFixed(3);+ }+ function draw(){drawRain();drawBolts();shownKey=boltKey()}+ // What the bolts' canvas shows, as a key that changes every frame while a strike flashes and once a round (every 110 ms)+ // while See inside builds it; the loop draws the canvas again only when the key changes+ function boltKey(){+ if(!strike||strike.still)return mode+'still';+ const age=t-strike.at;+ if(mode==='inside')return strike.full||age>=2000?'built':'round'+Math.floor(age/110);+ return age<(reduceMQ.matches?1100:600)?'flash'+t:'after';+ }+ // See inside's labels beside the parts they name, each one beside the bolt where the bolt, its forks and the labels already+ // placed leave room, nearer the bolt; a label with no room at its height looks lower, then higher+ function placeLabels(){+ if(!strike||mode!=='inside'||!W)return;+ const b=strike.bolt,[[x0,y0],[x1,y1]]=b.main[0],pts=[],f=b.forks[0],done=[];+ for(let k=0;k<=24;k++)pts.push([x0+(x1-x0)*k/24,y0+(y1-y0)*k/24]);+ b.main.slice(1).forEach(r=>pts.push(...r));b.forks.forEach(fk=>pts.push(...fk[fk.length-1]));+ const want=[['l-straight',H*.08],['l-split',H*.3],['l-fork',f?Math.min(H*.62,Math.max(H*.4,f[0][0][1]-10)):H*.52],['l-glow',H*.72]];+ for(const [id,at] of want){+ const el=document.getElementById(id),tries=[];+ for(let y=at;y<H;y+=10)tries.push(y);for(let y=at-10;y>=8;y-=10)tries.push(y);+ // with no room anywhere (a click near the middle of a narrow box), narrower still, then over the forks but never over a label+ tries.some(y=>fit(el,Math.max(8,y),pts,done,96))||tries.some(y=>fit(el,Math.max(8,y),pts,done,72))||tries.some(y=>fit(el,Math.max(8,y),[],done,72));+ done.push({l:el.offsetLeft,t:el.offsetTop,r:el.offsetLeft+el.offsetWidth,b:el.offsetTop+el.offsetHeight});+ }+ }+ const PAD=14; // the glow and the forks' numbers reach this far from a line+ function fit(el,y,pts,done,min){+ let w=Math.min(W*.46,260);+ for(let i=0;i<3;i++){+ el.style.left='0px';el.style.maxWidth=w+'px';const h=el.offsetHeight,ew=el.offsetWidth;if(y+h>H-8)return false; // measured at the left edge, where the box does not squeeze it+ let lo=1e9,hi=-1e9;for(const [px,py] of pts)if(py>y-PAD&&py<y+h+PAD){lo=Math.min(lo,px);hi=Math.max(hi,px)}+ if(lo>hi)lo=hi=strike.tx; // nothing at this height: beside where it strikes+ const left=lo-PAD-8,right=W-8-hi-PAD,free=x=>!done.some(d=>x<d.r+6&&d.l<x+ew+6&&y<d.b+6&&d.t<y+h+6);+ // the side with more room first, then the other+ for(const [room,x] of right>=left?[[right,hi+PAD],[left,lo-PAD-ew]]:[[left,lo-PAD-ew],[right,hi+PAD]])+ if(ew<=room&&free(x)){el.style.left=x+'px';el.style.top=y+'px';return true}+ const room=Math.max(left,right);+ if(room<min||ew<=room)return false;+ w=room; // narrower, on more lines, then measured again+ }+ return false;+ }+ // The rain falls by the time that passed; fewer drops on phones+ function makeRain(){drops=Array.from({length:phone.matches?70:160},()=>({x:rand()*(W+40),y:rand()*H,l:8+rand()*10,v:.5+rand()*.3}))}+ // The loop moves the rain and the clouds and keeps the strikes by the time that passed (a third of it in slow motion). A strike+ // the visitor asked for waits until the gap since the last one is over.+ function loop(ts){+ raf=requestAnimationFrame(loop);+ if(followReduce())return; // reduced motion just turned on: the bolt holds still, and the shared script pauses+ if(lastT===null){lastT=ts;return}+ const dt=Math.min(ts-lastT,50)*(slowTog.checked?1/3:1);lastT=ts;t+=dt;+ if(t-lastStrike>=GAP&&(pending||t>=nextAt)){strikeNow(pending);pending=null}+ for(const d of drops){d.y+=d.v*dt;d.x-=d.v*dt*.12;if(d.y>H){d.y=-d.l;d.x=rand()*(W+40)}}+ clouds.forEach((c,i)=>{c.style.transform=`translateX(${-((t*(i?.006:.01))%W).toFixed(1)}px)`});+ drawRain();+ const key=boltKey();+ if(key!==shownKey){drawBolts();shownKey=key}+ }+ function start(){if(raf||paused)return;lastT=null;raf=requestAnimationFrame(loop)}+ // Registered at the top level: under reduced motion the shared script pauses the loop at once, on a still bolt+ // A still bolt starts fading when the loop plays again+ document.addEventListener('hb:pause',e=>{+ paused=e.detail.paused;followReduce();notes();+ if(paused){cancelAnimationFrame(raf);raf=0;draw();return}+ // a still bolt starts fading, and counts as the last strike, so the next keeps the gap+ if(strike&&strike.still){strike.still=false;strike.at=lastStrike=t-(reduceMQ.matches?600:180)}+ start();+ });+ document.addEventListener('visibilitychange',()=>{lastT=null});+ // The mode switch draws the mode at once; See inside opened while paused shows the last bolt's whole drawing+ document.addEventListener('hb:mode',e=>{mode=e.detail.mode;if(paused&&strike)strike.full=true;cvs.setAttribute('aria-label',LABELS[mode]);placeLabels();if(W)draw()});+ // A click, a tap, or Enter or Space on the box asks for a strike there (the middle, from the keyboard). While paused it draws a+ // new still bolt there at once, with no flash.+ function ask(at){+ if(!paused){pending=at;return}+ strikeNow(at);strike.still=true;lastStrike=-1e9;draw();+ }+ cvs.addEventListener('click',e=>{const r=cvs.getBoundingClientRect();ask({x:e.clientX-r.left,y:Math.max(H*.3,e.clientY-r.top)})});+ cvs.addEventListener('keydown',e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();ask({x:W/2,y:H*.62})}});+ function resize(){+ const w=stage.clientWidth,h=stage.clientHeight;if(!w||!h||(w===W&&h===H))return;+ const sx=W?w/W:1,sy=H?h/H:1;W=w;H=h;+ // thin lines stay sharp enough at one and a half pixels per CSS pixel, which spares a phone almost half the work+ const dpr=Math.min(devicePixelRatio||1,1.5);+ for(const [c,g] of [[cvs,ctx],[rain,rctx]]){c.width=W*dpr;c.height=H*dpr;g.setTransform(dpr,0,0,dpr,0,0)}+ numFont='700 12px '+getComputedStyle(stage).getPropertyValue('--hb-font');+ makeRain();+ if(strike){strike.tx*=sx;strike.ty*=sy}+ redrawBolts();+ }+ function choices(id,pick){+ const buttons=document.querySelectorAll('#'+id+' button');+ buttons.forEach(b=>b.addEventListener('click',()=>{+ buttons.forEach(x=>{x.classList.toggle('on',x===b);x.setAttribute('aria-pressed',String(x===b))});+ pick(b.dataset);+ }));+ }+ // Branches and colors show at once, on the bolt on screen; How often counts from the next strike+ choices('often-seg',d=>{often=d.often;nextAt=Math.min(nextAt,lastStrike+EVERY[often][1])});+ choices('forks-seg',d=>{forks=+d.forks;redrawBolts()});+ choices('color-sw',d=>{rgb=d.rgb.split(',').map(Number);draw()});+ skyTog.addEventListener('change',draw);+ rainTog.addEventListener('change',draw);+ new ResizeObserver(resize).observe(stage);+ resize();+ // Under reduced motion the loop starts paused on a still bolt, and the notes say so while it is paused; playing, the markup's+ // words hold+ const said={inside:document.querySelector('[data-hb-for="inside"]').textContent,compare:document.querySelector('[data-hb-for="compare"]').textContent};+ const STILL={inside:'Shown still: the bolt is a straight line split again and again, each middle pushed aside by less, with its forks numbered and a soft glow.',+ compare:'Shown still: on the left, Even zigzag bends in equal steps, so it looks drawn; on the right, Random splits has big bends and fine jitter.'};+ function notes(){const still=reduceMQ.matches&&paused;for(const k of ['inside','compare'])document.querySelector(`[data-hb-for="${k}"]`).textContent=still?STILL[k]:said[k]}+ // The still bolt: the strike on screen held, or a new one at a fixed spot (the random numbers are seeded, so it is the same bolt+ // every time)+ function stillBolt(){+ if(!strike||(!strike.still&&bright(t-strike.at)<=0))strikeNow({x:W*.62,y:H*.78});+ strike.still=true;lastStrike=-1e9;draw();+ }+ if(reduceMQ.matches)stillBolt();+ notes();+ // The device's setting changed after load: turned on, the bolt on screen holds still (the shared script pauses the loop); either+ // way the notes follow. Chrome sends no change event to a page that reads the setting every frame, so the loop and the pause+ // look too.+ let wasReduced=reduceMQ.matches;+ function followReduce(){+ const r=reduceMQ.matches;if(r===wasReduced)return false;wasReduced=r;+ if(r&&W)stillBolt();notes();return r;+ }+ reduceMQ.addEventListener('change',followReduce);+ document.fonts&&document.fonts.ready.then(placeLabels); // the labels' sizes once the site font is in+ if(!reduceMQ.matches)start(); // under reduced motion the shared script pauses at once: no frame may come first+</script>+</body>+</html>diff --git a/animations/07-ambient-background/snow-rain/README.md b/animations/07-ambient-background/snow-rain/README.mdindex e1c6f8d3..38f67063 100644--- a/animations/07-ambient-background/snow-rain/README.md+++ b/animations/07-ambient-background/snow-rain/README.md@@ -70,3 +70,4 @@ The number of particles follows the area they share, so a phone draws about a qu- [Wave Layers](../wave-layers/) — the same near-fast, far-slow depth rule with layers of water- [Particle Constellation](../particle-constellation/) — drifting dots that link up when they come close- [Fireworks](../fireworks/) — particles over the same kind of dark scene, bursting instead of falling+- [Lightning](../lightning/) — bolts and a soft flash over the same kind of rainy scenediff --git a/index.html b/index.htmlindex 87c2deee..60329c8a 100644--- a/index.html+++ b/index.html@@ -4,8 +4,8 @@<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="google-site-verification" content="2PnJemecfPix7j08I3cojuzPTfwKpwxxFMADFxv4wk8">-<title>Animation Handbook — 175 Web Animation Techniques with Live Demos</title>-<meta name="description" content="A free visual reference of 175 web animation techniques, from scroll effects to 3D: each plays live and comes with a ready-made prompt for your AI assistant.">+<title>Animation Handbook — 176 Web Animation Techniques with Live Demos</title>+<meta name="description" content="A free visual reference of 176 web animation techniques, from scroll effects to 3D: each plays live and comes with a ready-made prompt for your AI assistant."><meta name="keywords" content="web animation, CSS animation, animation examples, scroll animation, page transitions, micro-interactions, kinetic typography, WebGL, frontend animation reference, motion design, animation handbook"><meta name="author" content="Matin Monshizadeh"><meta name="robots" content="index, follow, max-image-preview:large">@@ -19,8 +19,8 @@<!-- Open Graph --><meta property="og:type" content="website"><meta property="og:site_name" content="Animation Handbook">-<meta property="og:title" content="Animation Handbook — 175 Web Animation Techniques with Live Demos">-<meta property="og:description" content="A free visual reference of 175 web animation techniques, from scroll effects to 3D: each plays live and comes with a ready-made prompt for your AI assistant.">+<meta property="og:title" content="Animation Handbook — 176 Web Animation Techniques with Live Demos">+<meta property="og:description" content="A free visual reference of 176 web animation techniques, from scroll effects to 3D: each plays live and comes with a ready-made prompt for your AI assistant."><meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/"><meta property="og:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png"><meta property="og:image:width" content="1200">@@ -28,8 +28,8 @@<!-- Twitter --><meta name="twitter:card" content="summary_large_image">-<meta name="twitter:title" content="Animation Handbook — 175 Web Animation Techniques with Live Demos">-<meta name="twitter:description" content="A free visual reference of 175 web animation techniques, from scroll effects to 3D: each plays live and comes with a ready-made prompt for your AI assistant.">+<meta name="twitter:title" content="Animation Handbook — 176 Web Animation Techniques with Live Demos">+<meta name="twitter:description" content="A free visual reference of 176 web animation techniques, from scroll effects to 3D: each plays live and comes with a ready-made prompt for your AI assistant."><meta name="twitter:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png"><!-- Structured data: parsed by search + AI answer engines -->@@ -39,7 +39,7 @@"@type": "WebSite","name": "Animation Handbook","url": "https://matinmonshizadeh.github.io/animation-handbook/",- "description": "A free visual reference of 175 web animation techniques, from scroll effects to 3D: each plays live and comes with a ready-made prompt for your AI assistant.",+ "description": "A free visual reference of 176 web animation techniques, from scroll effects to 3D: each plays live and comes with a ready-made prompt for your AI assistant.","inLanguage": "en","author": { "@type": "Person", "name": "Matin Monshizadeh" },"about": ["web animation", "CSS animation", "motion design", "frontend development"],@@ -1405,6 +1405,15 @@ button,input{font:inherit;color:inherit}@keyframes fire-tongue{0%{transform:scaleY(.86) skewX(-4deg)}100%{transform:scaleY(1.08) skewX(5deg)}}@keyframes fire-spark{0%{opacity:0;transform:translate(0,0)}15%{opacity:1}100%{opacity:0;transform:translate(1.5cqw,-58cqh)}}+.pv-lightning{background:linear-gradient(#0b1020,#1a2236 60%,#262c40);overflow:hidden}+.pv-lightning .hl{position:absolute;left:0;right:0;bottom:0;height:30%;background:radial-gradient(70% 90% at 25% 100%,#141a2a 60%,#0000 61%),radial-gradient(80% 100% at 85% 100%,#0b0f1a 60%,#0000 61%)}+.pv-lightning .bt{position:absolute;inset:0;width:100%;height:100%;opacity:0;animation:lightning-bolt 3s linear infinite}+.pv-lightning .bt path{fill:none;stroke-linecap:round;stroke-linejoin:round}+.pv-lightning .g{stroke:rgba(200,215,255,.28);stroke-width:5}.pv-lightning .c{stroke:#fff;stroke-width:1.4}.pv-lightning .f{stroke-width:.9}+.pv-lightning .fl{position:absolute;inset:0;background:#fff;opacity:0;animation:lightning-sky 3s linear infinite}+@keyframes lightning-bolt{0%{opacity:0}1.5%{opacity:1}3%{opacity:.35}4.5%{opacity:.9}14%,100%{opacity:0}}+@keyframes lightning-sky{0%{opacity:0}1.5%{opacity:.22}3%{opacity:.08}4.5%{opacity:.2}14%,100%{opacity:0}}+/* ── bespoke: added demos ── */.pv-magnet{background:#08090c;display:grid;place-items:center;position:relative}.pv-magnet .btn{padding:9px 20px;border-radius:6px;border:1px solid var(--accent);color:var(--accent);font-family:var(--text);font-size:11px;animation:magbtn 3.6s var(--ease) infinite}@@ -1723,7 +1732,7 @@ button,input{font:inherit;color:inherit}<section class="wrap home-hero" aria-labelledby="hero-title"><span class="float fl1" aria-hidden="true"></span><span class="float fl2" aria-hidden="true"></span><span class="float fl3" aria-hidden="true"></span><span class="float fl4" aria-hidden="true"></span><span class="float fl5" aria-hidden="true"></span><span class="float fl6" aria-hidden="true"></span>- <p class="pill"><span class="pill-dot" aria-hidden="true"></span>175 free animations · no coding needed</p>+ <p class="pill"><span class="pill-dot" aria-hidden="true"></span>176 free animations · no coding needed</p><h1 class="h1" id="hero-title">What do you want to animate?</h1><p class="sub">Pick a place, or describe it in your own words. Every animation plays live, and each one comes with a ready-made prompt for your AI assistant.</p><form class="search" id="search-form" role="search" action="./" method="get">@@ -1788,14 +1797,14 @@ button,input{font:inherit;color:inherit}<p class="empty-s">Try a simpler word, or pick one of these:</p><p class="pop"><button type="button" data-q="fade in">fade in</button><button type="button" data-q="typing text">typing text</button><button type="button" data-q="loading spinner">loading spinner</button><button type="button" data-q="parallax">parallax</button><button type="button" data-q="confetti">confetti</button></p></div>- <div class="more" id="more"><button type="button" class="bigbtn" id="more-btn"><span id="more-label">Browse all 175 animations</span><svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M6 13l6 6 6-6"/></svg></button></div>+ <div class="more" id="more"><button type="button" class="bigbtn" id="more-btn"><span id="more-label">Browse all 176 animations</span><svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M6 13l6 6 6-6"/></svg></button></div><div class="fd-not" id="find-not" hidden><h3 class="fd-not-t">Not here?</h3><p class="fd-not-s" id="find-not-s">Tell us what you saw. We use it to add the animation or to fix the finder.</p><p class="fd-not-acts"><a class="fd-btn" id="find-gh" href="https://github.com/matinmonshizadeh/animation-handbook/issues/new?template=animation_not_here.yml" target="_blank" rel="noopener">Tell us on GitHub</a><button type="button" class="pillbtn" id="find-words">Describe it in words</button></p><p class="fd-fine">The form is on GitHub and needs a free account.</p></div>- <noscript><p class="noscript">This page shows its animations with JavaScript. All 175 are still easy to reach: see the <a href="https://github.com/matinmonshizadeh/animation-handbook#categories">category list on GitHub</a> or the <a href="sitemap.xml">full sitemap</a>. Each demo is a page of its own under <code>/animations/<category>/<name>/</code>.</p></noscript>+ <noscript><p class="noscript">This page shows its animations with JavaScript. All 176 are still easy to reach: see the <a href="https://github.com/matinmonshizadeh/animation-handbook#categories">category list on GitHub</a> or the <a href="sitemap.xml">full sitemap</a>. Each demo is a page of its own under <code>/animations/<category>/<name>/</code>.</p></noscript></section><section class="how" id="how" aria-labelledby="how-title">@@ -1813,7 +1822,7 @@ button,input{font:inherit;color:inherit}<footer class="wrap foot"><a class="brand" href="./"><svg class="mark" viewBox="0 0 32 32" aria-hidden="true"><circle class="ring" cx="11.16" cy="20.84" r="6.1"/><circle class="ring" cx="15.12" cy="16.88" r="6.1"/><circle class="ring" cx="18.51" cy="13.49" r="6.1"/><circle class="ball" cx="21.2" cy="10.8" r="6.6"/></svg><span>Animation Handbook</span></a>- <p class="foot-t">175 web animations with live demos and copyable prompts.</p>+ <p class="foot-t">176 web animations with live demos and copyable prompts.</p><nav class="nav" aria-label="Footer"><a class="lnk" href="famous/">Famous effects</a><a class="lnk" href="https://github.com/matinmonshizadeh/animation-handbook" target="_blank" rel="noopener">GitHub</a><a class="lnk" href="#top">Back to top</a></nav></footer><div class="toast" id="toast" role="status" aria-live="polite"><span class="ok" aria-hidden="true"><svg class="i" viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span><span class="toast-t"></span></div>@@ -2051,6 +2060,7 @@ const CATS=[['game-of-life','Game of Life','Cells live and die by their neighbors, and patterns grow. Best for tech sites.'],['ken-burns','Ken Burns Effect','Photos slowly zoom and pan, then fade into the next. Best for hero slideshows.'],['fire-effect','Fire Effect','Flames flicker and rise as heat climbs and cools. Best for game and event pages.'],+ ['lightning','Lightning','Jagged bolts strike from the clouds and light up the sky. Best for dramatic intros.'],]}];@@ -2068,7 +2078,7 @@ const PV={'image-trail':'imgtrail','gooey-menu':'gooey','dynamic-island':'dynisland','before-after-slider':'beforeafter','magnifier-lens':'magnifier','card-deck-swipe':'deckswipe','flip-card-3d':'flip3d','carousel-3d':'carousel3d','depth-map-photo':'depthmap','flocking':'flock','ascii-halftone':'ascii','physics-2d':'phys2d','liquid-glass':'liquidglass','holographic-card':'holo','infinite-zoom':'izoom','water-ripple':'waterripple','audio-visualizer':'audioviz','matrix-rain':'matrix','plasma':'plasmapv','wave-layers':'wavelayers','snow-rain':'snowrain','fireworks':'fireworks',- 'topographic-lines':'topo','light-rays':'rays','game-of-life':'life','ken-burns':'kenburns','fire-effect':'fire',+ 'topographic-lines':'topo','light-rays':'rays','game-of-life':'life','ken-burns':'kenburns','fire-effect':'fire','lightning':'lightning','parallax-depth-of-field':'dof','parallax-scrolling':'plx','reverse-scrolling-columns':'revcol','cover-card-to-fixed-header':'cover','fly-in-fly-out-contact-list':'flylist','stacking-cards':'stack','scroll-trigger':'trigger','scrub-animation':'scrub','pin-animation':'pin','snap-scrolling':'snap',@@ -2288,7 +2298,8 @@ const PLACES={'light-rays':['bg','intro'],'game-of-life':['bg'],'ken-burns':['imgcard','bg','intro'],- 'fire-effect':['bg','intro']+ 'fire-effect':['bg','intro'],+ 'lightning':['bg','intro']};// What moved, when and how: the finder's answers for each card, the main one first.const FIND={@@ -2473,7 +2484,8 @@ const FIND={'light-rays':['background','loop','color drift fade'],'game-of-life':['particles background shape','loop click drag','morph grow glitch'],'ken-burns':['card background','loop load','grow slide fade'],- 'fire-effect':['background','loop','glitch color drift']+ 'fire-effect':['background','loop','glitch color drift'],+ 'lightning':['background shape','loop click','glitch color']};// The finder's three questions in order (spec, section 2): each answer's key (in the address and in FIND), its words (which name// it) and its picture: a still icon in the site's 24px line style for What and When, the class of a small moving picture for How@@ -2601,6 +2613,7 @@ function pvMarkup(k){[[13,0],[14,0],[12,1],[15,1],[13,2],[14,2],[1,7],[2,7],[1,8],[2,8]].map(cell).join('')+'</svg>';}case 'kenburns': return '<i class="p1 anim"></i><i class="p2 anim"></i>';case 'fire': return [1,2,3,4].map(k=>'<i class="t'+k+' anim"></i>').join('')+[1,2,3].map(k=>'<b class="k'+k+' anim"></b>').join('');+ case 'lightning': return '<span class="hl"></span><svg class="bt anim" viewBox="0 0 160 100"><path class="g" d="M96 6L88 22 94 30 80 46 86 52 74 70 78 76 70 88"/><path class="g" d="M86 52L98 62 96 72"/><path class="c" d="M96 6L88 22 94 30 80 46 86 52 74 70 78 76 70 88"/><path class="c f" d="M86 52L98 62 96 72"/></svg><span class="fl anim"></span>';case 'aurora': return '<span class="band b1 anim"></span><span class="band b2 anim"></span><span class="band b3 anim"></span>';case 'mesh': return '<span class="m m1 anim"></span><span class="m m2 anim"></span><span class="m m3 anim"></span>';case 'glow': return '<span class="core anim"></span><span class="ring anim"></span>';@@ -2883,7 +2896,7 @@ let shown=[];// under the place label or between two states). Nothing here runs without reduced motion.const STILL={cover:.1,curtain:.6,kinetic:.25,carousel:.1,typewriter:.55,textclip:.7,svgpath:.7,smoke:.3,leak:.7,- flash:.41,blurpage:.2,toggle:.7,shake:.8,hideheader:.72,hilite:.7,splitflap:.7,handwrite:.75,tparticles:.36,circlerev:.25,owipe:.165,pcurl:.44,cubepage:.3,reorder:.4,ascii:.2,phys2d:.6,shatter:.15,izoom:.02,pixelate:.34,deckswipe:.4+ flash:.41,blurpage:.2,toggle:.7,shake:.8,hideheader:.72,hilite:.7,splitflap:.7,handwrite:.75,tparticles:.36,circlerev:.25,owipe:.165,pcurl:.44,cubepage:.3,reorder:.4,ascii:.2,phys2d:.6,shatter:.15,izoom:.02,pixelate:.34,deckswipe:.4,lightning:.016};function hold(card){const anims=card.querySelector('.pv').getAnimations({subtree:true});diff --git a/llms.txt b/llms.txtindex f1e1dead..a257da2f 100644--- a/llms.txt+++ b/llms.txt@@ -1,8 +1,8 @@# Animation Handbook-> A visual reference of 175 web animation techniques, each with a live demo and a plain-words prompt for building it with an AI assistant.+> A visual reference of 176 web animation techniques, each with a live demo and a plain-words prompt for building it with an AI assistant.-Each page plays one technique live and gives a ready-made prompt that describes it in plain words, with no code. Most pages also have a few plain settings, such as speed or direction, and the prompt you copy lists your choices. Each technique's folder on GitHub has a README on how it works, the values that matter and production notes. To give an AI coding assistant all 175 prompts and settings at once, install the Agent Skill: `npx skills add matinmonshizadeh/animation-handbook`.+Each page plays one technique live and gives a ready-made prompt that describes it in plain words, with no code. Most pages also have a few plain settings, such as speed or direction, and the prompt you copy lists your choices. Each technique's folder on GitHub has a README on how it works, the values that matter and production notes. To give an AI coding assistant all 176 prompts and settings at once, install the Agent Skill: `npx skills add matinmonshizadeh/animation-handbook`.## Scroll-Based@@ -199,6 +199,7 @@ Each page plays one technique live and gives a ready-made prompt that describes- [Game of Life](https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/game-of-life/): Cells live and die by their neighbors, and patterns grow. Best for tech sites.- [Ken Burns Effect](https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/ken-burns/): Photos slowly zoom and pan, then fade into the next. Best for hero slideshows.- [Fire Effect](https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/fire-effect/): Flames flicker and rise as heat climbs and cools. Best for game and event pages.+- [Lightning](https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/lightning/): Jagged bolts strike from the clouds and light up the sky. Best for dramatic intros.## Famous effects@@ -207,14 +208,14 @@ Each page plays one technique live and gives a ready-made prompt that describes## Skill files- [SKILL.md](https://matinmonshizadeh.github.io/animation-handbook/skills/animation-handbook/SKILL.md): how to find a technique, choose its settings for the user's page and build it, with the rules for real pages-- [references/catalog.md](https://matinmonshizadeh.github.io/animation-handbook/skills/animation-handbook/references/catalog.md): all 175 in one list, with what each does and where it goes, and an index by place+- [references/catalog.md](https://matinmonshizadeh.github.io/animation-handbook/skills/animation-handbook/references/catalog.md): all 176 in one list, with what each does and where it goes, and an index by place- [references/01-scroll-based.md](https://matinmonshizadeh.github.io/animation-handbook/skills/animation-handbook/references/01-scroll-based.md): the 27 Scroll-Based entries, each with its prompt and its settings, with the demo's values- [references/02-entrance-and-exit.md](https://matinmonshizadeh.github.io/animation-handbook/skills/animation-handbook/references/02-entrance-and-exit.md): the 15 Entrance & Exit entries, each with its prompt and its settings, with the demo's values- [references/03-page-transitions.md](https://matinmonshizadeh.github.io/animation-handbook/skills/animation-handbook/references/03-page-transitions.md): the 17 Page Transitions entries, each with its prompt and its settings, with the demo's values- [references/04-micro-interactions.md](https://matinmonshizadeh.github.io/animation-handbook/skills/animation-handbook/references/04-micro-interactions.md): the 44 Micro-Interactions entries, each with its prompt and its settings, with the demo's values- [references/05-text-typography.md](https://matinmonshizadeh.github.io/animation-handbook/skills/animation-handbook/references/05-text-typography.md): the 19 Text & Typography entries, each with its prompt and its settings, with the demo's values- [references/06-3d-advanced.md](https://matinmonshizadeh.github.io/animation-handbook/skills/animation-handbook/references/06-3d-advanced.md): the 28 3D & Advanced entries, each with its prompt and its settings, with the demo's values-- [references/07-ambient-background.md](https://matinmonshizadeh.github.io/animation-handbook/skills/animation-handbook/references/07-ambient-background.md): the 25 Ambient & Background entries, each with its prompt and its settings, with the demo's values+- [references/07-ambient-background.md](https://matinmonshizadeh.github.io/animation-handbook/skills/animation-handbook/references/07-ambient-background.md): the 26 Ambient & Background entries, each with its prompt and its settings, with the demo's values## Optionaldiff --git a/og-image.png b/og-image.pngindex 271cc27f..b96bbc51 100644Binary files a/og-image.png and b/og-image.png differdiff --git a/sitemap.xml b/sitemap.xmlindex 44358740..940ac7f0 100644--- a/sitemap.xml+++ b/sitemap.xml@@ -170,11 +170,12 @@<url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/matrix-rain/</loc><lastmod>2026-10-15</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url><url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/plasma/</loc><lastmod>2026-10-15</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url><url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/wave-layers/</loc><lastmod>2026-10-15</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>- <url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/snow-rain/</loc><lastmod>2026-10-15</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>+ <url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/snow-rain/</loc><lastmod>2026-10-18</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url><url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/fireworks/</loc><lastmod>2026-10-18</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url><url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/topographic-lines/</loc><lastmod>2026-10-15</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url><url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/light-rays/</loc><lastmod>2026-10-15</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url><url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/game-of-life/</loc><lastmod>2026-10-18</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url><url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/ken-burns/</loc><lastmod>2026-10-18</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url><url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/fire-effect/</loc><lastmod>2026-10-18</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>+ <url><loc>https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/lightning/</loc><lastmod>2026-10-18</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url></urlset>diff --git a/skills/animation-handbook/SKILL.md b/skills/animation-handbook/SKILL.mdindex 4e550636..4425155c 100644--- a/skills/animation-handbook/SKILL.md+++ b/skills/animation-handbook/SKILL.md@@ -1,12 +1,12 @@---name: animation-handbook-description: Builds web animations from Animation Handbook, a set of 175 tested techniques with plain-words build prompts and settings (scroll effects, entrances and exits, page transitions, micro-interactions for buttons and forms, text effects, 3D and WebGL, ambient backgrounds). Use when the user asks to add, pick or improve an animation, transition, hover or click effect, loading state, scroll effect or background motion in a web page or web app, in any framework or plain HTML, CSS and JavaScript.+description: Builds web animations from Animation Handbook, a set of 176 tested techniques with plain-words build prompts and settings (scroll effects, entrances and exits, page transitions, micro-interactions for buttons and forms, text effects, 3D and WebGL, ambient backgrounds). Use when the user asks to add, pick or improve an animation, transition, hover or click effect, loading state, scroll effect or background motion in a web page or web app, in any framework or plain HTML, CSS and JavaScript.license: MIT---# Animation Handbook-[Animation Handbook](https://matinmonshizadeh.github.io/animation-handbook/) is a free reference of 175 web animation techniques. Each has a live demo, a few plain settings for most (speed, direction, color and the like) and a prompt that says in plain words how to build it. This skill holds every prompt and every setting with the demo's values.+[Animation Handbook](https://matinmonshizadeh.github.io/animation-handbook/) is a free reference of 176 web animation techniques. Each has a live demo, a few plain settings for most (speed, direction, color and the like) and a prompt that says in plain words how to build it. This skill holds every prompt and every setting with the demo's values.## How to use it@@ -36,13 +36,13 @@ Keep these even where a prompt does not say them, and follow them where a prompt## Where to look-- [references/catalog.md](references/catalog.md): all 175 in one list, grouped by category, with an index by place.+- [references/catalog.md](references/catalog.md): all 176 in one list, grouped by category, with an index by place.- [references/01-scroll-based.md](references/01-scroll-based.md): Scroll-Based, 27 animations. Animations driven by scroll position — parallax, sticky, scrub, snap, and storytelling.- [references/02-entrance-and-exit.md](references/02-entrance-and-exit.md): Entrance & Exit, 15 animations. Element-level animations for arriving and departing — fades, slides, reveals, flips, and text staggers.- [references/03-page-transitions.md](references/03-page-transitions.md): Page Transitions, 17 animations. Full-page transitions between routes or views — crossfades, slides, portals, morphs, and the View Transitions API.- [references/04-micro-interactions.md](references/04-micro-interactions.md): Micro-Interactions, 44 animations. Short, user-triggered animations — hover, click, focus, loading states, and UI feedback patterns.- [references/05-text-typography.md](references/05-text-typography.md): Text & Typography, 19 animations. Animations specifically for type — kinetic motion, character-level effects, gradient flows, and word transformations.- [references/06-3d-advanced.md](references/06-3d-advanced.md): 3D & Advanced, 28 animations. WebGL, shaders, particles, 3D transforms, simulations, and other heavier effects.-- [references/07-ambient-background.md](references/07-ambient-background.md): Ambient & Background, 25 animations. Passive, looping effects that hold visual interest without demanding attention — gradients, particles, grain, and glows.+- [references/07-ambient-background.md](references/07-ambient-background.md): Ambient & Background, 26 animations. Passive, looping effects that hold visual interest without demanding attention — gradients, particles, grain, and glows.Each live demo address is also the technique's folder in https://github.com/matinmonshizadeh/animation-handbook; read its README (the address followed by README.md) only when the user asks how a technique works.diff --git a/skills/animation-handbook/references/07-ambient-background.md b/skills/animation-handbook/references/07-ambient-background.mdindex 81ff32cd..19b32d4a 100644--- a/skills/animation-handbook/references/07-ambient-background.md+++ b/skills/animation-handbook/references/07-ambient-background.md@@ -1,6 +1,6 @@# 07 · Ambient & Background-Passive, looping effects that hold visual interest without demanding attention — gradients, particles, grain, and glows. 25 animations from Animation Handbook, in the home page's order. Each entry gives the live demo, how it runs, what it is good for and what to avoid it on, the prompt from its page word for word, and its settings with what each does and the demo's values.+Passive, looping effects that hold visual interest without demanding attention — gradients, particles, grain, and glows. 26 animations from Animation Handbook, in the home page's order. Each entry gives the live demo, how it runs, what it is good for and what to avoid it on, the prompt from its page word for word, and its settings with what each does and the demo's values.## Contents@@ -29,6 +29,7 @@ Passive, looping effects that hold visual interest without demanding attention- [Game of Life](#game-of-life)- [Ken Burns Effect](#ken-burns-effect)- [Fire Effect](#fire-effect)+- [Lightning](#lightning)## Animated Gradient Background@@ -560,3 +561,24 @@ Add a fire effect to [the dark section or edge you want to set alight]. Keep a s- Colors: **Orange** · Blue · Green. The palette from cool to hot: orange runs from dark red to yellow and white, blue from deep navy to pale blue, green from dark green to pale yellow.- Wind: **None** · Left · Right. Left or right moves half of the heat one extra cell to that side each step, so the flames lean that way.- Sparks: **on** · off. About 24 sparks a second rise from the flames and fade within one to two and a half seconds (10 a second on phones).++## Lightning++Jagged bolts strike from the clouds and light up the sky. Best for dramatic intros.++- Live demo: https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/lightning/+- How it runs: moves by itself+- Good for: Game sites · Storm and weather themes · Dramatic intros+- Avoid on: Reading pages · Calm or health sites++**Prompt**++Add lightning to [the dark section or storm scene you want it in]. Every so often, draw a jagged bolt from the clouds to the ground on a canvas: start from a straight line, split it again and again, pushing each new midpoint sideways at random by less each time, and let thinner forks branch off. Draw a wide, faint stroke under a thin bright one for the glow; the bolt flickers once and fades within half a second. When the settings include it, light the sky softly, never more than twice a second. A click or tap strikes where the visitor points. If the visitor has reduced motion turned on, show a still bolt with no flash. Match the settings listed below.++**Settings** (the choice in bold is where the demo starts; each line ends with what the setting does, with the demo's values):++- How often: Rarely · **Sometimes** · Often. The wait between strikes, picked at random: rarely is 5 to 8 seconds, sometimes 2.6 to 4.4 seconds and often 1.6 to 2.4 seconds; never less than 1.5 seconds.+- Branches: Few · **Some** · Many. How many thinner forks split off the bolt: few is 2, some 4 and many 7.+- Bolt color: **White** · Blue · Violet. The color of the glow and of the core, which is that color mixed halfway to white: white, blue or violet.+- Lights up the sky: **on** · off. The sky turns at most 30% white with each strike and follows its flicker (15% under See inside's drawing, a steady 10% behind a still bolt, and a soft fade to 10% under reduced motion); off, only the bolt flashes.+- Rain: **on** · off. 160 thin raindrops fall at a slant (70 on phones); off, the sky is clear of rain.diff --git a/skills/animation-handbook/references/catalog.md b/skills/animation-handbook/references/catalog.mdindex f4bae37e..be5cff36 100644--- a/skills/animation-handbook/references/catalog.md+++ b/skills/animation-handbook/references/catalog.md@@ -1,6 +1,6 @@# Catalog-All 175 animations of Animation Handbook, in the home page's order and grouped by category. Each line gives the name linked to its live demo, what it does and what it is best for, and its places (the parts of a page it suits, the main one first). The category folder in the address names the file that holds its full entry, with the prompt and the settings.+All 176 animations of Animation Handbook, in the home page's order and grouped by category. Each line gives the name linked to its live demo, what it does and what it is best for, and its places (the parts of a page it suits, the main one first). The category folder in the address names the file that holds its full entry, with the prompt and the settings.Contents: [01 · Scroll-Based](#01--scroll-based) · [02 · Entrance & Exit](#02--entrance--exit) · [03 · Page Transitions](#03--page-transitions) · [04 · Micro-Interactions](#04--micro-interactions) · [05 · Text & Typography](#05--text--typography) · [06 · 3D & Advanced](#06--3d--advanced) · [07 · Ambient & Background](#07--ambient--background) · [By place](#by-place)@@ -186,7 +186,7 @@ WebGL, shaders, particles, 3D transforms, simulations, and other heavier effects## 07 · Ambient & Background-Passive, looping effects that hold visual interest without demanding attention — gradients, particles, grain, and glows. 25 animations, in [07-ambient-background.md](07-ambient-background.md).+Passive, looping effects that hold visual interest without demanding attention — gradients, particles, grain, and glows. 26 animations, in [07-ambient-background.md](07-ambient-background.md).- [Animated Gradient Background](https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/animated-gradient-background/): Colors slowly drift across a soft gradient background. Best for hero sections. Places: Backgrounds.- [Mesh Gradient Animation](https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/mesh-gradient/): Blurred blobs of color drift and melt together. Best for landing pages. Places: Backgrounds.@@ -213,6 +213,7 @@ Passive, looping effects that hold visual interest without demanding attention- [Game of Life](https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/game-of-life/): Cells live and die by their neighbors, and patterns grow. Best for tech sites. Places: Backgrounds.- [Ken Burns Effect](https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/ken-burns/): Photos slowly zoom and pan, then fade into the next. Best for hero slideshows. Places: Images & cards, Backgrounds, Page intros.- [Fire Effect](https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/fire-effect/): Flames flicker and rise as heat climbs and cools. Best for game and event pages. Places: Backgrounds, Page intros.+- [Lightning](https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/lightning/): Jagged bolts strike from the clouds and light up the sky. Best for dramatic intros. Places: Backgrounds, Page intros.## By place@@ -221,9 +222,9 @@ The home page's places, each with the animations that suit it.- **Buttons** (22): Hover State Animation, Click / Tap Ripple, Button Press Scale, Magnetic Button, Toggle / Switch Slide, Heart / Like Burst, Success Confetti, Notification Badge Pulse, Tooltip Reveal, Modal Expand, Hamburger Menu Toggle, Theme Toggle Morph, Copy to Clipboard, Star Rating, Segmented Control, Animated Gradient Border, Spotlight Hover Glow, Add-to-Cart Fly, Hold to Confirm, Expanding Search, Button Loading States, Gooey Menu- **Text** (27): Counter Animation, Text Fill on Scroll, Slide Up Reveal, Split Text Reveal, Letter-by-Letter Stagger, Word-by-Word Reveal, Rolling Numbers, Kinetic Typography, Typewriter Effect, Scramble / Glitch Text, Variable Font Morph, Text Clip-Path Reveal, Marquee / Ticker, Text Morphing, Text Gradient Animation, Outline to Fill, Enter/Exit Typography, Rotate Word Carousel, Glitch Text, Text on a Path, Wavy Text, Highlighter Sweep, Split-Flap Board, Neon Flicker, Handwriting Draw, Text Particles, Chromatic Aberration- **Images & cards** (52): Parallax Depth-of-Field, Parallax Scrolling, Reverse-Scrolling Columns, Stacking Cards, Snap Scrolling, Reveal on Scroll, Stagger Reveal, Horizontal Scroll, Zoom Into Image, Scroll Image Sequence, Scroll Velocity Skew, Clip-Path Reveal, Blur In, Flip In, Shatter Effect, Ink Spread Reveal, Shared Element Transition, Blur Transition, Dissolve Transition, FLIP Technique, Page Curl, Cube Transition, Pixelate Transition, Hover State Animation, Skeleton Loader, Modal Expand, Swipe to Dismiss, Animated Gradient Border, Spotlight Hover Glow, Image Trail, Before/After Slider, Magnifier Lens, Card Deck Swipe, 3D Model Orbit, Scroll-Driven 3D Rotation, Parallax 3D Tilt, Glassmorphism Animated, SVG Path Animation, 2.5D / Pseudo-3D, Image Distortion on Hover, Cloth / Soft-Body Simulation, 3D Flip Card, 3D Carousel, Depth-Map Photo, ASCII / Halftone, Liquid Glass, Holographic Card, Water Ripple, Audio Visualizer, Grain / Film Noise Overlay, Light Leak, Ken Burns Effect-- **Backgrounds** (43): Scroll-Driven Background Color, Cursor Follower, Neon Flicker, Canvas Particle Effect, Fluid / Liquid Simulation, Glassmorphism Animated, WebGL Shader Animation, Noise-Based Motion, Ray Marching / SDF Scene, GPGPU Particle System, Volumetric Smoke / 3D Noise, Morphing Blob, Flocking, ASCII / Halftone, 2D Physics, Infinite Zoom, Water Ripple, Audio Visualizer, Animated Gradient Background, Mesh Gradient Animation, Aurora / Northern Lights, Grain / Film Noise Overlay, Scanline Effect, Light Leak, Starfield / Space Particles, Breathing / Pulsing Glow, Ambient Ripple Effect, Floating Elements, Grid / Dot Pattern Parallax, Abstract Geometric Motion, Particle Constellation, Flow Field, Synthwave Grid, Matrix Rain, Plasma Field, Wave Layers, Snow / Rain, Fireworks, Topographic Lines, Light Rays, Game of Life, Ken Burns Effect, Fire Effect+- **Backgrounds** (44): Scroll-Driven Background Color, Cursor Follower, Neon Flicker, Canvas Particle Effect, Fluid / Liquid Simulation, Glassmorphism Animated, WebGL Shader Animation, Noise-Based Motion, Ray Marching / SDF Scene, GPGPU Particle System, Volumetric Smoke / 3D Noise, Morphing Blob, Flocking, ASCII / Halftone, 2D Physics, Infinite Zoom, Water Ripple, Audio Visualizer, Animated Gradient Background, Mesh Gradient Animation, Aurora / Northern Lights, Grain / Film Noise Overlay, Scanline Effect, Light Leak, Starfield / Space Particles, Breathing / Pulsing Glow, Ambient Ripple Effect, Floating Elements, Grid / Dot Pattern Parallax, Abstract Geometric Motion, Particle Constellation, Flow Field, Synthwave Grid, Matrix Rain, Plasma Field, Wave Layers, Snow / Rain, Fireworks, Topographic Lines, Light Rays, Game of Life, Ken Burns Effect, Fire Effect, Lightning- **Menus & forms** (20): Cover Card to Fixed Header, Scrollspy Navigation, Hide-on-Scroll Header, Slide In, Scale In / Zoom In, Focus Ring Animation, Toggle / Switch Slide, Checkmark Draw, Form Field Morph, Drawer / Panel Slide, Accordion Open/Close, Error Shake, Hamburger Menu Toggle, Star Rating, Segmented Control, Drag to Reorder, Expanding Search, Gooey Menu, Dynamic Island, Liquid Glass- **Loading & messages** (20): Progress Bar, Slide In, Bounce In, Heart / Like Burst, Success Confetti, Skeleton Loader, Shimmer Effect, Loading Spinner, Progress Animation, Checkmark Draw, Notification Badge Pulse, Error Shake, Copy to Clipboard, Toast Notification, Pull to Refresh, Rolling Numbers, Typing Indicator, Button Loading States, Dynamic Island, Breathing / Pulsing Glow-- **Page intros** (31): Fade In / Fade Out, Slide In, Slide Up Reveal, Scale In / Zoom In, Clip-Path Reveal, Curtain Reveal, Split Text Reveal, Letter-by-Letter Stagger, Word-by-Word Reveal, Blur In, Flip In, Bounce In, Rotate In, Ink Spread Reveal, Image Trail, Kinetic Typography, Typewriter Effect, Text Clip-Path Reveal, Enter/Exit Typography, Split-Flap Board, Handwriting Draw, Text Particles, SVG Path Animation, Depth-Map Photo, 2D Physics, Infinite Zoom, Wave Layers, Fireworks, Light Rays, Ken Burns Effect, Fire Effect+- **Page intros** (32): Fade In / Fade Out, Slide In, Slide Up Reveal, Scale In / Zoom In, Clip-Path Reveal, Curtain Reveal, Split Text Reveal, Letter-by-Letter Stagger, Word-by-Word Reveal, Blur In, Flip In, Bounce In, Rotate In, Ink Spread Reveal, Image Trail, Kinetic Typography, Typewriter Effect, Text Clip-Path Reveal, Enter/Exit Typography, Split-Flap Board, Handwriting Draw, Text Particles, SVG Path Animation, Depth-Map Photo, 2D Physics, Infinite Zoom, Wave Layers, Fireworks, Light Rays, Ken Burns Effect, Fire Effect, Lightning- **Scrolling** (28): Parallax Depth-of-Field, Parallax Scrolling, Reverse-Scrolling Columns, Cover Card to Fixed Header, Fly-in Fly-out Contact List, Stacking Cards, Scroll-Triggered Animation, Scrub Animation, Pin Animation, Snap Scrolling, Scrollytelling, Reveal on Scroll, Stagger Reveal, Horizontal Scroll, Sticky Section, Counter Animation, Progress Bar, Section Wipe, Zoom Into Image, Scroll Image Sequence, Smooth (Inertia) Scroll, Text Fill on Scroll, Scroll Velocity Skew, SVG Line Draw on Scroll, Scrollspy Navigation, Scroll-Driven Background Color, Hide-on-Scroll Header, Scroll-Driven 3D Rotation- **Page changes** (18): Shatter Effect, View Transitions API, Shared Element Transition, Morph Transition, Crossfade Transition, Slide Transition, Zoom Transition, Flash / Light Leak Transition, Blur Transition, Elastic Transition, Portal / Tunnel Zoom, Dissolve Transition, FLIP Technique, Circle Reveal, Overlay Wipe, Page Curl, Cube Transition, Pixelate Transition