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: content sheet for the 3D & Advanced rollout
matinc2fdde80242b
diff --git a/docs/superpowers/plans/2026-09-29-3d-content.md b/docs/superpowers/plans/2026-09-29-3d-content.mdnew file mode 100644index 00000000..1aeb55d2--- /dev/null+++ b/docs/superpowers/plans/2026-09-29-3d-content.md@@ -0,0 +1,1480 @@+# 3D & Advanced — Content Sheet++This sheet decides, page by page, how the eighteen 3D & Advanced pages present their kind, settings, words and prompt on the guided-steps page. The conversion tasks of `2026-09-29-demo-page-rollout-parallel.md` follow each section exactly, together with "How to convert a page" in `2026-09-28-demo-page-rollout-text-typography.md`, the markup for the do-it and scroll kinds in `2026-09-29-demo-page-kinds-do-and-scroll.md` (Tasks 1–3), and the lessons in the rollout's Global Constraints. Rotate In (`animations/02-entrance-and-exit/rotate-in/`) is the reference for everything a section does not mention. Text on a Path is the reference for a loop driven by animation frames, and Glitch Text and Wavy Text for "css" loops.++## The kinds in this category++| Kind | Pages |+|---|---|+| Loop, Pause (page) | 3D Model Orbit, Canvas Particle Effect, Fluid / Liquid Simulation, WebGL Shader Animation, Noise-Based Motion, Ray Marching / SDF Scene, GPGPU Particle System, Cloth / Soft-Body Simulation, Volumetric Smoke / 3D Noise, Morphing Blob |+| Loop, Pause (css) | Glassmorphism Animated, Chromatic Aberration |+| Do it | Parallax 3D Tilt (Hover it), 2.5D / Pseudo-3D (Hover it), Image Distortion on Hover (Hover it), 3D Flip Card (Click it) |+| Scroll | Scroll-Driven 3D Rotation |+| Plays once | SVG Path Animation |++A page is a loop when something on it moves by itself with no end, even if the pointer also plays a part (the pointer then appears in the help line). A page is a do-it page only when nothing moves until the visitor or Show me moves it: a do-it page has no Pause, so under reduced motion anything that moved by itself could not be stopped. Every page keeps settings, so every page has a Try it step. Of the rollout spec's special cases, only "click demos play one click and return to rest" concerns this category (3D Flip Card).++How to read a section:++- **Sets in the demo** lists one value per choice, in the same order as the choices. A Speed row sets the script's variable and the CSS variable it names.+- **Shown only when …** in the Control column means the setting's whole `div.hb-setting` gets the `hidden` attribute while it has no effect, so it also drops out of "Your settings".+- Switches in Try it keep their default in the markup (`checked` when the default is on), as on Rotate In. Only the player bar's switches (Loop, Slow motion) start unchecked.+- **Help lines.** "Default" for a loop is "It moves by itself. Pause it to look closely, or turn on slow motion to see each part of the movement." For SVG Path Animation it is Rotate In's line. The Try it help line is the kind's: loops "Change a setting and see the difference as it moves."; SVG Path Animation "Change a setting and the animation plays again."; do-it pages "Change a setting, then try it again or press Show me."; the scroll page "Change a setting, then scroll again or press Play." (on do-it and scroll pages a setting change plays nothing by itself; the shared script only replays pages that have Replay).+- **Pause (css)** means `data-hb-pause="css"` and **Pause (page)** means `data-hb-pause` without a value. The same goes for Slow motion and `data-hb-slowmo`.+- **Speed** reads Slow · Normal · Fast, and today's default stays Normal. For a duration, Slow is about 1.6 times and Fast about 0.6 times the default; for a rate (steps a frame, time multipliers), it is the other way round.+- **Swatches** use the Text & Typography palette, in this order, with each colour's name as its button's `aria-label`: Pink `#ff6f8b` · White `#f4f4f2` · Blue `#58a6ff` · Purple `#d2a8ff` · Green `#56d364` · Orange `#ffa657`. Every single colour picker here defaults to Blue `#58a6ff`, except Volumetric Smoke's, which keeps its own smoke colours (listed in its section).+- **Category line:** the pages have none today. NN is the page's position on the home page: `06.01 · 3D & Advanced` (3D Model Orbit) to `06.18 · 3D & Advanced` (3D Flip Card).+- **Titles:** four `<h1>`s differ from their home card names: Fluid / Liquid Simulation (card "Fluid Simulation"), Ray Marching / SDF Scene ("Ray Marching / SDF"), Cloth / Soft-Body Simulation ("Cloth Simulation") and Volumetric Smoke / 3D Noise ("Volumetric Smoke"). The titles stay as they are; pager links and See also links use the `<h1>`, as the page checks require.+- **Accent:** every page uses `--ui-accent:#3fd6c4`, the colour sixteen of the eighteen pages already have. 3D Flip Card changes from `#b98cff` (its card keeps its purple; see its section) and Morphing Blob, which has none, gets it.+- **Stage:** every page uses the default height. The old `--stage-h` values (620px; 480px, 420px, 400px or 380px on phones), the phone rules that made Chromatic Aberration, Glassmorphism Animated, Parallax 3D Tilt and SVG Path Animation `height:auto`, 3D Flip Card's own `clamp(360px,52vh,560px)` and Morphing Blob's `min(70vh,620px)`/`56vh` all go. A demo's own `.stage` rule keeps only what its content needs (`position:relative`, its background, flex centring, padding, `perspective`, `touch-action`, `cursor`); `flex:1`, `min-width`, `height`, `border` and `border-radius` go, because the page owns them. The shared `overflow:hidden` applies everywhere except the scroll page, whose own `overflow-y:auto` wins. `hb-dots` is used only on stages that paint one plain dark colour. On the shared stage (960×380 on a 1280×800 screen, 960×327 on a 1366×657 laptop, 707×440 on a tablet, 343×300 on a 375px phone and 288×300 on a 320px phone) three demos needed changes to fit: Glassmorphism Animated (cards in one row on phones), 2.5D / Pseudo-3D (a smaller scene) and 3D Flip Card (a card sized from the stage). Each was previewed at those sizes in headless Chrome.+- **Small text on stages:** eyebrows and small capitals get 11px and `font-weight:600`; card body text gets 13px at `rgba(255,255,255,.72)`; Georgia, Arial Narrow and italics go. These are the Ambient & Background sheet's card rules.+- **Class names:** no element on a stage may use the class names `seg` or `swatches`, because the shared stylesheet styles `.hb-page .seg` and `.swatches` for the Try it controls. No stage here uses them; the only `.seg` in this category is 3D Flip Card's old panel, whose rules go with the panel.+- **Slow motion** multiplies movements and the timers that wait for them, never holds, on every kind of page, including Show me runs (3D Flip Card's 1200ms hold stays 1200ms) and SVG Path Animation's plays (its 1200ms hold stays).++---++## Owner decisions and lessons that apply here++- **Stage text uses the site font.** Nothing here is a typing effect.+- **Pause stops at once, on every loop.** The ten page loops cancel their animation frame on `hb:pause` (the pattern below), which stops them at once. The two "css" loops are held by the shared class `hb-paused`, and neither has page timers. No loop here is a timer chain, so the Text sheet's `wait()`/`freeze()`/`thaw()` helper is not needed.+- **Reduced motion** greys out Slow motion (and Loop on SVG Path Animation), starts every loop paused, and runs nothing by itself: no Show me on arrival, no automatic scroll, and SVG Path Animation's Replay runs once as on Rotate In. Pause/Play, Show me, Reset, Play and Back to top still work when pressed. See "Reduced motion" below for what that removes from these pages.+- **Scroll and do-it pages show themselves once on arrival:** the shared script presses Show me or Play 400ms after load (not under reduced motion). The pages do nothing for this.+- **Long names in the top bar** ("Cloth / Soft-Body Simulation", "Volumetric Smoke / 3D Noise", "Image Distortion on Hover") are cut with "…" by the shared stylesheet; the pages do nothing.+- **Lessons from the Text & Typography reviews:** the `hb:pause` and `hb:input` listeners are registered at the top level of the page's inline script; the page reaches the player controls by their ids (`btn-pause`, `slow-tog`, `btn-demo`, `btn-reset`, `btn-play`, `loop-tog`), never by `data-hb-*`; a page never calls `pause()` or `play()` on a CSS keyframe animation; SVG Path Animation restarts its paths itself on every play (rebuilt hidden, a forced reflow, then drawn) and uses the pruning `later()`; Chromatic Aberration's typed text follows the typed-text rules (`trim()` decides blankness, blank falls back to the default, `textContent` only).++## Canvas and WebGL loops (Pause "page")++Ten pages move their picture with `requestAnimationFrame`: 3D Model Orbit, Canvas Particle Effect, Fluid / Liquid Simulation, WebGL Shader Animation, Noise-Based Motion, Ray Marching / SDF Scene, GPGPU Particle System, Cloth / Soft-Body Simulation, Volumetric Smoke / 3D Noise and Morphing Blob. Each follows Text on a Path; its section only adds what differs.++- The loop keeps exactly one pending frame in `raf`. `start()` returns at once when `raf` is set; otherwise it forgets the time of the last frame and requests a frame.+- The page listens for `hb:pause`, registered at the top level of its inline script. Paused: `cancelAnimationFrame(raf); raf=null;` and the picture on screen stays. Not paused: `start()`, which carries on from the current state. The page keeps its own `paused` flag from this event; the old panel's Pause button, its label code and its flag handling go.+- Each page's frame gate stays as it is today (`if(dt<16)return`, 12ms on GPGPU Particle System).+- **Clocks.** Where the movement follows a clock, the page keeps its own, which adds up each frame's time (capped, and counted afresh from each start), so Play never jumps. Where a speed multiplies the clock inside a shader (Ray Marching's camera, Volumetric Smoke's rise), the page adds up the speed-weighted step itself, so a new speed never makes the picture jump; the sections say which uniform replaces which product.+- **The first picture:** the page draws a frame at load, before the loop starts, so a loop that is paused on arrival never shows an empty stage. The sections name the call.+- **While paused,** a setting change or a resize draws the picture again so the change shows, without moving anything. This is the loop rule "changing a setting while paused shows the new setting without starting the loop again". Most pages already do this ("repaint while paused"); the sections name the function. Listeners that watched the old `aside` for `input` now watch the Try it step for `click` and `change` (choice buttons send `click`).+- **Slow motion (page):** while the switch is on, each frame moves things a third of the usual step, or adds a third of the frame's time to the page's clock. It takes effect from the next frame. Something that jumps straight to the pointer (3D Model Orbit's Follows the pointer, Fluid / Liquid Simulation's pointer blob) is left alone; something that glides after it or is pushed by it (Morphing Blob's drop, Canvas Particle Effect's dots) moves at a third of its speed like everything else.+- **Pointer while paused:** the pointer's position is still recorded, but nothing on the stage moves until Play.+- The fps badges, the counters and the shader-source panels go (the pages show no code). The "WebGL is unavailable" and "shader failed" messages stay, in the site font. Context-loss handling stays exactly as today.++The browser tool (`tools/check-pages.mjs`) runs headless Chrome with `--disable-gpu`. A scratch check in that same Chrome found WebGL, WebGL 2 and `EXT_color_buffer_float` all available, and WebGL canvases appear in its screenshots, so its loop checks (the stage moves, Pause stops it, Play starts it) can see these stages.++## Do-it pages (Show me)++Four pages: Parallax 3D Tilt, 2.5D / Pseudo-3D, Image Distortion on Hover (step 1 "Hover it") and 3D Flip Card (step 1 "Click it").++- The body is `<body class="hb" data-hb-kind="do" data-hb-autoplay>`. Step 1's title and help line are in the section. The player bar holds the Show me button, and the Reset button where the section has one, exactly as in the do-it/scroll plan (Task 2). 3D Flip Card also has Slow motion (css).+- **Show me** runs one example of the interaction, 2.5 to 3 seconds long, and returns the demo to rest. The run keeps one handle (its animation frame or its timer), so a second press restarts it cleanly and anything can stop it.+- **Stopping a run:** the page listens for `hb:input` at the top level of its inline script and stops a run that is under way, leaving the visitor in control. Hovering sends no `hb:input` (the shared script sends it for presses, keys, wheels and touches only), so on the three Hover it pages the page's own `pointermove` handler also ends a run, for trusted events only (`e.isTrusted`), before it acts on the pointer.+- **Reset** is there only where the demo keeps a state (2.5D / Pseudo-3D's camera, 3D Flip Card's turned card). Parallax 3D Tilt and Image Distortion on Hover return to rest by themselves.+- **Settings** apply at once to what they change (a depth, a colour) and play nothing; the visitor sees them at the next interaction or Show me.+- **Reduced motion:** nothing runs on arrival. Show me, Reset and the visitor's own pointer still work, so CSS rules that would stop them go (Parallax 3D Tilt's `transform:none!important`), while rules that only swap an animation for an instant change stay (3D Flip Card's face fade).++## The scroll page++Scroll-Driven 3D Rotation: `<body class="hb" data-hb-kind="scroll" data-hb-autoplay>`, step 1 "Scroll it" with the default help line "Scroll inside the box, or press Play and it scrolls for you.", and the Play and Back to top buttons from the do-it/scroll plan (Task 3). The scroller is the `.stage` itself. No Slow motion.++## Reduced motion for full-stage effects++Today almost every page handles reduced motion itself:++- script checks that draw one still frame and never start the loop (3D Model Orbit, Canvas Particle Effect, Fluid / Liquid Simulation, WebGL Shader Animation, Noise-Based Motion, Ray Marching / SDF Scene, GPGPU Particle System, Image Distortion on Hover, Cloth / Soft-Body Simulation, Volumetric Smoke / 3D Noise, Morphing Blob);+- CSS rules that remove the keyframe animations (Glassmorphism Animated, Chromatic Aberration), pin a card flat (Parallax 3D Tilt), or switch off every animation and transition on the whole page (`*{…animation:none!important;transition:none!important}` on Fluid / Liquid Simulation and Cloth / Soft-Body Simulation, which would also reach the shared page around the demo).++All of these go:++- the shared script now starts every loop paused under reduced motion, and a visitor who presses Play or Show me has asked to see the effect;+- the still-frame checks and the removal rules would stop Play or Show me from showing anything, and the browser check fails a loop that does not move after Play;+- the page-wide rules also change the shared page.++What stays: the still picture (every loop draws a full frame at load and is paused there on arrival), the scroll page's own "no easing under reduced motion" check, SVG Path Animation's rule that shows the drawing complete, and 3D Flip Card's face fade. The prompts keep their reduced-motion sentence, which is about the visitor's own site.++## Heavy effects and their phone fallbacks++CLAUDE.md asks for 60 fps on a mid-range phone, and a reduced-quality fallback on phones for heavy effects. Each section has a **Phone fallback** line: what the demo already does, or the smallest change that keeps it smooth. "On phones" means a screen 600px wide or less, which is how these demos already decide (`innerWidth<=600` or `matchMedia('(max-width:600px)')`).++The WebGL pages already draw fewer pixels on phones (a lower pixel ratio, and fewer ray steps on the two ray-marching pages), and GPGPU Particle System starts with fewer particles; those stay. Their cost is on the graphics chip, which a headless measurement cannot stand in for.++The canvas and SVG pages were measured in a scratch run: headless Chrome at 375×812 with pixel ratio 2, the CPU slowed four times (roughly a mid-range phone), the old demos with their stage set to 351×300 (a phone stage), recording how long each animation-frame callback runs and how many frames were drawn in 3 seconds (180 is a full 60 fps). The browser draws the canvas in software there, so frame counts are pessimistic, but they show where the work is.++| Page | What was measured | Callback median | Frames in 3 s |+|---|---|---|---|+| Canvas Particle Effect | today's drawing, 250 dots (today's phone default), 100px links | 140 ms | 8 |+| | today's drawing, 100 dots, 100px links | 18.5 ms | 48 |+| | today's drawing, 60 dots, 70px links | 3.7 ms | 174 |+| | links batched in six paths, 120 dots, 100px links | 2.6 ms | 91 |+| | same, on a 1000×440 laptop stage at full CPU: today's drawing, 500 dots | 13.5 ms | 96 |+| | links batched, 500 dots, laptop stage, full CPU | 3.4 ms | 148 |+| Cloth / Soft-Body Simulation | 16 × 12 points (today's phone default) | 5.2 ms | 102 |+| | 24 × 18 | 8.1 ms | 82 |+| | 40 × 30 | 29.2 ms | 43 |+| Noise-Based Motion | today's 20 columns on a phone stage (340 dots) | 8.9 ms | 98 |+| | 12 columns (120 dots) | 3.7 ms | 179 |+| | the blob | 0.8 ms | 181 |+| Morphing Blob | 4, 6 or 9 blobs, with the SVG filter | 0.5–0.8 ms | 181 |+| 2.5D / Pseudo-3D | a continuous camera pan | 0.6 ms | 176 |++Canvas Particle Effect's cost is its links: one `stroke()` per line, thousands a frame. Its section batches the links and draws a quarter of the dots on phones (the same density as on a laptop). Noise-Based Motion places its dots by columns, so a narrow phone stage gets more dots than a laptop; its section places them by spacing instead.++## Pointer and touch++- Loops that follow the pointer take its position from `pointermove`, so a tap did nothing. 3D Model Orbit, Fluid / Liquid Simulation and WebGL Shader Animation also take it from `pointerdown`; Canvas Particle Effect, which uses touch events so a finger keeps working while the page scrolls, also takes it from `touchstart`. Morphing Blob and Cloth / Soft-Body Simulation already handle touch.+- Stages keep today's `touch-action`: `pan-y` where a sideways drag moves something and an up-and-down drag should still scroll the page (3D Model Orbit, Fluid / Liquid Simulation, WebGL Shader Animation, 2.5D / Pseudo-3D), and `none` where a finger must drag (Cloth / Soft-Body Simulation, Morphing Blob, Image Distortion on Hover's canvas, Parallax 3D Tilt's card).+- None of these is a CSS `:hover` rule. The only hover-only extra is 3D Flip Card's idle tilt, which stays off on touch screens as today (`@media(hover:none)`); the flip itself works by tap and keyboard.++## Category README++`animations/06-3d-advanced/README.md` says "All demos include an FPS counter and a pause button." After the rollout neither is true (the fps badges go, and do-it and scroll pages have no Pause). It is not part of any page conversion; the lane's final fix wave should correct that sentence.++---++## 3d-model-orbit — 3D Model Orbit++- **Kind:** loop. The shape keeps turning; there is no end.+- **Description:** A lit 3D shape spins, or turns to face your pointer. Best for product views.+- **Watch it help line:** default+- **Player bar:** Pause (page) · Slow motion (page)+- **Sequence:** the WebGL loop as in the preamble (`render(ts)`, 16ms gate). Each drawn frame:+ - with Movement on Spins, `ry += SY*.01` and `rx += SX*.01*(Math.sin(ts*.0003)*.5+.5)`, as today (the forward roll speeds up and slows down over about 21 seconds);+ - with Follows the pointer, `rx = mouseNY*1.2` and `ry = mouseNX*1.5`;+ - then `draw()`.++ **The first picture:** `draw()` runs once at load, after `init()` and `resize()`. **While paused,** every setting and a resize call `draw()` (today's `if(gl&&!raf)draw()` calls, which are now true only while paused).+- **Slow motion:** while the switch is on, both spin steps are divided by 3, from the next frame. Following the pointer is not slowed.+- **Reduced motion:** `motionOk` goes, with its one-frame branch at load and the "still follows the pointer" line in the `pointermove` handler (see the preamble).+- **Stage font:** no text on the stage; the WebGL message uses the site font.+- **Stage:** only the canvas. The fps and shape badges (`.hud`) go. `hb-dots`: no (the canvas clears to its own dark blue). Default height. `touch-action:pan-y` stays.+- **Phone fallback:** none needed. The largest shape, the ring, has 1,280 triangles and each pixel gets one light calculation; the canvas already caps the pixel ratio at 2.+- **Touch:** `pointerdown` also sets the pointer's position (today only `pointermove` does), so with Follows the pointer a tap turns the shape toward the finger and a sideways drag keeps turning it.++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Shape | Choice buttons | Cube · Sphere · Ring · Pyramid | Cube | The object that is drawn and lit. | `loadGeometry('cube' / 'sphere' / 'torus' / 'tetra')`, then `rx=ry=0` (today's menu handler) |+| Movement | Choice buttons | Spins · Follows the pointer | Spins | Or it turns to face your pointer or finger. | `MODE`: `'orbit'` / `'mouse'`; also shows Speed and Tumbles as it spins only with Spins |+| Speed | Choice buttons; shown only when Movement is Spins | Slow · Normal · Fast | Normal | How fast it spins. | `SY`: 0.5 / 0.8 / 1.3 and `SX`: 0.12 / 0.2 / 0.32 (`SX` stays 0 while Tumbles as it spins is off) |++**More options**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Tumbles as it spins | Switch; shown only when Movement is Spins | on / off | on | Also rolls it forward, so the top and bottom show. | on: `SX` as Speed sets it; off: `SX = 0` |+| Distance | Choice buttons | Close · Medium · Far | Medium | How close the camera is; closer looks bigger. | `DIST`: 2.6 / 3 / 4.2 |+| Color | Swatches | Pink · White · Blue · Purple · Green · Orange | Blue | The color of the object. | `COLOR` from `#ff6f8b` / `#f4f4f2` / `#58a6ff` / `#d2a8ff` / `#56d364` / `#ffa657`, each channel ÷ 255 as today's picker handler does |+| Edges only | Switch | on / off | off | Draws the triangles' edges instead of a lit surface. | `WIRE` true / false |++- **Removed:**+ - The note.+ - The panel's Pause button. The player bar's Pause replaces it.+ - The fps and shape badges.+ - The Mode and Object menus. They become Movement and Shape.+ - The Spin X and Spin Y sliders, which could reach zero. They become Speed and Tumbles as it spins.+ - The Camera Distance slider. It becomes Distance. Close is 2.6 rather than the slider's 2.2: closer than about 2.5, the turning cube's corners leave the stage at some angles.+ - The colour picker. It becomes the Color swatches.+ - "Wireframe" becomes Edges only.+- **Good for:** Product showcases · Hero sections · Logos · 3D previews · **Avoid on:** Long reading pages · Low-power devices+- **Prompt:**++ > Add a spinning 3D object to [the product or shape you want to show]. Draw it with WebGL: store the shape as triangles and light every point with a soft base light, a direct light and a shiny highlight, so it reads as solid. Turn it around its own axis so every side comes into view, or let it turn to face the pointer, which a tap or a sideways drag should also do on touch screens. Change its size by moving the camera closer or further, not by changing the lens. If the visitor has reduced motion turned on, show the object still. Match the settings listed below.++- **README What it is:** rewritten:++ > A 3D model orbit shows a solid-looking object turning in the browser. The shape is stored as triangles, and WebGL lights every point of it with a soft base light, a direct light and a shiny highlight, so each side reads as solid as it comes into view. It is the basic pattern behind 3D product viewers, drawn here without a 3D library.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Shape | Cube | The object that is drawn: a cube, a sphere, a ring or a four-sided pyramid |+ | Movement | Spins | Spins turns it by itself; Follows the pointer turns it to face your pointer or finger |+ | Speed | Normal | How fast it spins: slow is about 17°, normal 27° and fast 45° a second |+ | Tumbles as it spins | on | Also rolls it forward, at a speed that rises and falls, so the top and bottom come into view |+ | Distance | Medium | How far away the camera is: close looks bigger, far looks smaller; the lens stays the same |+ | Color | Blue | The object's color; the lighting adds the shading and the highlight |+ | Edges only | off | Draws the edges of the triangles the shape is made of, instead of its lit surface |++- **README See also:**+ - [Scroll-Driven 3D Rotation](../scroll-driven-3d-rotation/) — scrolling turns the object instead of time+ - [Parallax 3D Tilt](../parallax-3d-tilt/) — a flat card leans in 3D toward the pointer+ - [WebGL Shader Animation](../webgl-shader-animation/) — the same WebGL setup, painting a pattern instead of a shape+- **README How it works:** unchanged+- **README Production notes:** unchanged+- **Category line:** `06.01 · 3D & Advanced`+- **Pager:** Previous: none · Next: Scroll-Driven 3D Rotation (`../scroll-driven-3d-rotation/`)++---++## scroll-driven-3d-rotation — Scroll-Driven 3D Rotation++- **Kind:** scroll. Scrolling inside the stage turns the cube; nothing moves on its own.+- **Description:** Scrolling turns a 3D cube from pose to pose. Best for product tours.+- **Step 1:** Scroll it — default help line: "Scroll inside the box, or press Play and it scrolls for you."+- **Scroller:** the `.stage` itself. Its own rule keeps `overflow-y:auto;overflow-x:hidden`, which wins over the shared `overflow:hidden`; no `data-hb-scroller`.+- **What scrolling shows:** the cube stays pinned in the middle of the stage while the stage scrolls through content four stage-heights tall. The scroll position, from the top to the end, moves the cube through four poses in turn: a quarter turn to the side, a forward tilt, growing larger, then turning round to show its back. It glides between them while Smooth follow is on. Scrolling back runs it in reverse.+- **Player bar:** Play · Back to top (the shared script runs both). No Slow motion.+- **Sequence:** unchanged: `scroll` → `onScroll()` → progress from 0 to 1 → `applyRotation(p)`, then `tick()` eases the cube toward its pose while Smooth follow is on, or `render()` sets it at once. The ResizeObserver stays. Back to top jumps the stage to its top, and the `scroll` event that causes brings the cube back to its first pose.+ - `onScroll()` loses its readout lines (the progress bar, the percentage and the Scroll Progress slider).+ - `render()` loses the Rotation X, Rotation Y and Scale readouts.+ - `applyRotation()` loses the chapter dots, name and description.+- **Reduced motion:** the page's own `reduceMotion` check stays: under reduced motion the cube follows the scroll exactly, with no gliding. The shared script scrolls nothing by itself, and Play still works. The rule `.obj-wrap{transition:none!important}` stays; `.prog-fill`'s goes with the bar.+- **Stage font:** site font. The face labels keep 11px, 1px letter spacing and their blue; "BOT" becomes "BOTTOM".+- **Stage:**+ - `.scroll-content` becomes `height:400%` and `.sticky-wrap` `height:25%` (a quarter of the content is one stage height, the pinned frame), in place of the `--stage-h` sums. Checked: on a phone stage the content is 1,192px and the pinned frame 298px, the stage's inner height.+ - The info panel (Progress, Chapter dots, Stage name and its description) and the progress bar at the top go, so `.obj-panel` fills the frame and centres the cube. The cube is 120px and up to 168px while grown, which fits the 300px phone stage.+ - `hb-dots`: yes. Default height.+- **Phone fallback:** none needed: one CSS cube of six faces.+- **Touch:** touch scrolling inside the stage works as it does today.++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Turn amount | Choice buttons | Less · Normal · More | Normal | How far each pose turns the cube. | `mult`: 6 / 10 / 16 (every pose's angles × mult ÷ 10), then `onScroll()` |+| Smooth follow | Switch | on / off | on | The cube glides to catch up instead of jumping. | `smooth-tog` checked: `applyRotation()` eases with `tick()` / sets the pose at once; then `onScroll()` |++**More options**++None: leave out the `details.hb-options` block.++- **Removed:**+ - The note.+ - The Scroll Progress slider, a readout that could not be moved, and the Rotation X, Rotation Y and Scale readouts.+ - The info panel on the stage and the progress bar.+ - Reset scroll. Back to top replaces it.+ - The Rotation Multiplier slider. It becomes Turn amount.+ - "Smooth scrub (lerp)" becomes Smooth follow.+- **Good for:** Product tours · Device launches · Landing pages · Storytelling sections · **Avoid on:** Short pages · Forms and dashboards+- **Prompt:**++ > Add a scroll-driven 3D rotation to [the product or object you want to show]. Pin the object in view while the visitor scrolls through a tall section, and turn the scroll position, from the top of the section to its end, into a series of poses: turned to one side, tilted forward, larger, then turned round to show its back. Blend smoothly between neighbouring poses so scrolling back plays it in reverse, and when the settings include it, let the object glide to catch up instead of jumping with the scroll. If the visitor has reduced motion turned on, follow the scroll exactly, with no gliding. Match the settings listed below.++- **README What it is:** rewritten:++ > Scroll-driven 3D rotation ties an object's turn to the scroll position. The object stays pinned in view while the visitor scrolls through a tall section, and each stretch of scrolling moves it on to the next pose: turned, tilted, grown, then showing its back. Scrolling back runs it in reverse, the way many product pages show off a new device.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Turn amount | Normal | How far every pose turns the cube: less is 0.6, normal 1 and more 1.6 times the planned angles; at normal the last pose shows the cube's back |+ | Smooth follow | on | The cube closes a tenth of the gap to its pose every frame, so it glides after the scroll; off, it follows the scroll exactly |++- **README See also:**+ - [3D Model Orbit](../3d-model-orbit/) — time turns the object instead of scrolling+ - [Scrub Animation](../../01-scroll-based/scrub-animation/) — scroll position drives any animation, without 3D+ - [Sticky Section](../../01-scroll-based/sticky-section/) — the pinning that keeps the object in view+- **README How it works:** unchanged+- **README Production notes:** unchanged+- **Category line:** `06.02 · 3D & Advanced`+- **Pager:** Previous: 3D Model Orbit (`../3d-model-orbit/`) · Next: Parallax 3D Tilt (`../parallax-3d-tilt/`)++---++## parallax-3d-tilt — Parallax 3D Tilt++- **Kind:** do it. The card moves only when the pointer, a finger or Show me moves it.+- **Description:** A card tilts toward your pointer, and a light slides over it. Best for cards.+- **Step 1:** Hover it — "Move your pointer over the card, or drag a finger across it."+- **Player bar:** Show me. No Reset: the card settles flat by itself when the pointer leaves. No Slow motion: the tilt follows the pointer directly.+- **Show me:** one run of 3 seconds. A pretend pointer circles the card's middle one and a half times, starting and ending at the centre and reaching 40% of the way to the edges halfway through. For progress p from 0 to 1, `r = 0.4*Math.sin(Math.PI*p)` and `a = 3*Math.PI*p`, and each animation frame calls `tilt(r*Math.cos(a), r*Math.sin(a))`. At the end it calls `onLeave()`, so the card settles flat over Return speed. A second press starts the run again from the centre.+- **Stopping a run:** on `hb:input`, and in the card's `pointermove` handler for the visitor's own (trusted) events, the run's frame is cancelled and `onLeave()` runs; the visitor's pointer then tilts the card as usual.+- **Sequence:** `onMove(e)` becomes `tilt(x, y)` (x and y from −0.5 to 0.5) plus a small `onMove(e)` that works out x and y from the event and calls it. Everything else runs as today: `pointerdown` and `pointermove` on the card tilt it, and `pointerleave` and `pointercancel` call `onLeave()`.+- **Reduced motion:** Show me does not run on arrival (the shared script). The demo's reduced-motion rule loses `transform:none!important` on the card and the orbs and `opacity:0!important` on the shine, which would stop Show me and the visitor's own tilt. What stays is `.tilt-card{transition:none!important}` and `.card-shine{transition:none!important}`, so the card snaps flat when the pointer leaves instead of easing back.+- **Stage font:** site font. `.card-h` drops Georgia and the italic and gets `font-weight:700`. `.card-over` gets 11px and `font-weight:600` (was 9px); `.card-sub` gets 13px and `rgba(255,255,255,.72)` (was 11px at .55).+- **Stage:**+ - The card stays, with its shine and its two floating orbs. Card text: over-line "Feature card"; title "Three-dimensional perspective"; line "The card leans toward your pointer, and the light follows it." (was "Mouse position maps to rotateX and rotateY. The highlight follows the virtual light source.").+ - The readout on the card and the "Move or drag the card →" line go.+ - The stage keeps `background:#060a10`, its flex centring and `perspective:var(--perspective)`. `hb-dots`: yes. Default height: the card is 240×240px on phones (30px of room above and below on the 300px stage) and 340×240px on a laptop.+- **Phone fallback:** none needed: one card moved with 3D transforms.+- **Touch:** as today: the card has `touch-action:none`, so dragging a finger over it tilts it and a tap tilts it once toward the finger.++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Tilt amount | Choice buttons | Small · Medium · Large | Medium | How far the card leans at its edges. | `maxTilt`: 8 / 15 / 25 (degrees) |+| 3D depth | Choice buttons | Subtle · Medium · Strong | Medium | Strong looks closer and more dramatic. | `--perspective`: 1500px / 1000px / 500px |+| Shine | Switch | on / off | on | A soft light follows the pointer across the card. | `shineOn` true / false (off also hides the shine at once, as today) |++**More options**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Return speed | Choice buttons | Slow · Normal · Fast | Normal | How quickly the card settles flat again. | `--reset-dur`: 650ms / 400ms / 250ms |+| Tilts away from the pointer | Switch | on / off | off | Leans the other way, as if you pressed it. | `invert` true / false |+| Grows a little | Switch | on / off | on | Lifts the card slightly while it tilts. | `scaleOn` true / false (`scale(1.04)` / `scale(1)`) |++- **Removed:**+ - The note.+ - The RotateX and RotateY readouts, and the readout on the card.+ - The card's "Move or drag the card →" line. The help line says it.+ - The Max Tilt Angle, Perspective and Reset Duration sliders. They become Tilt amount, 3D depth and Return speed.+ - "Shine highlight", "Invert tilt" and "Subtle scale on hover" become Shine, Tilts away from the pointer and Grows a little.+- **Good for:** Feature cards · Pricing cards · Portfolio tiles · Game cards · **Avoid on:** Text-heavy cards · Dense grids+- **Prompt:**++ > Add a 3D tilt to [the card you want to bring to life]. As the pointer moves over the card, rotate the card slightly around its horizontal and vertical axes according to where the pointer is, and give its container a 3D perspective so the tilt has depth. When the settings include it, move a soft light across the card with the pointer, as if it catches the light. On touch screens, dragging a finger across the card should tilt it the same way. When the pointer leaves, let the card settle back flat. If the visitor has reduced motion turned on, keep the card flat. Match the settings listed below.++- **README What it is:** rewritten:++ > A 3D tilt makes a flat card lean toward the pointer, as if you were looking at a real card from different angles. The card's container gives the scene depth, and a soft light slides across the card with the pointer, which completes the illusion. The browser's own 3D transforms do it, with no 3D library.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Tilt amount | Medium | How far the card leans at its edges: small is 8°, medium 15° and large 25°; beyond about 25° it feels unsteady |+ | 3D depth | Medium | How close the viewer seems: subtle is 1500px, medium 1000px and strong 500px; closer makes the lean more dramatic |+ | Shine | on | A soft light follows the pointer across the card, like light catching a real card |+ | Return speed | Normal | How long the card takes to settle flat when the pointer leaves: slow is 650ms, normal 400ms and fast 250ms |+ | Tilts away from the pointer | off | Leans the card away from the pointer instead, as if you were pressing on it |+ | Grows a little | on | Scales the card up by 4% while it tilts, which reads as lifting it toward you |++- **README See also:**+ - [3D Model Orbit](../3d-model-orbit/) — a real 3D object drawn with WebGL+ - [Hover State Animation](../../04-micro-interactions/hover-state/) — flat hover feedback, without the 3D+ - [2.5D / Pseudo-3D](../2-5d-pseudo-3d/) — layers at different depths move with the pointer+- **README How it works:** unchanged+- **README Production notes:** the Reduced motion bullet becomes: "**Reduced motion**: the demo does not tilt on its own, and the card snaps flat when the pointer leaves instead of easing back. In production, keep the card flat for these visitors." The rest is unchanged.+- **Category line:** `06.03 · 3D & Advanced`+- **Pager:** Previous: Scroll-Driven 3D Rotation (`../scroll-driven-3d-rotation/`) · Next: Canvas Particle Effect (`../canvas-particle-effect/`)++---++## canvas-particle-effect — Canvas Particle Effect++- **Kind:** loop. The dots drift forever.+- **Description:** Dots drift, link up when close, and dodge your pointer. Best for tech sites.+- **Watch it help line:** It moves by itself, and the dots move away from your pointer or finger. Pause it to look closely, or turn on slow motion to see each part of the movement.+- **Player bar:** Pause (page) · Slow motion (page)+- **Sequence:** the canvas loop as in the preamble (`loop(t)`, 16ms gate). Each drawn frame runs `update()` on every particle (the pointer's push or pull within 120px, the speed cap, the move, the bounce), then `draw()`.+ - **The links in six batches:** `draw()` puts every link into one of six paths by its opacity step and strokes each path once, in place of one `stroke()` per link. For a pair closer than Link distance, `k = Math.min(5, Math.floor((1 - d2/d2max) * 6))` picks the path, and path k is stroked at opacity `(k + 0.5) / 6 * 0.4` (today's opacity, `(1 - d2/d2max) * 0.4`, in six steps). The dots are drawn as today.+ - **The first picture:** `draw()` runs at load, after `spawn()`. **While paused,** every setting and a resize call `draw()` (today's `if(paused)draw()` calls).+- **Slow motion:** while the switch is on, `update()` moves each particle by a third of its velocity (`this.x += this.vx/3`, and the same for y), and the pointer's push or pull adds a third of today's amount, from the next frame. The speed cap stays.+- **Reduced motion:** the page's reduced-motion branch (paused at load with one frame drawn) goes (see the preamble).+- **Stage font:** no text on the stage.+- **Stage:** only the canvas. The fps badge goes. `hb-dots`: no (its dots would mix with the particles). Default height.+- **Phone fallback:** on screens 600px wide or less (today's `innerWidth<=600` test, which today only lowers the default to 250), the page draws a quarter of the dots: 60 · 120 · 200 (checked at each `spawn()`, so turning a phone does not leave a stale count). A phone stage has about a quarter of a laptop stage's area, so the dots stay as dense as on a laptop. With the batched links, 120 dots take 2.6ms a frame on the throttled phone, against 140ms for today's 250 dots (see the preamble).+- **Touch:** `touchstart` also sets the pointer's position (today only `touchmove` does), so a finger resting on the stage pushes the dots too. `touchend` and `touchcancel` still clear it.++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Pointer effect | Choice buttons | Push · Pull · None | Push | What your pointer or finger does to nearby dots. | `FORCE`: −0.5 / 0.5 / 0 |+| Number of particles | Choice buttons | Few · Medium · Many | Medium | More dots make more links; phones draw a quarter. | `COUNT`: 250 / 500 / 800 (60 / 120 / 200 on phones), then `spawn()` |+| Link distance | Choice buttons | None · Short · Medium · Long | Medium | How close two dots must be to join with a line. | None: `CONNECTIONS` false; Short · Medium · Long: `CONNECTIONS` true and `DIST` 70 / 100 / 150 |++**More options**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Speed | Choice buttons | Slow · Normal · Fast | Normal | Slow drifting feels calm; fast looks busy. | `SPD`: 0.5 / 0.8 / 1.3, scaling every particle's velocity by new ÷ old as today's slider does |+| Color | Swatches | Pink · White · Blue · Purple · Green · Orange | Blue | The color of the dots and lines. | `COLOR`: `#ff6f8b` / `#f4f4f2` / `#58a6ff` / `#d2a8ff` / `#56d364` / `#ffa657` |+| Trails | Switch | on / off | off | Each dot leaves a fading streak behind it. | `TRAILS` true / false |++- **Removed:**+ - The note.+ - The panel's Pause button. The player bar's Pause replaces it.+ - The fps badge and the Particles readout.+ - The Particle Count, Connect Distance, Speed and Mouse Force sliders. They become Number of particles, Link distance, Speed and Pointer effect.+ - "Show connections". It becomes Link distance's None.+ - The colour picker. It becomes the Color swatches.+ - "Particle trails" becomes Trails.+- **Good for:** Hero sections · Tech sites · Loading screens · Dark backgrounds · **Avoid on:** Long reading pages · Busy layouts+- **Prompt:**++ > Add a particle background to [the section you want it behind]. Draw small dots on a canvas, give each its own direction, and bounce them off the edges. When the settings include lines, join any two dots that come close with a thin line that fades as they move apart, so a network keeps forming and breaking. Dots near the pointer, or a finger on touch screens, can be pushed away or pulled in. Checking every pair of dots gets slow quickly, so draw a quarter as many dots on phones and stroke the lines in a few batches rather than one at a time. If the visitor has reduced motion turned on, show the dots still. Match the settings listed below.++- **README What it is:** rewritten:++ > A canvas particle effect draws hundreds of small dots on one canvas and moves them every frame. Each dot drifts in its own direction and bounces off the edges, thin lines join dots that come close, and the pointer pushes nearby dots away or pulls them in. It is the connected-dots background seen on many tech sites.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Pointer effect | Push | What the pointer or a finger does to dots within 120px: pushes them away, pulls them in, or nothing |+ | Number of particles | Medium | Few is 250, medium 500 and many 800 dots; phones draw a quarter (60, 120 and 200), which keeps the same density on a smaller stage |+ | Link distance | Medium | How close two dots must be to join with a line: short is 70px, medium 100px and long 150px; none draws no lines |+ | Speed | Normal | How fast the dots drift: slow is 0.5, normal 0.8 and fast 1.3 (the fastest dots' pixels a frame); slow feels calm, fast looks busy |+ | Color | Blue | The color of the dots and lines |+ | Trails | off | Each dot leaves a fading streak, because the canvas is only partly cleared between frames |++- **README See also:**+ - [GPGPU Particle System](../gpgpu-particle-system/) — tens of thousands of particles moved on the graphics chip+ - [Noise-Based Motion](../noise-based-motion/) — dots moved by smooth noise instead of physics+ - [Particle Constellation](../../07-ambient-background/particle-constellation/) — calmer linked dots, as a background+- **README How it works:** the Connections snippet becomes the batched version, and one sentence follows it:++ ```js+ // Every link goes into one of six paths by its opacity; each path is stroked once+ const paths = Array.from({ length: 6 }, () => new Path2D());+ for (let i = 0; i < particles.length; i++) {+ for (let j = i + 1; j < particles.length; j++) {+ const dx = particles[i].x - particles[j].x;+ const dy = particles[i].y - particles[j].y;+ const d2 = dx*dx + dy*dy;+ if (d2 < DIST * DIST) {+ const k = Math.min(5, Math.floor((1 - d2 / (DIST * DIST)) * 6));+ paths[k].moveTo(particles[i].x, particles[i].y);+ paths[k].lineTo(particles[j].x, particles[j].y);+ }+ }+ }+ paths.forEach((path, k) => {+ ctx.strokeStyle = `rgba(88, 166, 255, ${(k + 0.5) / 6 * 0.4})`;+ ctx.stroke(path);+ });+ ```++ "Stroking each link on its own costs one draw call per line, thousands a frame; grouping the links into six opacity steps draws them all in six calls, with no visible difference."+- **README Production notes:**+ - The `ctx.clearRect` bullet's "(enable "trails" toggle in the demo)" becomes "(turn on Trails in the demo)".+ - Add a bullet after "O(n²) limit": "**Phones**: the demo draws a quarter as many dots on screens 600px wide or less, which keeps a laptop's density on a smaller stage, and strokes the links in six batches instead of one call per line."+ - The rest is unchanged.+- **Category line:** `06.04 · 3D & Advanced`+- **Pager:** Previous: Parallax 3D Tilt (`../parallax-3d-tilt/`) · Next: Fluid / Liquid Simulation (`../fluid-simulation/`)++---++## fluid-simulation — Fluid / Liquid Simulation++- **Kind:** loop. The blobs drift and merge forever.+- **Description:** Blobs drift and melt into each other like liquid. Best for hero backgrounds.+- **Watch it help line:** It moves by itself, and one blob follows your pointer or finger. Pause it to look closely, or turn on slow motion to see each part of the movement.+- **Player bar:** Pause (page) · Slow motion (page)+- **Sequence:** the WebGL loop as in the preamble (`render(ts)`, 16ms gate). Each drawn frame adds the frame's time × Speed to `simT` (at most 100ms, as today) and draws.+ - **The first picture:** at load, `render(lastT+16)` runs once in place of `raf=requestAnimationFrame(render)`: it draws a frame at once and starts the loop.+ - **Pause:** on `hb:pause`, paused sets `paused=true`, cancels the frame and sets `raf=null`; not paused sets `paused=false` and `lastT=performance.now()` and requests a frame (today's Pause button code, without the label).+ - **While paused,** any `click` or `change` in Try it repaints with `render(lastT+16)` (today's `aside` `input` listener, moved to the Try it step; it does not advance `simT` while paused), and a resize repaints as today.+- **Slow motion:** while the switch is on, the clock adds a third of the frame's time (`simT += Math.min(dt,100)/1000*SPD/3`), from the next frame.+- **Reduced motion:** the page's reduced-motion branch (one still frame, paused) goes, and so does the rule `*{transition:none!important;animation:none!important}` (see the preamble).+- **Stage font:** no text on the stage; the WebGL message uses the site font.+- **Stage:** only the canvas; the fps badge goes and `.no-webgl` stays. `hb-dots`: no. Default height. `touch-action:pan-y` stays.+- **Phone fallback:** today's stays: on screens 600px wide or less the canvas caps the pixel ratio at 1.5 (2 on computers), because every pixel measures its distance to every blob.+- **Touch:** `pointerdown` also sets the pointer's position, so a tap moves the pointer blob there and a sideways drag moves it along.++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Melting | Choice buttons | A little · Medium · A lot | Medium | How far apart two blobs start to melt together. | `SMOOTH`: 0.03 / 0.08 / 0.15 |+| Number of blobs | Choice buttons | Few · Medium · Many | Medium | More blobs meet and merge more often. | `BALLS`: 3 / 5 / 8 |+| Speed | Choice buttons | Slow · Normal · Fast | Normal | Slow feels calm, like a lava lamp. | `SPD`: 0.5 / 0.8 / 1.3 |++**More options**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Blob size | Choice buttons | Small · Medium · Large | Medium | Bigger blobs touch and merge more. | `RAD`: 0.09 / 0.14 / 0.2 |+| Color | Swatches | Pink · White · Blue · Purple · Green · Orange | Blue | The color of the liquid. | `COLOR = hexToRgb(…)` of `#ff6f8b` / `#f4f4f2` / `#58a6ff` / `#d2a8ff` / `#56d364` / `#ffa657` |+| Glow | Switch | on / off | on | A soft halo around the liquid. | `GLOW` true / false |+| One blob follows the pointer | Switch | on / off | on | Moves one blob to your pointer or finger. | `MOUSE_BALL` true / false |++- **Removed:**+ - The note.+ - The panel's Pause button. The player bar's Pause replaces it.+ - The fps badge.+ - The Metaballs, Smoothness, Ball Radius and Speed sliders. They become Number of blobs, Melting, Blob size and Speed.+ - The Fluid Color picker. It becomes the Color swatches.+ - The Background Color picker. The background stays `#030810`; it framed the effect but did not change it.+ - "Mouse moves a ball" and "Glow effect" become One blob follows the pointer and Glow.+- **Good for:** Hero backgrounds · Wellness brands · Creative studios · Splash screens · **Avoid on:** Behind text · Small elements+- **Prompt:**++ > Add liquid blobs to [the section you want them in]. In a WebGL fragment shader, work out for every pixel its distance to each of a few moving circles, and blend those distances with a smooth minimum so circles that come close melt into one shape with soft necks between them, like drops of mercury. Move the circles on looping paths so they keep merging and separating; one can follow the pointer or a finger. Every pixel is checked against every circle, so draw fewer pixels on phones. If the visitor has reduced motion turned on, show the blobs still. Match the settings listed below.++- **README What it is:** rewritten:++ > This fluid effect looks like liquid but is not a real fluid simulation. A WebGL shader works out, for every pixel, how far it is from a few moving circles, and blends those distances so circles that come close melt into one smooth shape, like drops of mercury or a lava lamp. Circles that drift apart separate cleanly again.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Melting | Medium | How far apart two blobs start to melt together: a little is 0.03, medium 0.08 and a lot 0.15 of the stage height; a lot gives thick, soft necks |+ | Number of blobs | Medium | Few is 3, medium 5 and many 8 blobs; each one adds work for every pixel |+ | Speed | Normal | How fast the blobs move on their paths: slow is 0.5, normal 0.8 and fast 1.3 |+ | Blob size | Medium | Each blob's radius: small is 9%, medium 14% and large 20% of the stage height |+ | Color | Blue | The color of the liquid |+ | Glow | on | Adds a soft halo that fades out around the liquid |+ | One blob follows the pointer | on | One blob leaves its path and sits under the pointer or a finger |++- **README See also:**+ - [WebGL Shader Animation](../webgl-shader-animation/) — the same one-surface shader setup, painting patterns+ - [Morphing Blob](../morphing-blob/) — the same melting look from blurred circles, without WebGL+ - [Noise-Based Motion](../noise-based-motion/) — smooth noise moves dots and a blob instead+- **README How it works:** unchanged+- **README Production notes:** unchanged+- **Category line:** `06.05 · 3D & Advanced`+- **Pager:** Previous: Canvas Particle Effect (`../canvas-particle-effect/`) · Next: Glassmorphism Animated (`../glassmorphism-animated/`)++---++## glassmorphism-animated — Glassmorphism Animated++- **Kind:** loop. The colors behind the glass drift forever.+- **Description:** Frosted glass cards blur the colors behind them. Best for cards and panels.+- **Watch it help line:** default+- **Player bar:** Pause (css) · Slow motion (css)+- **Sequence:** the four blobs run `@keyframes blob-move` forever (over Speed, alternating direction); the Breathing card runs `blur-breath` (4s) and the Shifting card `tint-cycle` (8s). No page timers or frames. The only animations on the stage are these `@keyframes`.+- **Slow motion:** css+- **Reduced motion:** the demo's rule `.blob,.glass-card.g2,.glass-card.g3{animation:none!important}` goes, because it would stop Play. The loop starts paused, showing the blobs and cards still.+- **Stage font:** site font. `.card-title` gets `font-weight:700`; `.card-tag` gets 11px and `font-weight:600` (was 9px); `.card-body` gets 13px and `rgba(255,255,255,.72)` (was 10px at .6).+- **Stage:**+ - The four blobs and the three cards stay. The code badges at the foot of the cards go (the pages show no code). Card text, as eyebrow / title / line:+ - "Still" / "Fixed frost" / "The blur stays the same." (was "Static" / "Fixed Frost" / "Constant blur at the configured intensity. The baseline glass effect.")+ - "Animated" / "Breathing frost" / "The blur grows and fades." (was "Blur cycles 8px → 20px → 8px — the frost intensifies and recedes.")+ - "Shifting" / "Shifting tint" / "The tint keeps changing." (was "Tint Cycle" / "Frost color rotates through the palette over 8 seconds.")+ - **Phones:** today the cards wrap into one column, and the 300px stage would show only the first. Under `@media(max-width:600px)` the three cards sit in one row: `.stage{gap:8px;padding:12px;flex-wrap:nowrap}`, `.glass-card{width:auto;flex:1 1 0;min-width:0;min-height:0;padding:12px 8px;border-radius:12px;gap:6px}`, `.card-title` 13px, `.card-tag` 10px with 1px letter spacing, and `.card-body` 12px with `line-height:1.4`. Previewed: about 100×145px cards on a 375px phone and 82px wide on a 320px phone, all text inside.+ - On computers and tablets the cards stay in one row as today (180×200px).+ - `hb-dots`: no. Default height.+- **Phone fallback:** today's stays: the blobs blur 36px on phones instead of 60px. The glass blur only covers the three small cards.++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Frost | Choice buttons | Off · Light · Medium · Heavy | Medium | How strongly the glass blurs what is behind it. | Off: the stage gets `no-bf` (no blur on any card); Light · Medium · Heavy: `--blur` 6px / 12px / 20px and `no-bf` removed |+| Tint strength | Choice buttons | Faint · Medium · Strong | Medium | How much color the glass adds. | `--glass-op`: 0.06 / 0.12 / 0.25 |+| Speed | Choice buttons | Slow · Normal · Fast | Normal | How fast the colors drift behind the glass. | `--blob-spd`: 13s / 8s / 5s |++**More options**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Tint color | Swatches | Pink · White · Blue · Purple · Green · Orange | Blue | The color of the glass. | `--tint`: `rgba(r,g,b,var(--glass-op))` from `#ff6f8b` / `#f4f4f2` / `#58a6ff` / `#d2a8ff` / `#56d364` / `#ffa657`, as today's picker handler |+| Breathing frost | Switch | on / off | on | The middle card's blur grows and fades. | `.g2`'s `style.animation`: `''` / `'none'` |+| Shifting tint | Switch | on / off | on | The right card slowly changes color. | `.g3`'s `style.animation`: `''` / `'none'` |++- **Removed:**+ - The note.+ - The Blur Intensity, Glass Opacity and Blob Speed sliders. They become Frost, Tint strength and Speed.+ - The Frost Tint picker. It becomes the Tint color swatches.+ - "Animated blur (card 2)" and "Tint cycle (card 3)" become Breathing frost and Shifting tint.+ - "Disable backdrop-filter" and its Effect readout. They become Frost's Off.+ - The code badges on the cards.+- **Good for:** Cards and panels · Dashboards · Modals · Navigation bars · **Avoid on:** Plain backgrounds · Large surfaces+- **Prompt:**++ > Add frosted glass to [the cards or panels you want to style]. Give each card a see-through tinted background, blur whatever sits behind it, and add a thin light edge, so it looks like frosted glass. Put colorful shapes that drift slowly behind the cards, because glass over a plain background just looks grey. A card can also breathe, its blur growing and fading, or slowly change its tint. Blurring what is behind costs a lot, so keep the glass to small cards and blur the background shapes less on phones. If the visitor has reduced motion turned on, keep everything still. Match the settings listed below.++- **README What it is:** rewritten:++ > Glassmorphism styles a card as frosted glass: a see-through tint, a blur of whatever sits behind it, and a thin light edge. It only works when something colorful moves behind the glass, so the demo drifts soft color blobs behind three cards: one with a still frost, one whose blur breathes, and one whose tint slowly changes.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Frost | Medium | How strongly the glass blurs what is behind it: light is 6px, medium 12px and heavy 20px; off shows the cards with no blur, to compare |+ | Tint strength | Medium | How much color the glass adds: faint is 6%, medium 12% and strong 25% |+ | Speed | Normal | How long the colors behind take to drift through one path: slow is 13s, normal 8s and fast 5s |+ | Tint color | Blue | The color of the glass |+ | Breathing frost | on | The middle card's blur grows from 8px to 20px and back every 4 seconds |+ | Shifting tint | on | The right card's tint moves through blue, green, purple and orange every 8 seconds |++- **README See also:**+ - [Mesh Gradient Animation](../../07-ambient-background/mesh-gradient/) — soft color blobs drifting as a background+ - [WebGL Shader Animation](../webgl-shader-animation/) — moving color drawn on the graphics chip+ - [Modal Expand](../../04-micro-interactions/modal-expand/) — a dialog, where frosted glass often appears+- **README How it works:** unchanged+- **README Production notes:** the "Disable for performance audit" bullet becomes: "**Compare with the blur off**: the demo's Frost setting has an Off choice. If the page is noticeably faster without the blur, reconsider the design." The rest is unchanged.+- **Category line:** `06.06 · 3D & Advanced`+- **Pager:** Previous: Fluid / Liquid Simulation (`../fluid-simulation/`) · Next: WebGL Shader Animation (`../webgl-shader-animation/`)++---++## webgl-shader-animation — WebGL Shader Animation++- **Kind:** loop. The pattern keeps moving.+- **Description:** Moving color patterns computed for every pixel. Best for bold backgrounds.+- **Watch it help line:** default+- **Player bar:** Pause (page) · Slow motion (page)+- **Sequence:** the WebGL loop as in the preamble (`render(ts)`, 16ms gate). Each drawn frame adds the frame's time × Speed to `T` (at most 100ms, as today) and calls `draw()`.+ - **The first picture:** `draw()` runs once at load, after `resize()` (today `still()` draws only while paused).+ - **Pause:** on `hb:pause`, `setPaused(e.detail.paused)` (today's function, without the button label): it cancels the frame and redraws the held frame, or starts the loop.+ - **While paused,** settings call `still()`, as today.+ - The "WebGL is not available" branch keeps `fail()`; the line that disabled the panel's controls goes (the settings then change nothing, which the message explains).+- **Slow motion:** while the switch is on, `T` adds a third: `T += Math.min(dt,100)/1000*SPD/3`, from the next frame.+- **Reduced motion:** the page's `setPaused(true)` at load goes (see the preamble).+- **Stage font:** no text on the stage; `.gl-msg` uses the site font.+- **Stage:** only the canvas. The fps and pattern-name badges (`.overlay`) and the shader source panel go; `.gl-msg` stays. `hb-dots`: no. Default height. `touch-action:pan-y` stays.+- **Phone fallback:** today's stays: the pixel ratio is capped at 1.5 on phones (2 on computers).+- **Touch:** `pointerdown` also sets the pointer's position, so with Reacts to the pointer a tap bends the pattern there.++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Pattern | Choice buttons | Plasma · Waves · Cells · Kaleidoscope | Plasma | Four patterns, each one short formula. | `switchShader(0 / 1 / 2 / 3)`, then `still()` |+| Speed | Choice buttons | Slow · Normal · Fast | Normal | How fast the pattern moves. | `SPD`: 0.6 / 1 / 1.6 |++**More options**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Reacts to the pointer | Switch | on / off | off | The pattern bends around your pointer or finger. | `MOUSE_ON` true / false, then `still()` |++- **Removed:**+ - The note.+ - The panel's Pause button. The player bar's Pause replaces it.+ - The fps and pattern-name badges.+ - The Shader Preset menu and the Speed slider. They become Pattern and Speed.+ - The Hue Shift slider. Every pattern already runs through the whole rainbow, so turning the hues changed little; the shaders keep `H` at 0.+ - "Mouse interaction" becomes Reacts to the pointer.+ - "View shader source" and its panel (the pages show no code).+- **Good for:** Hero backgrounds · Music and events · Loading screens · Art pages · **Avoid on:** Behind text · Low-power devices+- **Prompt:**++ > Add a moving shader pattern to [the background or section you want it in]. Cover the area with one WebGL surface and write a fragment shader that works out the color of every pixel from its position and the time, so the whole pattern moves as the time runs on: flowing plasma, rippling waves, cells or a kaleidoscope. When the settings include it, let the pointer, or a finger on touch screens, bend the pattern near it. Draw fewer pixels on phones, and show a clear message where WebGL is not available. If the visitor has reduced motion turned on, show one still frame. Match the settings listed below.++- **README What it is:** rewritten:++ > A shader animation draws a moving picture entirely on the graphics chip. One small program runs for every pixel, every frame, and works out that pixel's color from its position and the time, so the whole pattern is made of math, with no images. Each of the four patterns in the demo is one such program.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Pattern | Plasma | Plasma adds up sine waves into flowing color; Waves bends striped color; Cells splits the plane into cells around moving points; Kaleidoscope mirrors one slice around the middle |+ | Speed | Normal | How fast time runs in the pattern: slow is 0.6, normal 1 and fast 1.6 times |+ | Reacts to the pointer | off | Each pattern bends around the pointer or a finger in its own way; in Kaleidoscope the pointer sets the number of slices |++- **README See also:**+ - [Fluid / Liquid Simulation](../fluid-simulation/) — blobs drawn by the same one-surface shader setup+ - [Ray Marching / SDF Scene](../ray-marching-sdf/) — a whole 3D scene drawn by one shader+ - [Noise-Based Motion](../noise-based-motion/) — moving patterns drawn on a 2D canvas instead+- **README How it works:** unchanged+- **README Production notes:** unchanged+- **Category line:** `06.07 · 3D & Advanced`+- **Pager:** Previous: Glassmorphism Animated (`../glassmorphism-animated/`) · Next: Noise-Based Motion (`../noise-based-motion/`)++---++## noise-based-motion — Noise-Based Motion++- **Kind:** loop. The dots sway, or the blob ripples, forever.+- **Description:** Smooth noise makes dots sway and a blob ripple. Best for calm backgrounds.+- **Watch it help line:** default+- **Player bar:** Pause (page) · Slow motion (page)+- **Sequence:** the canvas loop as in the preamble (`loop(ts)`, 16ms gate). Each drawn frame adds Speed × 0.01 to `t` and draws with `frame()`.+ - **The dot spacing:** `drawGrid()` uses `SPACE` pixels as its step, in place of `Math.max(4,Math.floor(W/GRID))`. Today the grid is set by columns across the stage, so a narrow phone stage gets a finer grid and more dots than a laptop (340 dots on a phone stage against 160 on the stage of a 1280×800 screen). Spacing in pixels keeps the same look on every screen: Medium, 48px, is today's 20 columns on a 960px laptop stage.+ - **The first picture:** `frame()` runs at load. **While paused,** every setting (Try it's `click` and `change`, in place of today's `aside` listener) and a resize call `frame()`.+- **Slow motion:** while the switch is on, each drawn frame adds a third: `t += SPD*.01/3`, from the next frame.+- **Reduced motion:** the page's reduced-motion branch goes (see the preamble).+- **Stage font:** no text on the stage.+- **Stage:** only the canvas. The fps badge goes. `hb-dots`: no (it would mix with the field of dots). Default height.+- **Phone fallback:** the spacing above: a phone stage draws 25 dots at Wide, 42 at Medium and 99 at Tight, against 340 today. Measured on the throttled phone: 120 dots take 3.7ms a frame at a full 60 fps; today's 340 take 8.9ms and draw about 33 frames a second.++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Shape | Choice buttons | Field of dots · Blob | Field of dots | A field of swaying dots, or one rippling blob. | `MODE`: `'grid'` / `'blob'`; also shows Space between dots only with Field of dots |+| Pattern size | Choice buttons | Large · Medium · Small | Medium | Large patterns sway together; small ones look busy. | `SCALE`: 0.004 / 0.008 / 0.016 |+| Speed | Choice buttons | Slow · Normal · Fast | Normal | How fast the noise moves along. | `SPD`: 0.3 / 0.5 / 0.8 |++**More options**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Wobble | Choice buttons | Small · Medium · Large | Medium | How far each dot, or the blob's edge, moves. | `AMP`: 6 / 12 / 20 (px) |+| Space between dots | Choice buttons; shown only when Shape is Field of dots | Wide · Medium · Tight | Medium | Wider spacing draws fewer dots. | `SPACE`: 64 / 48 / 32 (px) |+| Color | Swatches | Pink · White · Blue · Purple · Green · Orange | Blue | The color of the dots or the blob. | `COLOR`: `#ff6f8b` / `#f4f4f2` / `#58a6ff` / `#d2a8ff` / `#56d364` / `#ffa657` |++- **Removed:**+ - The note.+ - The panel's Pause button. The player bar's Pause replaces it.+ - The fps badge.+ - The Mode menu. It becomes Shape.+ - The Noise Scale, Speed and Amplitude sliders. They become Pattern size, Speed and Wobble.+ - The Grid Density slider. It becomes Space between dots, in pixels (see Sequence).+ - The Blob Vertices slider. 48 points already draw a smooth edge; fewer only made the blob look like a polygon.+ - The colour picker. It becomes the Color swatches.+- **Good for:** Backgrounds · Generative art · Idle and loading states · **Avoid on:** Behind text · Fast-paced screens+- **Prompt:**++ > Add noise-based motion to [the background or shape you want to bring to life]. Use smooth noise, a random value that changes gradually from place to place, instead of plain random numbers, which jump. For a field of dots, turn the noise at each dot into a direction and nudge the dot that way, then move through the noise over time so the whole field sways like grass in the wind. For a blob, push each point of its outline in or out by the noise so the edge ripples. Space the dots by distance, not by count, so phones draw fewer. If the visitor has reduced motion turned on, keep everything still. Match the settings listed below.++- **README What it is:** rewritten:++ > Noise-based motion uses smooth noise, a random value that changes gradually from place to place, to move things naturally. Plain random numbers jump about; noise drifts, so neighbouring dots move alike and nothing jerks. The demo turns it into a field of dots swaying like grass in the wind, and into a blob whose edge ripples.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Shape | Field of dots | A field of dots that sway, or one blob whose outline ripples |+ | Pattern size | Medium | How big the noise's patterns are: large moves big areas together, small looks busy and fine |+ | Speed | Normal | How fast the noise moves along: slow is 0.3, normal 0.5 and fast 0.8 |+ | Wobble | Medium | How far each dot, or the blob's edge, moves: small is 6px, medium 12px and large 20px |+ | Space between dots | Medium | The distance between dots in the field: wide is 64px, medium 48px and tight 32px; smaller stages draw fewer dots |+ | Color | Blue | The color of the dots or the blob |++- **README See also:**+ - [Canvas Particle Effect](../canvas-particle-effect/) — dots moved by simple physics instead of noise+ - [Flow Field](../../07-ambient-background/flow-field/) — particles follow a noise field and leave trails+ - [Volumetric Smoke / 3D Noise](../volumetric-smoke/) — the same kind of noise, in 3D, drawn as smoke+- **README How it works:** unchanged, plus one sentence after the wind-field snippet: "The demo sets `step` as a spacing in pixels rather than a number of columns, so a phone's smaller stage draws fewer dots at the same spacing."+- **README Production notes:** unchanged+- **Category line:** `06.08 · 3D & Advanced`+- **Pager:** Previous: WebGL Shader Animation (`../webgl-shader-animation/`) · Next: SVG Path Animation (`../svg-path-animation/`)++---++## svg-path-animation — SVG Path Animation++- **Kind:** once. The drawing draws itself and stays drawn; Loop repeats it.+- **Description:** A line drawing draws itself, stroke by stroke. Best for icons and logos.+- **Watch it help line:** default+- **Player bar:** Replay · Loop · Slow motion+- **Sequence:** every play rebuilds the paths hidden (`buildPaths()`, then each path's dash set to its length, or to minus its length with Starts from the other end, with the transition off). Path i starts 20 + i × (Speed × 0.3) ms after the play starts: a forced reflow (`path.getBoundingClientRect()`, as today), then its offset slides to 0 over Speed with Feel. 50ms after the last path finishes, the shapes fill when Fills in at the end is on (`fill-done`).+ - While Loop is on, the drawing then holds 1200ms, and Loop is checked at that moment: on, the next play starts (the drawing vanishes at once and draws again); off, it stays drawn.+ - Timers use the pruning `later()`, and every play clears them all (Rotate In's `play()`/`cycle()`). Today's `animating` flag, `run` counter and `loopTimer` go.+- **Slow motion:** multiplies Speed (each path's transition), the delay between paths (Speed × 0.3) and the timer that waits for the last path by 3. The fill's fade becomes `transition:fill var(--fill-dur) ease`: 400ms, or 1200ms while Slow motion is on. The 20ms and 50ms steps and the 1200ms hold stay.+- **Reduced motion:** the demo's rule `.draw-path{stroke-dashoffset:0!important;transition:none!important}` stays, so the drawing shows complete at once. As on Rotate In, Replay plays once.+- **Stage font:** no text on the stage.+- **Stage:** only the drawing.+ - The three preset tabs on the stage move to Try it as Drawing. The label under the drawing and the Path length readout go.+ - `svg{…}` becomes `.stage svg{…}`, so it cannot size the page's icons.+ - The stage keeps `background:#04060c`, its flex centring and 24px padding. The drawing fits: previewed at 343×300 and 288×300.+ - `hb-dots`: yes. Default height.+- **Phone fallback:** none needed.++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Drawing | Choice buttons | Icon · Signature · Logo | Icon | What is drawn: an icon, a signature or a logo. | `current`: 0 / 1 / 2 (the shared script replays) |+| Speed | Choice buttons | Slow · Normal · Fast | Normal | How long each line takes to draw. | `dur`: 2400 / 1500 / 900 (ms) |+| Line thickness | Choice buttons | Thin · Medium · Thick | Medium | Thin looks precise; thick looks bold. | `--stroke-w`: 1 / 2 / 4 |++**More options**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Feel | Choice buttons | Smooth · Gentle · Even | Smooth | Smooth slows at the end, like a hand finishing. | `ease`: `ease-out` / `ease-in-out` / `linear` |+| Line color | Swatches | Pink · White · Blue · Purple · Green · Orange | Blue | The color of the lines. | `--stroke-color`: `#ff6f8b` / `#f4f4f2` / `#58a6ff` / `#d2a8ff` / `#56d364` / `#ffa657` |+| Starts from the other end | Switch | on / off | off | Draws each line from its end back to its start. | `rev` true / false (the hidden offset is minus the length / the length) |+| Fills in at the end | Switch | on / off | off | Fills the shapes once the lines are drawn. | `fill` true / false |++- **Removed:**+ - The note.+ - Replay and Auto-loop. The player bar replaces them.+ - The preset tabs on the stage. They become Drawing.+ - The label under the drawing and the Path length readout.+ - The Draw Duration and Stroke Width sliders. They become Speed and Line thickness.+ - The Easing menu. It becomes Feel; its "Smooth" curve, nearly the same as Ease out, goes (Ease out is now Smooth).+ - The colour picker. It becomes the Line color swatches.+ - "Draw in reverse" and "Fill at end" become Starts from the other end and Fills in at the end.+ - The unused `--draw-dur` and `--draw-ease` variables.+- **Good for:** Icons · Logos · Signatures · Illustrations · **Avoid on:** Photos · Body text+- **Prompt:**++ > Add a self-drawing line to [your icon, logo or signature, drawn as SVG lines]. Measure the length of each line, hide it behind a dash exactly as long as the line, then slide the dash away so the line appears from one end to the other, as if drawn by hand. Draw several lines one after another, each starting a little after the one before. When the settings include it, fill the shapes once the lines are done. The finished drawing should be there for screen readers from the start. If the visitor has reduced motion turned on, show the drawing complete. Match the settings listed below.++- **README What it is:** rewritten:++ > An SVG path animation makes a line drawing appear as if drawn by hand. Each line is hidden behind a dash exactly as long as the line, and sliding that dash away uncovers the line from one end to the other. The whole drawing is in the page from the start, so screen readers can always find it.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Drawing | Icon | What is drawn: a house with a star, a flowing signature, or a circle logo |+ | Speed | Normal | How long each line takes to draw: slow is 2400ms, normal 1500ms and fast 900ms; each next line starts after 30% of that |+ | Line thickness | Medium | Thin is 1px, medium 2px and thick 4px; thin looks precise, thick looks bold |+ | Feel | Smooth | Smooth slows at the end, like a hand finishing a stroke; Gentle eases in and out; Even keeps one pace |+ | Line color | Blue | The color of the lines, and of the fill |+ | Starts from the other end | off | Draws each line from its end back to its start |+ | Fills in at the end | off | Fills the shapes with a light tint of the line color once the lines are drawn |++- **README See also:**+ - [Checkmark Draw](../../04-micro-interactions/checkmark-draw/) — the same technique for a success tick+ - [Text Clip-Path Reveal](../../05-text-typography/text-clip-path-reveal/) — lines of text uncovered one by one+ - [Outline to Fill](../../05-text-typography/outline-to-fill/) — hollow letters fill with color+- **README How it works:** the two snippets that wait with a double `requestAnimationFrame` wait with a forced reflow instead, as the demo does:+ - The first snippet becomes:++ ```js+ const path = document.querySelector('.draw-path');+ const length = path.getTotalLength();++ // Set up hidden state+ path.style.strokeDasharray = length;+ path.style.strokeDashoffset = length; // fully hidden+ path.style.transition = 'none';++ // Make the browser apply the hidden state, then animate+ path.getBoundingClientRect();+ path.style.transition = 'stroke-dashoffset 1500ms ease-out';+ path.style.strokeDashoffset = 0; // fully revealed+ ```++ - The second snippet becomes:++ ```js+ paths.forEach((path, i) => {+ const len = path.getTotalLength();+ path.style.strokeDasharray = len;+ path.style.strokeDashoffset = len;+ path.style.transition = 'none';++ setTimeout(() => {+ path.getBoundingClientRect(); // apply the hidden state first+ path.style.transition = 'stroke-dashoffset 700ms ease-out';+ path.style.strokeDashoffset = 0;+ }, i * 300);+ });+ ```++ The rest is unchanged.+- **README Production notes:** unchanged+- **Category line:** `06.09 · 3D & Advanced`+- **Pager:** Previous: Noise-Based Motion (`../noise-based-motion/`) · Next: Chromatic Aberration (`../chromatic-aberration/`)++---++## chromatic-aberration — Chromatic Aberration++- **Kind:** loop. The split pulses or glitches forever. Movement's default becomes Pulse; today the page starts still (Static), which a loop cannot be.+- **Description:** A word splits into red, green and blue fringes. Best for bold titles.+- **Watch it help line:** default+- **Player bar:** Pause (css) · Slow motion (css)+- **Sequence:** with Pulse, the red and blue copies run `@keyframes ca-pulse-r` and `ca-pulse-b` (2s) forever; with Glitch, `ca-glitch-r` and `ca-glitch-b` (4s, a quick jump near the end of each cycle). With None nothing moves. No page timers. The only animations on the stage are these `@keyframes`.+- **Slow motion:** css+- **Reduced motion:** the demo's rule `.ca-r,.ca-b{animation:none!important}` goes, because it would stop Play. The loop starts paused, showing the split still.+- **Stage font:** site font. `.ca-text` drops Georgia and the italic and gets `font-weight:800`.+- **Stage:**+ - Only the word. The red, green and blue copies get `aria-hidden="true"`, so screen readers read the word once, from the see-through base copy.+ - Typed text: `trim()` decides blankness, blank falls back to "PRISM", and the text is set with `textContent` (today's `setText()`).+ - `hb-dots`: yes. `hb-grow`, because typed text can wrap.+- **Phone fallback:** none needed: three blended text layers.++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Movement | Choice buttons | Pulse · Glitch · None | Pulse | Pulse breathes in and out; Glitch jumps now and then. | `#ca-wrap`'s class: `pulse` / `glitch` / neither, then `applyOffset()` |+| Color split | Choice buttons | Small · Medium · Large | Medium | How far the red and blue copies sit from the word. | `amt`: 2 / 4 / 8 (px), then `applyOffset()` |+| Direction | Choice buttons | Sideways · Slanted · Up and down | Slanted | Which way the red and blue copies move apart. | `angle`: 0 / 30 / 90 (degrees), then `applyOffset()` |++**More options**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Soft color edges | Switch | on / off | off | Blurs the colored copies, like a real lens. | `--ca-blur`: 2px / 0px |+| Your text | Text (`input.hb-text`) | any text | PRISM | Short words work best. | `setText(txtIn.value.trim())` on input (blank falls back to "PRISM") |++- **Removed:**+ - The note.+ - The Intensity, Direction Angle and Channel Blur sliders. They become Color split, Direction and Soft color edges.+ - "Blur offset channels". It folds into Soft color edges.+ - The Animation Mode menu. It becomes Movement.+ - The Text box becomes Your text.+- **Good for:** Bold titles · Music and games · Error pages · **Avoid on:** Body text · Light backgrounds+- **Prompt:**++ > Add a chromatic aberration effect to [your headline or short word]. Stack three copies of the text in pure red, green and blue, blend them so that where they overlap they add up to white, and shift the red and blue copies in opposite directions so colored fringes appear at the letters' edges, like a cheap camera lens. The split can breathe in and out, or jump now and then like a glitch. It only works on a dark background. Screen readers should read the text once, not three times. If the visitor has reduced motion turned on, keep the copies still. Match the settings listed below.++- **README What it is:** rewritten:++ > Chromatic aberration copies a flaw of cheap lenses, where red, green and blue light land in slightly different places and leave colored fringes at the edges. The demo stacks a red, a green and a blue copy of a word, which add up to white where they overlap, and shifts the red and blue copies apart. The split can breathe in and out or glitch.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Movement | Pulse | Pulse widens and narrows the split every 2 seconds; Glitch jumps it briefly every 4 seconds; None keeps it still |+ | Color split | Medium | How far the red and blue copies sit from the word: small is 2px, medium 4px and large 8px; above about 6px the word gets hard to read |+ | Direction | Slanted | Sideways splits the colors left and right; Slanted splits them at 30°; Up and down splits them vertically |+ | Soft color edges | off | Blurs the red and blue copies by 2px, which looks more like a lens than a digital shift |+ | Your text | PRISM | The word that splits |++- **README See also:**+ - [Glitch Text](../../05-text-typography/glitch-text/) — red and cyan strips tear across a word+ - [WebGL Shader Animation](../webgl-shader-animation/) — shaders, which can split colors pixel by pixel+ - [Scramble / Glitch Text](../../05-text-typography/scramble-text/) — random symbols lock into the real text+- **README How it works:** unchanged+- **README Production notes:** unchanged+- **Category line:** `06.10 · 3D & Advanced`+- **Pager:** Previous: SVG Path Animation (`../svg-path-animation/`) · Next: 2.5D / Pseudo-3D (`../2-5d-pseudo-3d/`)++---++## 2-5d-pseudo-3d — 2.5D / Pseudo-3D++- **Kind:** do it. Nothing moves until the pointer, a finger or Show me moves the camera.+- **Description:** Flat layers slide by different amounts, faking depth. Best for hero scenes.+- **Step 1:** Hover it — "Move your pointer across the scene, or drag a finger sideways."+- **Player bar:** Show me · Reset. No Slow motion: the camera follows the pointer directly.+- **Show me:** one run of 3 seconds: the camera sweeps right, back through the middle, left and back, dipping a little, then rests in the middle. For progress p from 0 to 1 and the camera's position when the run starts (`x0 = mx`, `y0 = my`), each animation frame calls `applyParallax(x0*(1-p) + 0.45*Math.sin(2*Math.PI*p), y0*(1-p) + 0.2*Math.sin(Math.PI*p))`. At the end `mx = my = 0`. A second press starts again from where the camera is.+- **Stopping a run:** on `hb:input`, and in the stage's `pointermove` handler for the visitor's own (trusted) events, the run's frame is cancelled and the camera stays where it is; the visitor's pointer moves it from then on.+- **Reset:** stops a run, sets `mx = my = 0` and calls `applyParallax(0,0)` (today's Reset camera, without the readout).+- **Sequence:** the Mode menu and `autoLoop()` go (Auto-pan becomes Show me). The pointer moves the camera as today (`pointermove` → `applyParallax(mx,my)`), and the camera stays where the pointer leaves it, as today.+- **Reduced motion:** Show me does not run on arrival. The page's `motionOk` branch goes with the Mode menu. The rule `.scene-inner{transition:none!important}` can stay (it changes nothing).+- **Stage font:** site font. The layer labels get 11px and `font-weight:600` (were 8px) and read "moves 5%" to "moves 100%" (were "depth 0.05" to "depth 1.0"). Their stagger becomes `top = 4 + i*16` px so the larger labels do not overlap, and `MAX_PAN` becomes 35 (half the largest Camera movement; the slider it read goes).+- **Stage:**+ - The seven layers, the custom cursor ring and the labels stay. `cursor:none` and `touch-action:pan-y` stay.+ - **A smaller scene.** The scene was drawn for a 620px stage: on the shared 300–440px stage the mountains' peaks are cut off and the moon hides behind the hills. Its fixed sizes shrink to about 0.7 (the hills to 0.6), previewed at the laptop, tablet and both phone stages with the peaks, the moon and the tree line all in view:+ - `.mtns-far` (inline style): height 200px → 140px;+ - the six mountains' inline `border-width:0 W H`: 100/160 → 70/112, 80/120 → 56/84, 120/180 → 84/126, 90/140 → 63/98, 110/160 → 77/112, 70/100 → 49/70;+ - `.hills-wrap` 180px → 108px, and the second one's inline 130px → 78px;+ - `.fog` 80px → 56px; `.moon` 50px → 36px;+ - `addTrees('trees-far',14,25,…)` and `addTrees('trees-near',8,39,…)` (were 36 and 56).+ - `hb-dots`: no. Default height.+- **Phone fallback:** none needed: seven layers moved with transforms (a continuous pan measured 0.6ms a frame on the throttled phone).+- **Touch:** `pointerdown` also sets the camera (today only `pointermove` does), so a tap moves it; a sideways drag keeps moving it.++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Camera movement | Choice buttons | Small · Medium · Large | Medium | How far the nearest layer moves; far ones move less. | `strength`: 20 / 40 / 70 (px), then `applyParallax(mx,my)` unless a run is under way |+| Layer labels | Switch | on / off | off | Shows how much each layer moves. | the `.depth-label`s' `display`: `block` / `none` |++**More options**++None: leave out the `details.hb-options` block.++- **Removed:**+ - The note.+ - The Mode menu. Auto-pan becomes Show me.+ - The Camera Strength slider. It becomes Camera movement.+ - "Show depth labels" becomes Layer labels.+ - The Mouse X and Layers readouts.+ - "↺ Reset camera". The player bar's Reset replaces it.+- **Good for:** Hero scenes · Illustrations · Game sites · Landing pages · **Avoid on:** Photos · Content-heavy pages+- **Prompt:**++ > Add a 2.5D parallax scene to [the illustration or hero you want to give depth]. Split the picture into flat layers, from a far sky to the near ground, and when the pointer moves, shift every layer the opposite way by an amount that grows with how near it is: the sky barely moves and the ground moves the most, so the flat picture seems deep. Make each layer a little wider than the frame so no edge shows. On touch screens, dragging a finger should move the scene the same way. If the visitor has reduced motion turned on, keep the layers still. Match the settings listed below.++- **README What it is:** rewritten:++ > 2.5D fakes depth with flat layers. The picture is split into layers at different distances, and when the camera moves, near layers slide further than far ones, as the view from a train window does. The same trick gave old cartoons and video games their sense of depth.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Camera movement | Medium | How far the nearest layer moves as the pointer crosses the scene: small is 20px, medium 40px and large 70px; the farthest layer moves 5% of that |+ | Layer labels | off | Labels each layer with the share of the camera movement it follows, from 5% for the sky to 100% for the ground |++- **README See also:**+ - [Parallax Depth-of-Field](../../01-scroll-based/parallax-depth-of-field/) — the same layered depth, driven by scrolling+ - [Parallax 3D Tilt](../parallax-3d-tilt/) — one card leans toward the pointer+ - [Scroll-Driven 3D Rotation](../scroll-driven-3d-rotation/) — scrolling moves a 3D object+- **README How it works:** the sentence "For an **auto-pan** camera, drive the norm values with sine:" and its snippet become "For **Show me**, the demo drives the same layers with a three-second sweep instead of the pointer, ending in the middle:" and:++ ```js+ function sweep(now) { // start = performance.now() when Show me is pressed+ const p = Math.min(1, (now - start) / 3000);+ const normX = 0.45 * Math.sin(2 * Math.PI * p);+ const normY = 0.2 * Math.sin(Math.PI * p);+ LAYERS.forEach(({ el, depth }) => {+ el.style.transform = `translate(${-normX * STRENGTH * depth}px, ${-normY * STRENGTH * depth * 0.4}px)`;+ });+ if (p < 1) requestAnimationFrame(sweep);+ }+ ```++ The rest is unchanged.+- **README Production notes:** unchanged+- **Category line:** `06.11 · 3D & Advanced`+- **Pager:** Previous: Chromatic Aberration (`../chromatic-aberration/`) · Next: Ray Marching / SDF Scene (`../ray-marching-sdf/`)++---++## ray-marching-sdf — Ray Marching / SDF Scene++- **Kind:** loop. The camera keeps circling the shapes.+- **Description:** A 3D scene drawn only from formulas, circled by a camera. Best for art pages.+- **Watch it help line:** default+- **Player bar:** Pause (page) · Slow motion (page)+- **Sequence:** the WebGL loop as in the preamble (`render(ts)`, 16ms gate).+ - **The clock:** the page keeps its own clock, `curT`, which adds each frame's time (at most 50ms, and nothing on the first frame after a start), in place of `(ts-startT)/1000`. Each drawn frame calls `draw(curT)`.+ - **The camera:** the page also keeps the camera's angle, `camA`, which adds the same step × Camera speed. The shader takes `uniform float uCamAng` and uses `float angle=uCamAng;` in place of `uT*uCamSpd`, so a new Camera speed never makes the camera jump (today the angle is the time × the speed, so any change of speed moves the camera at once).+ - `start()` and `stop()` stay, without `startT`. **The first picture:** `draw(0)` at load. **While paused,** settings call `refresh()` and a resize redraws, as today.+- **Slow motion:** while the switch is on, the clock and the camera's angle add a third of each frame's step, from the next frame.+- **Reduced motion:** the page's reduced-motion branch goes (see the preamble).+- **Stage font:** no text on the stage; `.fallback` uses the site font.+- **Stage:** only the canvas. The fps and scene badges and the shader source panel go; `.fallback` stays. `hb-dots`: no. Default height.+- **Phone fallback:** today's stays: on screens 600px wide or less the canvas draws at 0.7 of the stage's CSS size (up to 1.5 times on computers), and Detail takes two thirds of the steps there (16 · 32 · 64 in place of 24 · 48 · 96; today phones start at 32).++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Scene | Choice buttons | Blend · Cut-out · Endless | Blend | Shapes that melt, shapes cut from shapes, or endless copies. | `SCENE`: 0 / 1 / 2, then `refresh()` |+| Camera speed | Choice buttons | Slow · Normal · Fast | Normal | How fast the camera circles the shapes. | `CAM_SPD`: 0.35 / 0.6 / 1 |+| Soft shadows | Switch | on / off | off | Real soft shadows; costly, so best left off on phones. | `SHADOW` true / false, then `refresh()` |++**More options**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Corner shading | Switch | on / off | on | Darkens creases where surfaces meet. | `AO` true / false, then `refresh()` |+| Detail | Choice buttons | Low · Medium · High | Medium | More steps find thin edges; phones use fewer. | `MAX_STEPS`: 24 / 48 / 96 (16 / 32 / 64 on phones), then `refresh()` |+| Step count view | Switch | on / off | off | Colors each pixel by how many steps it took. | `DEBUG` true / false, then `refresh()` |++- **Removed:**+ - The note.+ - The panel's Pause button. The player bar's Pause replaces it.+ - The fps and scene badges.+ - The Scene menu. It becomes Scene.+ - The Camera Speed slider, which could reach zero. It becomes Camera speed; Pause now stops the camera.+ - The Max March Steps slider. It becomes Detail.+ - "Ambient occlusion", "Soft shadows (GPU-heavy)" and "Debug: march steps as color" become Corner shading, Soft shadows and Step count view.+ - "View shader source" and its panel (the pages show no code).+- **Good for:** Art pages · Hero visuals · Tech demos · **Avoid on:** Behind text · Low-power devices+- **Prompt:**++ > Add a ray-marched 3D scene to [the section you want it in]. Draw the whole scene in a fragment shader, with no 3D models: describe each shape as a formula that gives the distance to its surface, then for every pixel step a ray forward by that distance until it touches a surface, and light that point. Formulas let shapes melt together, be carved out of each other or repeat without end, while a camera circles them. Every pixel does a lot of work, so draw fewer pixels and take fewer steps on phones. If the visitor has reduced motion turned on, show one still frame. Match the settings listed below.++- **README What it is:** rewritten:++ > Ray marching draws a 3D scene without any 3D models. Each shape is a formula that gives the distance to its surface, and for every pixel the shader steps a ray forward by that distance until it touches something, then lights that point. Because the shapes are formulas, they can melt together, be carved out of each other or repeat forever.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Scene | Blend | Blend melts a sphere, a box and a ring together; Cut-out carves a box out of a sphere, with a small ball inside; Endless repeats a carved box across the floor without end |+ | Camera speed | Normal | How fast the camera circles the shapes: once in about 18 seconds at slow, 10 at normal and 6 at fast |+ | Soft shadows | off | Casts a second ray toward the light from every surface point, for soft shadows; the most costly option |+ | Corner shading | on | Darkens creases and corners where surfaces meet, by testing a few points just above each surface |+ | Detail | Medium | The most steps a ray may take: low is 24, medium 48 and high 96; phones take two thirds as many |+ | Step count view | off | Colors each pixel by how many steps its ray took: edges and near misses take the most |++- **README See also:**+ - [Volumetric Smoke / 3D Noise](../volumetric-smoke/) — rays that add up smoke instead of stopping at a surface+ - [WebGL Shader Animation](../webgl-shader-animation/) — simpler shaders on the same setup+ - [Fluid / Liquid Simulation](../fluid-simulation/) — the same melting of shapes, in 2D+- **README How it works:** unchanged+- **README Production notes:** unchanged+- **Category line:** `06.12 · 3D & Advanced`+- **Pager:** Previous: 2.5D / Pseudo-3D (`../2-5d-pseudo-3d/`) · Next: GPGPU Particle System (`../gpgpu-particle-system/`)++---++## gpgpu-particle-system — GPGPU Particle System++- **Kind:** loop. The particles flow forever.+- **Description:** Tens of thousands of particles flow on the graphics chip. Best for hero effects.+- **Watch it help line:** default+- **Player bar:** Pause (page) · Slow motion (page)+- **Sequence:** the WebGL 2 loop as in the preamble (`render(ts)`, 12ms gate).+ - `drawFrame(t)` splits into `physics(t)` (the physics pass and the texture swap) and `paint(t)` (the drawing pass). Each drawn frame runs both.+ - The page keeps its own clock, `simT` (each frame's time, at most 50ms, and nothing on the first frame after a start), in place of `(ts-startT)/1000`.+ - **The first picture:** `physics()` and `paint()` run once at load (today's `resize()` draws only while paused).+ - **While paused,** a setting or a resize calls `paint()` only. Today's `refresh()` also ran a physics step, which moved the particles a little while paused.+- **Slow motion:** the physics shader gets `uniform float uStep` (1, or 1/3 while Slow motion is on), from the next frame. Every change of velocity is multiplied by `uStep` (the four behaviours' pushes, and the vortex's and orbit's inward pulls), the damping becomes `pow(.985,uStep)`, and the move becomes `x+=vx*uStep; y+=vy*uStep`. So every particle moves a third as far each frame while its speed and the shapes the particles form stay the same. The clock adds a third of each frame's time.+- **Reduced motion:** the page's reduced-motion branch goes (see the preamble).+- **Stage font:** no text on the stage. The WebGL 2 message uses the site font and reads "This demo needs WebGL 2, which this browser does not offer. Try a recent Chrome, Firefox or Safari.", set with `textContent` (was "WebGL2 required for GPGPU texture ping-pong." with a `<br>`).+- **Stage:** only the canvas. The fps, count and behaviour badges go; `.no-wgl2` stays. `hb-dots`: no. Default height.+- **Phone fallback:** today's stays: on screens 600px wide or less the page starts with 16,000 particles (today's `SMALL` default). At load it gives 16,000 the `on` class and `aria-pressed="true"` (and takes them from 65,000) itself, before the shared script reads the settings. The visitor can still pick more.++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Movement | Choice buttons | Flow · Swirl · Attract · Orbit | Flow | The rule every particle follows. | `BEHAVIOR`: 0 / 1 / 2 / 3 |+| Number of particles | Choice buttons | 16,000 · 65,000 · 100,000 | 65,000 (16,000 on phones) | Phones start with 16,000; more can be slow there. | `TEX_N`: 128 / 256 / 320, then `initTex(TEX_N)` |+| Speed | Choice buttons | Slow · Normal · Fast | Normal | How hard the rule pushes the particles. | `SPD`: 0.35 / 0.6 / 1 |++**More options**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Color | Choice buttons | One color · By speed · Shifting | One color | One color, by speed, or slowly shifting colors. | `COLOR_MODE`: 0 / 1 / 2 |+| Trails | Switch | on / off | off | Each particle leaves a fading streak. | `TRAILS` true / false |++- **Removed:**+ - The note.+ - The panel's Pause button. The player bar's Pause replaces it.+ - The fps, count and behaviour badges, and the Texture size and Physics pass readouts.+ - The Particle Count, Behavior and Color Mode menus. They become Number of particles, Movement and Color.+ - The Speed slider. It becomes Speed.+ - "Motion trails" becomes Trails.+- **Good for:** Hero effects · Data art · Launch pages · **Avoid on:** Behind text · Low-power devices+- **Prompt:**++ > Add a GPU particle system to [the section you want it in]. Keep every particle's position and speed in a floating-point texture, one pixel per particle, and move them all at once in a shader that reads last frame's texture and writes the next, swapping the two each frame. Then draw each particle as a tiny point, following a flowing field, a swirl, a pull to the middle or an orbit. That keeps tens of thousands of particles smooth. Start with far fewer on phones, and show a clear message where WebGL 2 is missing. If the visitor has reduced motion turned on, show one still frame. Match the settings listed below.++- **README What it is:** rewritten:++ > A GPU particle system moves tens of thousands of particles on the graphics chip instead of in JavaScript. Every particle's position and speed is stored as one pixel of a texture, and a shader reads last frame's texture and writes the next one, all at once. A second step draws each particle as a tiny point.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Movement | Flow | Flow follows a shifting field of currents; Swirl circles the middle; Attract pulls everything toward the middle; Orbit sweeps the particles round in rings |+ | Number of particles | 65,000 | 16,000, 65,000 or 100,000 particles, one pixel each of a texture 128, 256 or 320 pixels square; phones start with 16,000 |+ | Speed | Normal | How hard the rule pushes each frame: slow is 0.35, normal 0.6 and fast 1 |+ | Color | One color | One blue, a color from each particle's speed, or colors that slowly shift |+ | Trails | off | Fades the last picture instead of clearing it, so each particle leaves a streak |++- **README See also:**+ - [Canvas Particle Effect](../canvas-particle-effect/) — hundreds of particles moved in JavaScript+ - [Fluid / Liquid Simulation](../fluid-simulation/) — a shader that melts blobs together+ - [WebGL Shader Animation](../webgl-shader-animation/) — shaders that paint every pixel+- **README How it works:** the physics snippet matches the new shader: after `uniform int uBehavior;` add `uniform float uStep; // 1, or 1/3 in slow motion`; the vortex's four velocity lines each end in `* uStep`; the damping line becomes `vx *= pow(0.985, uStep); vy *= pow(0.985, uStep); // damping`; and the move becomes `x += vx * uStep; y += vy * uStep;`. The rest is unchanged.+- **README Production notes:** unchanged+- **Category line:** `06.13 · 3D & Advanced`+- **Pager:** Previous: Ray Marching / SDF Scene (`../ray-marching-sdf/`) · Next: Image Distortion on Hover (`../image-distortion-hover/`)++---++## image-distortion-hover — Image Distortion on Hover++- **Kind:** do it. The picture bends only where the pointer, a finger or Show me touches it.+- **Description:** The picture ripples and bends around your pointer. Best for portfolio images.+- **Step 1:** Hover it — "Move your pointer over the picture, or drag a finger across it."+- **Player bar:** Show me. No Reset: the distortion fades by itself. No Slow motion.+- **Show me:** one run of 3 seconds: a pretend pointer crosses the picture from left to right along a gentle S, then lets go, and the distortion fades over Fade-out speed. The render loop drives it: while a run is under way, each frame sets `mouseX = W*(0.2 + 0.6*p)` and `mouseY = H*(0.5 + 0.18*Math.sin(2*Math.PI*p))` (backing-store pixels, p from 0 to 1), `active = true` and `amp = 1`; when p reaches 1, `active = false` and the run ends. A second press starts again from the left.+- **Stopping a run:** on `hb:input`, and in the stage's `track()` handler for the visitor's own (trusted) events, the run ends and `active = false`; `track()` then follows the visitor's pointer as today.+- **Sequence:** the render loop runs all the time, as today when not paused: `paused`, `poke()` and the Pause button go (a do-it page has no Pause).+ - **The picture stands still:** the shader's `uT` stays 0. Today the pattern drifts slowly by itself; a real image would not, and a do-it page moves only when the visitor or Show me moves it.+ - `phase` and the fade (`amp`) run as today.+- **Reduced motion:** the page's reduced-motion branch goes. With the picture still, nothing on the stage moves until the visitor or Show me does.+- **Stage font:** no text on the stage; `.fallback` uses the site font.+- **Stage:** only the canvas. The fps badge and the shader source panel go. `touch-action:none` on the canvas stays. `hb-dots`: no. Default height.+- **Phone fallback:** today's stays: the pixel ratio is capped at 1.5 on phones (2 on computers).+- **Touch:** as today: dragging a finger bends the picture under it, and lifting it lets the distortion fade.++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Effect | Choice buttons | Ripple · Push · Liquid · Pixels | Ripple | Rings, a bulge, a liquid swirl, or big square pixels. | `TYPE`: 0 / 1 / 2 / 3; also shows Moving ripples only with Ripple |+| Strength | Choice buttons | Gentle · Medium · Strong | Medium | How far the picture bends. | `STR`: 4 / 8 / 14 |+| Size | Choice buttons | Small · Medium · Large | Medium | How wide an area around the pointer bends. | `RAD`: 0.15 / 0.25 / 0.4 |++**More options**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Fade-out speed | Choice buttons | Slow · Normal · Fast | Normal | How fast the picture settles after the pointer leaves. | `DECAY`: 0.3 / 0.5 / 0.8 |+| Moving ripples | Switch; shown only when Effect is Ripple | on / off | on | The rings keep moving outward. | `ANIMATE` true / false |++- **Removed:**+ - The note.+ - The panel's Pause button. A do-it page has none; the loop simply keeps drawing.+ - The fps badge.+ - The Distortion Type menu. It becomes Effect.+ - The Strength, Radius and Decay Speed sliders. They become Strength, Size and Fade-out speed.+ - "Animate ripple over time" becomes Moving ripples.+ - "View shader source" and its panel (the pages show no code).+ - The pattern's slow drift.+- **Good for:** Portfolio images · Gallery tiles · Hero images · Product photos · **Avoid on:** Small thumbnails · Images with text+- **Prompt:**++ > Add a hover distortion to [the image you want to react]. Draw the image with a WebGL shader and, in a circle around the pointer, read each pixel from a slightly shifted spot, so the picture seems to ripple, bulge, swirl like liquid or break into squares there while the image itself never changes. The bending fades out smoothly after the pointer leaves. On touch screens, dragging a finger across the image should do the same. If the visitor has reduced motion turned on, keep the image still. Match the settings listed below.++- **README What it is:** rewritten:++ > Image distortion on hover bends a picture around the pointer. A WebGL shader draws the image, and near the pointer each pixel is read from a slightly shifted spot, so the picture seems to ripple, bulge, swirl or break into squares there, while the image itself never changes. The bending fades away after the pointer leaves.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Effect | Ripple | Ripple sends rings out from the pointer; Push bulges the picture outward; Liquid swirls it; Pixels breaks it into squares |+ | Strength | Medium | How far the picture bends: gentle is 4, medium 8 and strong 14; stronger looks more dramatic but harder to read |+ | Size | Medium | How wide an area bends: small is 15%, medium 25% and large 40% of the picture's height |+ | Fade-out speed | Normal | How fast the bending fades after the pointer leaves: each second it loses about a quarter of its strength at slow, two fifths at normal and half at fast |+ | Moving ripples | on | With Ripple, the rings keep moving outward while the pointer rests; off, they stand still |++- **README See also:**+ - [WebGL Shader Animation](../webgl-shader-animation/) — the same shader setup, painting patterns+ - [Parallax 3D Tilt](../parallax-3d-tilt/) — a card leans toward the pointer instead of bending+ - [Fluid / Liquid Simulation](../fluid-simulation/) — a liquid look that follows the pointer+- **README How it works:** unchanged, plus one sentence after the procedural-texture snippet: "In the demo the pattern stands still, as a real image would: its time value stays at 0, and only the distortion moves."+- **README Production notes:** unchanged+- **Category line:** `06.14 · 3D & Advanced`+- **Pager:** Previous: GPGPU Particle System (`../gpgpu-particle-system/`) · Next: Cloth / Soft-Body Simulation (`../cloth-simulation/`)++---++## cloth-simulation — Cloth / Soft-Body Simulation++- **Kind:** loop. The cloth sways in the wind forever; you can drag it.+- **Description:** A cloth sways in the wind, and you can drag it around. Best for playful pages.+- **Watch it help line:** It moves by itself. Drag the cloth to pull it, or pause it to look closely.+- **Player bar:** Pause (page) · Reset. No Slow motion: each frame is one physics step, and slowing the steps would change how stiff the cloth is.+- **Reset:** hangs a fresh cloth (`initCloth()`, today's Reset cloth). While paused it shows the fresh cloth still.+- **Sequence:** the canvas loop as in the preamble (`loop(ts)`, 16ms gate). Each drawn frame runs `update()`, then `draw()`, as today.+ - **The first picture:** `initCloth()` draws the cloth at load (today it draws only while paused).+ - **While paused,** Hangs from and Detail show a fresh cloth, Shows the points redraws, and Wind, Gravity and Stiffness show at the next Play (they change how it moves).+ - **Dragging does nothing while paused:** the `if(paused){update();draw();}` line in the `pointermove` handler goes, so a paused cloth stays still.+ - The resize handler rebuilds the cloth, as today.+- **Reduced motion:** the page's `paused=matchMedia(…).matches` start goes, and so does the rule `*,*::before,*::after{animation:none!important;transition:none!important}` (see the preamble).+- **Stage font:** no text on the stage.+- **Stage:** only the canvas. The fps badge goes. `touch-action:none` on the stage and the canvas stays (dragging needs it). `hb-dots`: no. Default height.+- **Phone fallback:** today's stays: on screens 600px wide or less the page starts at Low detail (16 × 12 points). At load it gives Low the `on` class and `aria-pressed="true"` (and takes them from Medium) itself, before the shared script reads the settings. Measured on the throttled phone: Low takes 5.2ms a frame, Medium 8.1ms and High 29ms.+- **Touch:** as today: Pointer Events with pointer capture; a finger drags the nearest point within 30px.++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Hangs from | Choice buttons | Two corners · Top edge · One corner · Nothing | Two corners | Where the cloth is pinned; Nothing lets it fall. | `PIN_MODE`: `'top-corners'` / `'top-edge'` / `'single'` / `'none'`, then `initCloth()` |+| Wind | Choice buttons | Light · Medium · Strong | Medium | How hard the wind blows; it rises and falls. | `WIND`: 0.2 / 0.5 / 1.2 |+| Stiffness | Choice buttons | Stretchy · Medium · Stiff | Medium | Stretchy sags and bounces; stiff keeps its shape. | `ITERS`: 2 / 4 / 8 |++**More options**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Gravity | Choice buttons | Light · Normal · Heavy | Normal | Heavy cloth hangs straighter and falls faster. | `GRAVITY`: 0.06 / 0.12 / 0.2 |+| Detail | Choice buttons | Low · Medium · High | Medium (Low on phones) | More points make finer folds; phones start at Low. | `COLS`: 16 / 24 / 40, with `ROWS=Math.round(COLS*.75)`, then `start()` |+| Shows the points | Switch | on / off | off | Marks each point; pinned ones are red. | `SHOW_VERTS` true / false, then `draw()` while paused |++- **Removed:**+ - The note.+ - The panel's Pause button. The player bar's Pause replaces it.+ - "↺ Reset cloth". The player bar's Reset replaces it.+ - The fps badge.+ - The Resolution and Pin Mode menus. They become Detail and Hangs from.+ - The Gravity, Wind Strength and Stiffness sliders. They become Gravity, Wind and Stiffness.+ - "Show vertices" becomes Shows the points.+ - "Show constraints". It drew exactly the same lines as the mesh, so it changed nothing.+- **Good for:** Flags and banners · Playful pages · Fashion and textiles · **Avoid on:** Behind text · Serious content+- **Prompt:**++ > Add a cloth simulation to [the flag, banner or fabric you want to show]. Model the cloth as a grid of points joined to their neighbours by links of fixed length. Each frame, move every point by its own momentum plus gravity and wind, then pull linked points back toward their proper distance a few times over. Pin some points so the cloth hangs, and let the visitor grab and drag the nearest point with the pointer or a finger. Use a coarser grid on phones. If the visitor has reduced motion turned on, show the cloth hanging still. Match the settings listed below.++- **README What it is:** rewritten:++ > A cloth simulation treats fabric as a grid of points joined by links of fixed length. Each frame, every point keeps moving the way it was moving, plus gravity and wind, and then the links pull neighbouring points back into shape. Pin a few points and the grid hangs, sways and folds like fabric, and you can grab it.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Hangs from | Two corners | Pins the top two corners, the whole top edge, one corner, or nothing, in which case the cloth falls to the floor |+ | Wind | Medium | How hard the wind blows; it rises and falls on its own: light is 0.2, medium 0.5 and strong 1.2 |+ | Stiffness | Medium | How many times each frame the links are pulled back to length: stretchy is 2, medium 4 and stiff 8 |+ | Gravity | Normal | How heavy the cloth is: light is 0.06, normal 0.12 and heavy 0.2 |+ | Detail | Medium | How many points the cloth has: low is 16 × 12, medium 24 × 18 and high 40 × 30; phones start at low |+ | Shows the points | off | Marks every point of the grid, with the pinned ones in red |++- **README See also:**+ - [GPGPU Particle System](../gpgpu-particle-system/) — physics moved to the graphics chip+ - [Noise-Based Motion](../noise-based-motion/) — natural movement from noise instead of physics+ - [Canvas Particle Effect](../canvas-particle-effect/) — simpler physics for loose particles+- **README How it works:** unchanged+- **README Production notes:** the Performance bullet's last sentence becomes "The demo starts at 16×12 on screens 600px wide or less; its Detail setting still lets you pick more." The rest is unchanged.+- **Category line:** `06.15 · 3D & Advanced`+- **Pager:** Previous: Image Distortion on Hover (`../image-distortion-hover/`) · Next: Volumetric Smoke / 3D Noise (`../volumetric-smoke/`)++---++## volumetric-smoke — Volumetric Smoke / 3D Noise++- **Kind:** loop. The smoke keeps rising.+- **Description:** Soft smoke curls upward, drawn as a real 3D cloud. Best for moody backgrounds.+- **Watch it help line:** default+- **Player bar:** Pause (page) · Slow motion (page)+- **Sequence:** the WebGL loop as in the preamble (`render(ts)`, 16ms gate).+ - **The clock:** the page keeps its own clock, `curT` (each frame's time, at most 50ms, and nothing on the first frame after a start), in place of `(ts-startT)/1000`. `startT` and `pausedAt` go.+ - **The rise:** the page also keeps `rise`, which adds the same step × Speed. The shader takes `uniform float uRise` and `density()` uses `fbm(q*1.4+vec3(0.,uRise*.4,0.))` in place of `t*uSpd*.4`, so a new Speed never makes the smoke jump (today the rise is the time × the speed). The wind drift still follows the clock.+ - **The first picture:** `draw(curT)` at load. **While paused,** settings call `refresh()` and a resize redraws, as today.+- **Slow motion:** while the switch is on, the clock and the rise add a third of each frame's step, from the next frame.+- **Reduced motion:** the page's reduced-motion branch goes (see the preamble), with the CSS comment about it.+- **Stage font:** no text on the stage; `.msg` uses the site font.+- **Stage:** only the canvas. The fps and steps badges and the shader source panel go; `.msg` stays. `hb-dots`: no. Default height.+- **Phone fallback:** today's stays: on screens 600px wide or less the canvas draws at 0.75 of the stage's CSS size (at most 1 on computers) and a ray takes at most 48 steps, so High is 48 there.++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Thickness | Choice buttons | Thin · Medium · Thick | Medium | Thin smoke is wispy; thick smoke hides what is behind. | `DENS`: 0.4 / 0.7 / 1.2 |+| Speed | Choice buttons | Slow · Normal · Fast | Normal | How fast the smoke rises. | `SPD`: 0.35 / 0.6 / 1 |+| Detail | Choice buttons | Low · Medium · High | Medium | More steps look smoother but cost more. | `STEPS`: 16 / 32 / 64 (High is 48 on phones), through `setSteps()` without its slider and badge lines |++**More options**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Smoke color | Swatches | Gray blue · White · Purple · Orange | Gray blue | The color of the lit smoke. | `SMOKE` from `#9ab4d8` / `#f4f4f2` / `#d2a8ff` / `#ffa657` (today's default is the first) |+| Wind | Switch | on / off | on | The smoke drifts slowly to one side. | `WIND` true / false |+| Fine grain | Switch | on / off | on | Grain hides the stripes that few steps leave. | `DITHER` true / false |++- **Removed:**+ - The note.+ - The panel's Pause button. The player bar's Pause replaces it.+ - The fps and steps badges.+ - The Smoke Density, Animation Speed and March Steps sliders. They become Thickness, Speed and Detail.+ - The Smoke Color picker. It becomes the Smoke color swatches.+ - The Background Color picker. The background stays `#030810`; it framed the smoke but did not change it.+ - "Wind drift" and "Noise dither (reduce banding)" become Wind and Fine grain.+ - "View shader source" and its panel (the pages show no code).+- **Good for:** Moody backgrounds · Title cards · Games · Sci-fi themes · **Avoid on:** Behind text · Low-power devices+- **Prompt:**++ > Add volumetric smoke to [the section you want it in]. In a fragment shader, send a ray through a 3D cloud of smooth noise for every pixel and add up how much smoke it passes through, shading each step by how much smoke lies between it and the light, so the plume looks soft, deep and lit from one side. Move the noise upward over time so the smoke rises and curls, and let it drift sideways when the settings include wind. It is costly, so draw fewer pixels and take fewer steps on phones. If the visitor has reduced motion turned on, show the smoke still. Match the settings listed below.++- **README What it is:** rewritten:++ > Volumetric smoke is drawn as a real 3D cloud rather than a flat picture. For every pixel, a ray passes through a cloud of smooth noise and adds up how much smoke it meets, shading each part by how much smoke lies between it and the light. That gives soft edges and depth, which is how films draw smoke, fog and clouds.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Thickness | Medium | How dense the smoke is: thin is 0.4, medium 0.7 and thick 1.2; thin looks wispy, thick hides what is behind |+ | Speed | Normal | How fast the smoke rises: slow is 0.35, normal 0.6 and fast 1 |+ | Detail | Medium | How many steps each ray takes: low is 16, medium 32 and high 64 (48 on phones); fewer steps leave visible stripes |+ | Smoke color | Gray blue | The color of the lit smoke; the shadowed parts are darker shades of it |+ | Wind | on | The whole plume drifts slowly to one side |+ | Fine grain | on | Starts each ray at a slightly random point, which turns the stripes that few steps leave into fine grain |++- **README See also:**+ - [Ray Marching / SDF Scene](../ray-marching-sdf/) — rays that stop at surfaces instead of adding up smoke+ - [Noise-Based Motion](../noise-based-motion/) — the same kind of noise, on a flat canvas+ - [Fluid / Liquid Simulation](../fluid-simulation/) — a soft, liquid look drawn by a shader+- **README How it works:** in the `smokeDensity` snippet, `t * speed` becomes `rise`, and this sentence follows the snippet: "`rise` grows every frame by the frame's time × the speed, on the page, so changing the speed never makes the smoke jump." The rest is unchanged.+- **README Production notes:** unchanged+- **Category line:** `06.16 · 3D & Advanced`+- **Pager:** Previous: Cloth / Soft-Body Simulation (`../cloth-simulation/`) · Next: Morphing Blob (`../morphing-blob/`)++---++## morphing-blob — Morphing Blob++- **Kind:** loop. The blob keeps drifting and changing shape.+- **Description:** Blobs melt together, and one drop chases your pointer. Best for hero sections.+- **Watch it help line:** It moves by itself, and one drop follows your pointer or finger. Pause it to look closely, or turn on slow motion to see each part of the movement.+- **Player bar:** Pause (page) · Slow motion (page)+- **Sequence:** an animation-frame loop moving SVG circles.+ - `frame(t)` splits into `step(dt)` (the drift phase and the drop's chase) and `place()` (writes each circle's `cx`, `cy` and `r`); each frame runs both.+ - `start()` returns when `raf` is set; otherwise it forgets the last frame's time, so the first frame after a start adds nothing (today `Math.min(time-last,0.1)` could add a tenth of a second at once), and requests a frame.+ - **The first picture:** `place()` at load, after `build()`. **While paused,** Number of blobs rebuilds and calls `place()`; Gooeyness shows at once (it is an attribute of the filter); Speed shows at the next Play. The drop's target still follows the pointer, and the drop catches up after Play.+- **Slow motion:** while the switch is on, `phase` adds a third (`dt*speed/3`) and the drop closes 0.03 of the gap each frame in place of 0.09, from the next frame.+- **Reduced motion:** `reduce` goes, with `speed=0` and `paintStatic()`; the `.tip` rule goes with the tip (see the preamble).+- **Stage font:** no text on the stage.+- **Stage:** the SVG only; the "Move your pointer" tip goes. The stage keeps its radial gradient, `touch-action:none` and `cursor:crosshair`. `:root` gets `--ui-accent:#3fd6c4`; `--accent` and `--accent2` go with the panel, and `--stage` stays (the gradient uses it). `hb-dots`: no (it would replace the gradient). Default height.+- **Phone fallback:** none needed. Measured on the throttled phone: 0.5 to 0.8ms a frame and a full 60 frames a second with the filter, at 4, 6 and 9 blobs.+- **Touch:** as today: `pointerdown` and `pointermove` set the drop's target, and the stage's `touch-action:none` lets a finger drag it.++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Gooeyness | Choice buttons | Low · Medium · High | Medium | How far apart the circles start to melt together. | the blur's `stdDeviation`: 6 / 10 / 16 |+| Number of blobs | Choice buttons | Few · Medium · Many | Medium | More circles make a lumpier blob. | `build(4 / 6 / 9)` |+| Speed | Choice buttons | Slow · Normal · Fast | Normal | How fast the circles drift. | `speed`: 0.6 / 1 / 1.6 |++**More options**++None: leave out the `details.hb-options` block.++- **Removed:**+ - The note.+ - The Technique, Filter and Droplet readouts.+ - The "Move your pointer" tip. The help line says it.+ - The Gooeyness, Blob count and Drift speed sliders. They become Gooeyness, Number of blobs and Speed; Drift speed could reach zero, and Pause does that now.+- **Good for:** Hero sections · Playful brands · Loading states · Cursor effects · **Avoid on:** Serious content · Busy layouts+- **Prompt:**++ > Add a gooey blob to [the section you want it in]. Draw several plain circles that drift on looping paths, and run them through a filter that blurs them and then sharpens the blurred edge again, so circles that come close melt into one liquid shape and pull apart again. One drop follows the pointer, or a finger on touch screens, and merges with the rest when it comes near. Keep the blurred area small on phones. If the visitor has reduced motion turned on, show the blob still. Match the settings listed below.++- **README What it is:** rewritten:++ > A morphing blob is a soft, liquid shape made from plain circles. The circles are blurred and then their edges are sharpened again, so wherever two come close they melt into one shape, like drops of mercury. As they drift, the blob stretches, splits and joins, and one drop follows the pointer.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Gooeyness | Medium | How much the circles are blurred before the edge is sharpened again: low is 6, medium 10 and high 16; higher melts circles from farther apart |+ | Number of blobs | Medium | Few is 4, medium 6 and many 9 circles, counting the drop that follows the pointer |+ | Speed | Normal | How fast the circles drift: slow is 0.6, normal 1 and fast 1.6 times |++- **README See also:** the last link's text changes to the page's real title.+ - [Fluid / Liquid Simulation](../fluid-simulation/) — the same melting, drawn by a WebGL shader+ - [Noise-Based Motion](../noise-based-motion/) — smooth noise ripples a blob's outline+ - [SVG Path Animation](../svg-path-animation/) — lines that draw themselves+ - [Ray Marching / SDF Scene](../ray-marching-sdf/) — shapes that melt together in 3D+- **README How it works:** unchanged+- **README Production notes:** the Reduced motion bullet becomes: "**Reduced motion.** Under `prefers-reduced-motion: reduce` the demo starts paused, showing the blob still, until the visitor presses Play. In production, never leave an autonomous churning shape running for users who opted out: show one settled arrangement." The rest is unchanged.+- **Category line:** `06.17 · 3D & Advanced`+- **Pager:** Previous: Volumetric Smoke / 3D Noise (`../volumetric-smoke/`) · Next: 3D Flip Card (`../flip-card-3d/`)++---++## flip-card-3d — 3D Flip Card++- **Kind:** do it. The card turns only when it is clicked, tapped, hovered (with Flips on hover) or shown by Show me.+- **Description:** A card turns over in 3D to show its back. Best for profile and product cards.+- **Step 1:** Click it — "Click the card, or tap it, to turn it over."+- **Player bar:** Show me · Reset · Slow motion (css)+- **Show me:** one click's worth, about 2.5 seconds at Normal: `setFlipped(true)` at once; after Speed + 1200ms (Speed × 3 + 1200ms while Slow motion is on), `setFlipped(false)`. It ends on the front. A second press clears the pending timer and starts again.+- **Stopping a run:** on `hb:input` the pending timer is cleared and the card stays as it is; the visitor's click, tap or key then turns it as usual.+- **Reset:** stops a run, calls `setFlipped(false)` and sets the tilt flat (`tilt.style.transform='rotateX(0deg) rotateY(0deg)'`).+- **Sequence:** as today. A click, a tap, Enter or Space turns the card over; with Flips on hover, pointing turns it and leaving turns it back, and a tap still turns it on touch screens. While idle under a hovering pointer, the card leans toward it (Tilt toward the pointer). The "Flip card" button goes: Show me demonstrates the flip, and the card itself is the control.+- **Slow motion:** css: the flip and the tilt's return run at a third of their speed, and Show me's wait uses Speed × 3 while the switch is on.+- **Reduced motion:** Show me does not run on arrival. The demo's reduced-motion rules stay: the faces swap with a 120ms fade instead of turning, and the tilt is off. Show me, clicks and taps still swap the faces.+- **Stage font:** site font. `.avatar` and `.front .name` drop `var(--disp)` (their weights 800 and 700 stay). `.front .hint` and `.back .hint` get 11px and `rgba(255,255,255,.6)` (were 9px at .4); `.back .over` gets 11px and `font-weight:600` (was 9px).+- **Stage:**+ - The card only, directly in the stage; the `.stage-wrap` wrapper goes.+ - **The card is sized from the stage's height.** Today's width formula assumes the old 360–560px stage, and the card overflows the 300px phone stage. `.tilt` gets `height:100%`, and `.card` gets `height:min(100%,420px);width:auto;aspect-ratio:5/7` in place of its width formula. Previewed: 184×258px on a 375px phone (both faces' text inside), 164×229px on the 1366×657 laptop and 269×377px on a tablet.+ - Card text: the front hint becomes "Tap or click to flip →" (was "Click / tap / Enter to flip →"). The name, role, rows and the back's hint stay.+ - `.front .role` and `.back .over` use `#b98cff` directly, the card's own purple, since `--ui-accent` becomes the category's teal. `.card:focus-visible` keeps `var(--ui-accent)`.+ - The stage keeps its radial gradient, its `clamp(20px,4vw,48px)` padding and `perspective:var(--perspective)`; its own height goes. The shared `overflow:hidden` applies: the card fits, and only at Strong depth can a few pixels of its near edge pass the padding halfway through a turn.+ - `hb-dots`: no (the stage keeps its gradient). Default height.+- **Phone fallback:** none needed.+- **Touch:** as today: a tap turns the card. The idle tilt stays off on touch screens (`@media(hover:none)` and the `canHover` check), because it follows a hovering pointer; turning the card is the tap equivalent.++**Main settings**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Flip direction | Choice buttons | Sideways · Up and over | Sideways | Sideways turns like a page; up and over like a flap. | `axis`: `'y'` / `'x'` (the card's `axis-x` class off / on) |+| Speed | Choice buttons | Slow · Normal · Fast | Normal | How long one turn takes. | `--flip-dur`: 1000ms / 650ms / 400ms (Show me reads the same value) |+| 3D depth | Choice buttons | Subtle · Medium · Strong | Medium | Strong looks closer and more dramatic. | `--perspective`: 2000px / 1200px / 600px |++**More options**++| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo |+|---|---|---|---|---|---|+| Flips on hover | Switch | on / off | off | Pointing flips it; a tap still flips it on phones. | `trigger`: `'hover'` / `'click'`; switching it on turns the card to its front, as today |+| Tilt toward the pointer | Choice buttons | Off · Gentle · Strong | Gentle | The card leans toward a hovering pointer. | `maxTilt`: 0 / 10 / 18 (degrees; Off also sets the tilt flat, as today) |++- **Removed:**+ - The note.+ - The Flip card button.+ - The Flip axis and Trigger buttons. They become Flip direction and Flips on hover. The page's own `.seg`, `.seg button` and `.seg button.on` rules go with them, so they cannot restyle the shared Try it buttons.+ - The Flip duration, Perspective depth and Idle tilt strength sliders. They become Speed, 3D depth and Tilt toward the pointer.+- **Good for:** Profile cards · Product cards · Flashcards · Quiz answers · **Avoid on:** Long text · Key information+- **Prompt:**++ > Add a 3D flip to [the card you want to turn over]. Place the front and back faces in the same spot, turn the back face around so it faces away, and hide whichever face points away from the viewer. Clicking, tapping or pressing Enter turns the card over in 3D to show its back, and again to show its front. Give the card's container a 3D perspective so the turn has depth. When the settings include it, pointing at the card can flip it too, and the card can lean toward a hovering pointer. If the visitor has reduced motion turned on, swap the faces with a quick fade instead of turning. Match the settings listed below.++- **README What it is:** rewritten:++ > A 3D flip card has a front and a back and turns over in 3D to show the other side. Both faces sit in the same place, the back one turned away, and whichever face points away from the viewer is hidden. Perspective on the card's container gives the turn real depth, so it feels like turning over a physical card.++- **README Key parameters:**++ | Parameter | Default | Effect |+ |-----------|---------|--------|+ | Flip direction | Sideways | Sideways turns the card like a page; up and over turns it like a flap |+ | Speed | Normal | How long one turn takes: slow is 1000ms, normal 650ms and fast 400ms; 600 to 900ms feels physical |+ | 3D depth | Medium | How close the viewer seems: subtle is 2000px, medium 1200px and strong 600px; closer exaggerates the turn |+ | Flips on hover | off | Pointing at the card turns it over and leaving turns it back; a tap still turns it on touch screens |+ | Tilt toward the pointer | Gentle | While idle, the card leans up to 10° (gentle) or 18° (strong) toward a hovering pointer; off keeps it flat |++- **README See also:** each line gets a phrase, as the page checks require.+ - [Parallax 3D Tilt](../parallax-3d-tilt/) — a card leans toward the pointer without turning over+ - [Flip In](../../02-entrance-and-exit/flip-in/) — a card swings into view on a 3D hinge+ - [Scroll-Driven 3D Rotation](../scroll-driven-3d-rotation/) — scrolling turns a 3D cube+- **README How it works:** unchanged+- **README Production notes:** unchanged+- **Category line:** `06.18 · 3D & Advanced`+- **Pager:** Previous: Morphing Blob (`../morphing-blob/`) · Next: none