176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.
HTML ai-promptsanimationcss-animationsfrontendgithub-pagesjavascriptmicrointeractionsmotion-designno-dependenciesreferencescroll-animationui-animationweb-animationweb-developmentwebgl
feat: move Ambient Ripple Effect to the guided-steps page
matin0a6c2f84e139
diff --git a/animations/07-ambient-background/ambient-ripple/README.md b/animations/07-ambient-background/ambient-ripple/README.mdindex 6477a703..58fbcb9a 100644--- a/animations/07-ambient-background/ambient-ripple/README.md+++ b/animations/07-ambient-background/ambient-ripple/README.md@@ -1,7 +1,7 @@# Ambient Ripple Effect## What it is-The ambient ripple is the passive, atmospheric version of a ripple — concentric circles that expand outward from fixed source points on a periodic timer, not in response to user clicks. Each ring grows from zero radius to a maximum, fading in opacity as it expands, and is replaced by a new ring before it fully disappears. Multiple overlapping rings from multiple sources create the sense of something gently pulsing beneath the surface, like water drops on a still pond or sonar pings from a distant source.+An ambient ripple sends rings out from a few spots, over and over, like drops falling on a still pond or the ping of a sonar screen. Each ring grows from nothing and fades as it spreads, and the next one starts before it is gone, so the rings overlap into a gentle, steady pulse. It runs on its own rather than answering a click, and hints that something is alive there.## When to use it- Behind hero sections where "something is alive here" reinforces the product's value proposition@@ -18,8 +18,8 @@ class Ring {this.x = x;this.y = y;this.r = 0;- this.born = now; // the rAF frame timestamp — mixing it with performance.now()- this.duration = RING_LIFE_MS; // yields a negative radius on the birth frame+ this.born = now; // the page's own clock, which stops while paused+ this.duration = RING_LIFE_MS;}update(now) {@@ -40,13 +40,15 @@ class Ring {}```+`now` is the page's own clock: each frame adds the time since the last one (a third of it in slow motion), and it stops while the animation is paused, so rings freeze in place and carry on without jumping.+Sources emit rings at irregular intervals to avoid a mechanical clock-like feel:```jsfunction scheduleEmit(source) {const baseInterval = EMIT_INTERVAL_MS;const jitter = IRREGULAR ? (Math.random() - 0.5) * baseInterval * 0.8 : 0;- source.nextEmit = performance.now() + baseInterval + jitter;+ source.nextEmit = clock + baseInterval + jitter;}```@@ -65,11 +67,14 @@ function updateSource(source) {## Key parameters| Parameter | Default | Effect ||-----------|---------|--------|-| Source count | 3 | 1 = focused pulse; 3 = distributed field; 5 = active water surface |-| Emit interval | 3s | How often a new ring is born from each source |-| Max radius | 160px | Rings with large max radius need longer duration to avoid appearing to "rush" |-| Ring duration | 2.5s | Should be long enough for 2–3 rings to overlap, creating continuity |-| Irregular timing | On | ±40% random variance on the base interval — the most important toggle |+| Speed | Normal | How long each ring takes to spread and fade: slow is 4s, normal 2.5s and fast 1.5s |+| Time between ripples | Medium | How often each spot sends out a ring: short is every 1.8s, medium 3s and long 5s |+| Ripple size | Medium | How far each ring spreads: small is 100px, medium 160px and large 250px; big rings look calmer with a slow speed |+| Number of sources | 3 | One spot feels focused; three spread across the stage; five feel like rain on water |+| Ring thickness | Medium | The width of each ring: thin is 1px, medium 1.5px and thick 3px |+| Ring color | Blue | The color of the rings |+| Uneven timing | on | Each gap is up to 40% longer or shorter, at random, so the rings never tick like a clock |+| Sources drift | off | The spots slowly wander around the stage |## Production notes- **This is not the click ripple**: the click ripple ([Click / Tap Ripple](../../04-micro-interactions/click-ripple/)) responds to user input and confirms an action. The ambient ripple is passive and decorative — it fires automatically and continuously without any user interaction.@@ -79,6 +84,6 @@ function updateSource(source) {- **Accessibility**: the animation is purely decorative. Pause on `prefers-reduced-motion` and remove the canvas entirely if needed — no content is lost.## See also-- [Click / Tap Ripple](../../04-micro-interactions/click-ripple/) — the user-triggered, action-confirming version of a ripple-- [Breathing Glow](../breathing-glow/) — a pulsing glow rather than expanding rings-- [Abstract Geometric Motion](../abstract-geometric-motion/) — the "concentric rings" preset in the geometric loop demo+- [Click / Tap Ripple](../../04-micro-interactions/click-ripple/) — a ripple that answers a click instead+- [Breathing / Pulsing Glow](../breathing-glow/) — one glow that grows and shrinks instead of rings+- [Abstract Geometric Motion](../abstract-geometric-motion/) — its Rings pattern spreads rings from the centerdiff --git a/animations/07-ambient-background/ambient-ripple/index.html b/animations/07-ambient-background/ambient-ripple/index.htmlindex 65c29d51..89347fb7 100644--- a/animations/07-ambient-background/ambient-ripple/index.html+++ b/animations/07-ambient-background/ambient-ripple/index.html@@ -4,7 +4,7 @@<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Ambient Ripple Effect — Animation Handbook</title>- <meta name="description" content="Concentric rings expand from idle sources — automatic, periodic, decorative. Not click-triggered.">+ <meta name="description" content="Rings spread from a few spots, like drops on a still pond. Best for hero areas."><link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/ambient-ripple/"><link rel="icon" type="image/png" sizes="96x96" href="../../../favicon.png"><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">@@ -12,193 +12,314 @@<meta property="og:type" content="article"><meta property="og:site_name" content="Animation Handbook"><meta property="og:title" content="Ambient Ripple Effect — Animation Handbook">- <meta property="og:description" content="Concentric rings expand from idle sources — automatic, periodic, decorative. Not click-triggered.">+ <meta property="og:description" content="Rings spread from a few spots, like drops on a still pond. Best for hero areas."><meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/ambient-ripple/"><meta property="og:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png"><meta name="twitter:card" content="summary_large_image"><meta name="twitter:title" content="Ambient Ripple Effect — Animation Handbook">- <meta name="twitter:description" content="Concentric rings expand from idle sources — automatic, periodic, decorative. Not click-triggered.">+ <meta name="twitter:description" content="Rings spread from a few spots, like drops on a still pond. Best for hero areas."><meta name="twitter:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png">- <script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Ambient Ripple Effect", "name": "Ambient Ripple Effect", "description": "Concentric rings expand from idle sources — automatic, periodic, decorative. Not click-triggered.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/ambient-ripple/", "inLanguage": "en", "articleSection": "Ambient & Background", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, Ambient & Background, Ambient Ripple Effect"}</script>+ <script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Ambient Ripple Effect", "name": "Ambient Ripple Effect", "description": "Rings spread from a few spots, like drops on a still pond. Best for hero areas.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/ambient-ripple/", "inLanguage": "en", "articleSection": "Ambient & Background", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, Ambient & Background, Ambient Ripple Effect"}</script><style>- @font-face{font-family:'Bricolage';src:url('../../../assets/fonts/brico-700.woff2') format('woff2');font-weight:700;font-display:swap}- @font-face{font-family:'Bricolage';src:url('../../../assets/fonts/brico-800.woff2') format('woff2');font-weight:800;font-display:swap}- @font-face{font-family:'PlexMono';src:url('../../../assets/fonts/plex-400.woff2') format('woff2');font-weight:400;font-display:swap}- @font-face{font-family:'PlexMono';src:url('../../../assets/fonts/plex-500.woff2') format('woff2');font-weight:500;font-display:swap}- :root{--bg:#0b0b0d;--ui-bg:#111114;--ui-border:rgba(255,255,255,.09);--ui-accent:#ffce5a;--ui-text:#f4f4f2;--ui-muted:#77777e;--stage-h:620px;--disp:'Bricolage','Arial Narrow',sans-serif;--mono:'PlexMono',ui-monospace,Menlo,Consolas,monospace}+ :root{--ui-accent:#ffce5a}*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}- body{background:var(--bg);color:var(--ui-text);font-family:var(--mono);-webkit-font-smoothing:antialiased;padding:clamp(12px,3vw,24px)}- header{margin-bottom:20px}- header h1{font-family:var(--disp);font-weight:700;font-size:clamp(11px,1.8vw,15px);letter-spacing:-.01em}- header p{font-size:clamp(10px,1.2vw,12px);color:var(--ui-muted);margin-top:4px}- .layout{display:flex;gap:clamp(12px,2vw,24px);align-items:flex-start}- .stage{flex:1;min-width:0;height:var(--stage-h);border:1px solid var(--ui-border);border-radius:8px;overflow:hidden;position:relative;background:#020508}+ .stage{position:relative;overflow:hidden;background:#020508}canvas{display:block;width:100%;height:100%;position:absolute;inset:0}- .fg-card{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:clamp(180px,55%,280px);background:rgba(2,5,8,.7);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:1px solid rgba(255,255,255,.1);border-radius:10px;padding:20px;z-index:10;text-align:center}- .fg-eyebrow{font-size:9px;letter-spacing:2px;text-transform:uppercase;color:var(--ui-accent);margin-bottom:8px}- .fg-title{font-family:Georgia,serif;font-size:clamp(14px,2vw,18px);color:#fff;margin-bottom:8px;font-style:italic;line-height:1.3}- .fg-body{font-size:10px;color:rgba(255,255,255,.45);line-height:1.6}- aside{width:clamp(200px,22vw,240px);flex-shrink:0;background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:8px;padding:16px;display:flex;flex-direction:column;gap:10px}- .note{font-size:10px;color:var(--ui-muted);line-height:1.6;border-left:2px solid var(--ui-accent);padding-left:8px}- .lbl{font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-accent)}- .div{height:1px;background:var(--ui-border)}- .sr{display:flex;align-items:center;gap:6px;font-size:10px}- .sr input[type=range]{flex:1;accent-color:var(--ui-accent);min-height:44px}- .sv{width:44px;text-align:right;color:var(--ui-text)}- .tog{display:flex;align-items:center;gap:8px;font-size:10px;cursor:pointer;min-height:44px}- .tog input{accent-color:var(--ui-accent);width:16px;height:16px;flex-shrink:0}- input[type=color]{border:none;background:none;width:44px;height:30px;cursor:pointer;border-radius:4px;padding:0}- button.rst{background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:var(--mono);font-size:10px;padding:14px 8px;border-radius:4px;cursor:pointer;width:100%}- @media(hover:hover){button.rst:hover{border-color:var(--ui-accent);color:var(--ui-accent)}}- @media(max-width:600px){.layout{flex-direction:column;align-items:stretch}aside{width:100%}:root{--stage-h:420px}.stage{flex:none}input[type=color]{height:44px}}- /* Reduced motion is handled in the script: one static frame, no loop. */+ .fg-card{position:absolute;bottom:28px;left:50%;transform:translateX(-50%);width:clamp(180px,55%,280px);background:rgba(2,5,8,.7);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:1px solid rgba(255,255,255,.1);border-radius:10px;padding:20px;z-index:10;text-align:center}+ .fg-eyebrow{font-size:11px;font-weight:600;letter-spacing:2px;text-transform:uppercase;color:var(--ui-accent);margin-bottom:8px}+ .fg-title{font-size:clamp(14px,2vw,18px);font-weight:700;color:#fff;margin-bottom:8px;line-height:1.3}+ .fg-body{font-size:13px;color:rgba(255,255,255,.72);line-height:1.6}+ /* On phones and short screens the stage is small, so the card shrinks and sits lower to leave the rings in view */+ @media(max-width:600px),(max-height:760px){+ .fg-card{bottom:12px;padding:12px 14px}+ .fg-eyebrow{margin-bottom:4px}+ .fg-title{margin-bottom:0}+ .fg-body{display:none}+ }+ @media(max-width:600px){+ .fg-card{padding:12px}+ .fg-title{font-size:13px}+ }</style>-<style id="ah-inject">-:root{--ah-bg:rgba(17,17,20,.82);--ah-line:rgba(255,255,255,.1);--ah-ink:#f4f4f2;--ah-muted:#9a9aa2;--ah-accent:#6ea8ff}-body{padding-top:46px}-.ah-bar{position:fixed;top:0;left:0;right:0;height:46px;z-index:2147483000;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:0 clamp(10px,3vw,18px);background:var(--ah-bg);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border-bottom:1px solid var(--ah-line);font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12px;box-sizing:border-box}-.ah-bar a,.ah-bar button{color:var(--ah-muted);text-decoration:none;background:none;border:0;font:inherit;cursor:pointer;display:inline-flex;align-items:center;gap:6px;min-height:34px;padding:0 7px;border-radius:6px;transition:color .18s,background .18s;white-space:nowrap}-.ah-bar a:hover,.ah-bar button:hover{color:var(--ah-ink)}-.ah-home{color:var(--ah-ink);font-weight:600}-.ah-actions{display:flex;align-items:center;gap:2px}-.ah-sep{width:1px;height:16px;background:var(--ah-line);margin:0 4px}-.ah-copied{color:var(--ah-accent)!important}-@media(max-width:600px){.ah-bar .ah-hideSm{display:none}}-@media print{.ah-bar{display:none}body{padding-top:0}}-</style>+ <link rel="stylesheet" href="../../../assets/css/demo-page.css?v=3">+ <script src="../../../assets/js/demo-page.js?v=3" defer></script></head>-<body>-<div class="ah-bar" role="navigation" aria-label="Animation Handbook"><a class="ah-home" href="../../../">← Animation Handbook</a><span class="ah-actions"><a class="ah-hideSm" href="../breathing-glow/" rel="prev" title="Previous">‹ Prev</a><a class="ah-hideSm" href="../floating-elements/" rel="next" title="Next">Next ›</a><span class="ah-sep ah-hideSm"></span><button type="button" id="ah-copy" class="ah-hideSm">Copy source</button><a class="ah-hideSm" href="https://github.com/matinmonshizadeh/animation-handbook/blob/main/animations/07-ambient-background/ambient-ripple/index.html" target="_blank" rel="noopener noreferrer">Source ↗</a></span></div>-<header>- <h1>Ambient Ripple Effect</h1>- <p>Concentric rings expand from idle sources — automatic, periodic, decorative. Not click-triggered.</p>-</header>-<div class="layout">- <div class="stage" id="stage">- <canvas id="cvs"></canvas>- <div class="fg-card">- <div class="fg-eyebrow">Ambient Ripple</div>- <div class="fg-title">Something is alive here</div>- <div class="fg-body">Like water drops on a still pond, ECG monitors, sonar pings — suggests presence without interaction.</div>+<body class="hb" data-hb-kind="loop">+<nav class="hb-bar" aria-label="Animation Handbook">+ <a class="hb-home" href="../../../"><svg class="hb-mark" viewBox="0 0 32 32" aria-hidden="true"><g class="g"><circle cx="11.16" cy="20.84" r="6.1"/><circle cx="15.12" cy="16.88" r="6.1"/><circle cx="18.51" cy="13.49" r="6.1"/></g><circle class="b" cx="21.2" cy="10.8" r="6.6"/></svg><span>Animation Handbook</span></a>+ <span class="hb-pager"><a href="../breathing-glow/" rel="prev" aria-label="Previous: Breathing / Pulsing Glow"><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg><span><span class="hb-dir">Previous: </span>Breathing / Pulsing Glow</span></a><a href="../floating-elements/" rel="next" aria-label="Next: Floating Elements"><span><span class="hb-dir">Next: </span>Floating Elements</span><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg></a></span>+</nav>+<main class="hb-page">+ <header class="hb-head">+ <p class="hb-cat">07.09 · Ambient & Background</p>+ <h1>Ambient Ripple Effect</h1>+ <p class="hb-lede">Rings spread from a few spots, like drops on a still pond. Best for hero areas.</p>+ </header>++ <section class="hb-step hb-watch" aria-labelledby="hb-watch-title">+ <div class="hb-step-head">+ <span class="hb-num" aria-hidden="true">1</span>+ <div><h2 id="hb-watch-title">Watch it</h2><p>It moves by itself. Pause it to look closely, or turn on slow motion to see each part of the movement.</p></div></div>- </div>- <aside>- <p class="note">Ambient ripples evoke "something alive" without requiring interaction. Keep timing IRREGULAR — perfectly periodic ripples feel mechanical, like a clock, not nature.</p>- <div class="lbl">Source Count</div>- <div class="sr"><input type="range" id="src-sl" min="1" max="5" value="3" step="1"><span class="sv" id="src-v">3</span></div>- <div class="lbl">Emit Interval (base)</div>- <div class="sr"><input type="range" id="int-sl" min="10" max="80" value="30" step="5"><span class="sv" id="int-v">3.0s</span></div>- <div class="lbl">Max Radius</div>- <div class="sr"><input type="range" id="rad-sl" min="50" max="300" value="160" step="10"><span class="sv" id="rad-v">160px</span></div>- <div class="lbl">Ring Life (duration)</div>- <div class="sr"><input type="range" id="life-sl" min="10" max="50" value="25" step="5"><span class="sv" id="life-v">2.5s</span></div>- <div class="lbl">Ring Thickness</div>- <div class="sr"><input type="range" id="thick-sl" min="1" max="4" value="1.5" step="0.5"><span class="sv" id="thick-v">1.5px</span></div>- <div class="lbl">Color</div>- <input type="color" id="color-pick" value="#58a6ff" aria-label="Ripple color">- <label class="tog"><input type="checkbox" id="irr-tog" checked><span>Irregular timing</span></label>- <label class="tog"><input type="checkbox" id="drift-tog"><span>Sources drift slowly</span></label>- <div class="div"></div>- <button class="rst" id="pause-btn">⏸ Pause</button>- </aside>-</div>-<script>-const cvs=document.getElementById('cvs'),ctx=cvs.getContext('2d');-const stage=document.getElementById('stage');-let W,H,paused=false,raf=null,lastT=0;-const REDUCED=matchMedia('(prefers-reduced-motion:reduce)').matches;-let SRCS=3,INTERVAL=3,MAX_R=160,LIFE=2.5,THICK=1.5,IRR=true,DRIFT=false;-let COLOR=[88,166,255];-let sources=[],rings=[];+ <div class="stage">+ <canvas id="cvs" aria-hidden="true"></canvas>+ <div class="fg-card">+ <div class="fg-eyebrow">Ambient ripple</div>+ <div class="fg-title">Something is alive here</div>+ <div class="fg-body">Like drops on a still pond, or a sonar ping: it hints that something is there.</div>+ </div>+ </div>+ <div class="hb-player">+ <button class="hb-play" type="button" id="btn-pause" data-hb-pause data-state="playing"><svg class="hb-ic hb-i-pause" viewBox="0 0 24 24" aria-hidden="true"><rect x="6" y="4" width="4" height="16" rx="1"/><rect x="14" y="4" width="4" height="16" rx="1"/></svg><svg class="hb-ic hb-i-play" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 3l14 9-14 9z"/></svg><span class="hb-pause-label">Pause</span></button>+ <label class="hb-toggle"><input class="hb-switch" type="checkbox" role="switch" id="slow-tog" data-hb-slowmo autocomplete="off"><span>Slow motion</span></label>+ </div>+ </section>++ <section class="hb-step hb-try" aria-labelledby="hb-try-title">+ <div class="hb-step-head">+ <span class="hb-num" aria-hidden="true">2</span>+ <div><h2 id="hb-try-title">Try it</h2><p>Change a setting and see the difference as it moves.</p></div>+ </div>+ <div class="hb-settings">+ <div class="hb-setting">+ <p class="hb-setting-name" id="speed-lbl">Speed</p>+ <div class="seg" id="speed-seg" role="group" aria-labelledby="speed-lbl">+ <button type="button" data-life="4" aria-pressed="false">Slow</button>+ <button type="button" data-life="2.5" class="on" aria-pressed="true">Normal</button>+ <button type="button" data-life="1.5" aria-pressed="false">Fast</button>+ </div>+ <p class="hb-hint">How long each ring takes to spread and fade.</p>+ </div>+ <div class="hb-setting">+ <p class="hb-setting-name" id="int-lbl">Time between ripples</p>+ <div class="seg" id="int-seg" role="group" aria-labelledby="int-lbl">+ <button type="button" data-secs="1.8" aria-pressed="false">Short</button>+ <button type="button" data-secs="3" class="on" aria-pressed="true">Medium</button>+ <button type="button" data-secs="5" aria-pressed="false">Long</button>+ </div>+ <p class="hb-hint">How often each spot sends out a new ring.</p>+ </div>+ <div class="hb-setting">+ <p class="hb-setting-name" id="size-lbl">Ripple size</p>+ <div class="seg" id="size-seg" role="group" aria-labelledby="size-lbl">+ <button type="button" data-px="100" aria-pressed="false">Small</button>+ <button type="button" data-px="160" class="on" aria-pressed="true">Medium</button>+ <button type="button" data-px="250" aria-pressed="false">Large</button>+ </div>+ <p class="hb-hint">How far each ring spreads before it fades.</p>+ </div>+ </div>+ <details class="hb-options">+ <summary><span class="hb-more-label">More options</span><span class="hb-less">Fewer options</span><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg></summary>+ <div class="hb-settings">+ <div class="hb-setting">+ <p class="hb-setting-name" id="src-lbl">Number of sources</p>+ <div class="seg" id="src-seg" role="group" aria-labelledby="src-lbl">+ <button type="button" data-n="1" aria-pressed="false">1</button>+ <button type="button" data-n="3" class="on" aria-pressed="true">3</button>+ <button type="button" data-n="5" aria-pressed="false">5</button>+ </div>+ <p class="hb-hint">One spot feels focused; five feel like rain.</p>+ </div>+ <div class="hb-setting">+ <p class="hb-setting-name" id="thick-lbl">Ring thickness</p>+ <div class="seg" id="thick-seg" role="group" aria-labelledby="thick-lbl">+ <button type="button" data-px="1" aria-pressed="false">Thin</button>+ <button type="button" data-px="1.5" class="on" aria-pressed="true">Medium</button>+ <button type="button" data-px="3" aria-pressed="false">Thick</button>+ </div>+ <p class="hb-hint">The width of each ring's line.</p>+ </div>+ <div class="hb-setting">+ <p class="hb-setting-name" id="color-lbl">Ring color</p>+ <div class="swatches" id="color-sw" role="group" aria-labelledby="color-lbl">+ <button type="button" aria-pressed="false" aria-label="Pink" data-rgb="255,111,139" style="background:#ff6f8b"></button>+ <button type="button" aria-pressed="false" aria-label="White" data-rgb="244,244,242" style="background:#f4f4f2"></button>+ <button type="button" class="on" aria-pressed="true" aria-label="Blue" data-rgb="88,166,255" style="background:#58a6ff"></button>+ <button type="button" aria-pressed="false" aria-label="Purple" data-rgb="210,168,255" style="background:#d2a8ff"></button>+ <button type="button" aria-pressed="false" aria-label="Green" data-rgb="86,211,100" style="background:#56d364"></button>+ <button type="button" aria-pressed="false" aria-label="Orange" data-rgb="255,166,87" style="background:#ffa657"></button>+ </div>+ <p class="hb-hint">The color of the rings.</p>+ </div>+ <div class="hb-setting">+ <label class="hb-switch-row"><span>Uneven timing</span><input class="hb-switch" type="checkbox" role="switch" id="irr-tog" checked autocomplete="off"></label>+ <p class="hb-hint">Slightly random gaps feel natural, not mechanical.</p>+ </div>+ <div class="hb-setting">+ <label class="hb-switch-row"><span>Sources drift</span><input class="hb-switch" type="checkbox" role="switch" id="drift-tog" autocomplete="off"></label>+ <p class="hb-hint">The spots slowly wander around the stage.</p>+ </div>+ </div>+ </details>+ </section>-function resize(){- const dpr=Math.min(window.devicePixelRatio||1,2);- W=stage.clientWidth;H=stage.clientHeight;- cvs.width=Math.round(W*dpr);cvs.height=Math.round(H*dpr);ctx.setTransform(dpr,0,0,dpr,0,0);- initSources();-}+ <section class="hb-step hb-prompt-step" aria-labelledby="hb-prompt-title">+ <div class="hb-step-head">+ <span class="hb-num" aria-hidden="true">3</span>+ <div><h2 id="hb-prompt-title">Copy the prompt</h2><p>Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.</p></div>+ </div>+ <div class="hb-card">+ <p class="hb-prompt">Add an ambient ripple background to [the section or status you want to feel alive]. Pick a few spots and let each one send out a ring every so often that grows from nothing and gets fainter as it spreads until it disappears, so several rings overlap like drops on a still pond. It runs by itself, never on clicks. When the settings ask for uneven timing, vary the gaps slightly, because perfectly regular rings feel like a clock. If the visitor has reduced motion turned on, show a few still rings. Match the settings listed below.</p>+ <div class="hb-chips-box" hidden>+ <p class="hb-chips-title">Your settings</p>+ <ul class="hb-chips"></ul>+ </div>+ <div class="hb-copy-row">+ <button class="hb-copy" type="button"><svg class="hb-ic hb-i-copy" viewBox="0 0 24 24" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg><svg class="hb-ic hb-i-done" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg><span class="hb-copy-label" aria-live="polite">Copy prompt</span></button>+ <p class="hb-hint">Replace the words in brackets with your own element. Your settings are added at the end.</p>+ </div>+ </div>+ </section>-function initSources(){- sources=Array.from({length:SRCS},(_,i)=>({- x:W*(.2+i*.3/(Math.max(SRCS-1,1)))+W*.15,y:H*(.25+Math.random()*.5),- vx:(Math.random()-.5)*.2,vy:(Math.random()-.5)*.15,- nextEmit:performance.now()+Math.random()*INTERVAL*1000- }));-}+ <section class="hb-about" aria-labelledby="hb-what-title">+ <div class="hb-what">+ <h2 id="hb-what-title">What it is</h2>+ <div class="hb-what-text"><p>The full explanation is in <a href="README.md">README.md</a>.</p></div>+ </div>+ <div class="hb-fit">+ <h2>Good for</h2>+ <ul class="hb-tags hb-good"><li>Hero sections</li><li>Live and connected states</li><li>Maps and places</li><li>Meditation apps</li></ul>+ <h3>Avoid on</h3>+ <ul class="hb-tags hb-avoid"><li>Buttons</li><li>Alerts</li></ul>+ </div>+ </section>-class Ring{- constructor(x,y,now){this.x=x;this.y=y;this.r=0;this.born=now;this.dur=LIFE*1000;}- update(now){this.r=MAX_R*(now-this.born)/this.dur;}- isDead(now){return now-this.born>this.dur;}- draw(now){- const life=1-(now-this.born)/this.dur;- ctx.beginPath();ctx.arc(this.x,this.y,this.r,0,Math.PI*2);- ctx.strokeStyle=`rgba(${COLOR[0]},${COLOR[1]},${COLOR[2]},${(life*.5).toFixed(2)})`;- ctx.lineWidth=THICK*(1-this.r/MAX_R*.3);ctx.stroke();+ <section class="hb-related" aria-labelledby="hb-related-title" hidden>+ <h2 id="hb-related-title">Similar animations</h2>+ <div class="hb-rel-list"></div>+ </section>+</main>+<footer class="hb-foot"><span>Animation Handbook</span><a href="#top">Back to top ↑</a></footer>+<script>+ const cvs=document.getElementById('cvs'),ctx=cvs.getContext('2d');+ const stage=document.querySelector('.stage');+ const slowTog=document.getElementById('slow-tog');+ let W=0,H=0,raf=null,lastT=null,paused=false;+ let clock=0; // the page's own time in ms: it moves only while the loop runs, so Pause holds every ring where it is+ let SRCS=3,INTERVAL=3,MAX_R=160,LIFE=2.5,THICK=1.5,IRR=true,DRIFT=false;+ let COLOR=[88,166,255];+ let sources=[],rings=[];++ class Ring{+ constructor(x,y,born){this.x=x;this.y=y;this.born=born;this.dur=LIFE*1000}+ draw(rgb){+ const p=(clock-this.born)/this.dur; // 0 when the ring starts, 1 when it has faded away+ ctx.beginPath();ctx.arc(this.x,this.y,MAX_R*p,0,Math.PI*2);+ ctx.strokeStyle=`rgba(${rgb},${((1-p)*.5).toFixed(2)})`;+ ctx.lineWidth=THICK*(1-p*.3);ctx.stroke();+ }}-}-// Reduced motion still needs to show the technique, so freeze a single frame-// with each source mid-emission rather than an empty stage.-function paintStatic(){- ctx.clearRect(0,0,W,H);- const now=performance.now();- sources.slice(0,SRCS).forEach(s=>{- ctx.fillStyle=`rgba(${COLOR[0]},${COLOR[1]},${COLOR[2]},.4)`;- ctx.beginPath();ctx.arc(s.x,s.y,3,0,Math.PI*2);ctx.fill();- [.3,.6,.9].forEach(f=>{- const r=new Ring(s.x,s.y,now-f*LIFE*1000);- r.update(now);r.draw(now);- });- });-}+ // The wait until a source sends its next ring: Time between ripples, up to 40% shorter or longer with Uneven timing+ function gap(){return INTERVAL*1000*(1+(IRR?(Math.random()-.5)*.8:0))}-function loop(ts){- if(paused||REDUCED){raf=null;return;}- raf=requestAnimationFrame(loop);- const dt=ts-lastT;if(dt<16)return;lastT=ts;- ctx.clearRect(0,0,W,H);- // Update sources- sources.slice(0,SRCS).forEach(s=>{- if(DRIFT){- s.x+=s.vx;s.y+=s.vy;+ // The first picture: every source already has three rings on their way, so a stage that is paused on arrival shows the+ // effect. Emptying rings first means a resize or a new Number of sources never piles new rings on the old ones.+ function initSources(){+ rings=[];+ sources=Array.from({length:SRCS},(_,i)=>({+ x:W*(.2+i*.3/Math.max(SRCS-1,1))+W*.15,y:H*(.25+Math.random()*.5),+ vx:(Math.random()-.5)*.2,vy:(Math.random()-.5)*.15,+ nextEmit:clock+Math.random()*INTERVAL*1000+ }));+ sources.forEach(s=>[.3,.6,.9].forEach(f=>rings.push(new Ring(s.x,s.y,clock-f*LIFE*1000))));+ }++ // k is 1, or a third in slow motion+ function advance(k){+ if(!DRIFT)return;+ sources.forEach(s=>{+ s.x+=s.vx*k;s.y+=s.vy*k;if(s.x<W*.05||s.x>W*.95)s.vx*=-1;if(s.y<H*.1||s.y>H*.9)s.vy*=-1;- }- if(ts>=s.nextEmit){- rings.push(new Ring(s.x,s.y,ts));- const jitter=IRR?(Math.random()-.5)*INTERVAL*1000*.8:0;- s.nextEmit=ts+INTERVAL*1000+jitter;- }- // Draw source dot- ctx.fillStyle=`rgba(${COLOR[0]},${COLOR[1]},${COLOR[2]},.4)`;- ctx.beginPath();ctx.arc(s.x,s.y,3,0,Math.PI*2);ctx.fill();+ });+ }+ function emit(){+ sources.forEach(s=>{+ if(clock<s.nextEmit)return;+ rings.push(new Ring(s.x,s.y,clock));+ s.nextEmit=clock+gap();+ });+ rings=rings.filter(r=>clock-r.born<=r.dur);+ }+ // The canvas is cleared completely each time, so a picture drawn again after a setting changes leaves no trace of the old one+ function draw(){+ ctx.clearRect(0,0,W,H);+ const rgb=COLOR.join(',');+ ctx.fillStyle=`rgba(${rgb},.4)`;+ sources.forEach(s=>{ctx.beginPath();ctx.arc(s.x,s.y,3,0,Math.PI*2);ctx.fill()});+ rings.forEach(r=>r.draw(rgb));+ }++ // loop() keeps exactly one frame requested in raf; Pause cancels it and Play starts one loop again.+ function loop(ts){+ raf=requestAnimationFrame(loop);+ if(lastT!==null&&ts-lastT<16)return;+ // The first frame after a start has no earlier frame to measure from, so it adds no time; a long gap between+ // frames (a background tab) counts for at most 50 ms. Slow motion adds a third of the time.+ const dt=lastT===null?0:Math.min(ts-lastT,50);+ lastT=ts;+ const k=slowTog.checked?1/3:1;+ clock+=dt*k;+ advance(k);emit();draw();+ }+ function start(){if(raf)return;lastT=null;raf=requestAnimationFrame(loop)}++ // Registered at the top level, before the shared script (deferred) can run: under reduced motion it pauses the+ // loop on arrival, which this listener must catch. The rings on screen stay where they are while paused.+ document.addEventListener('hb:pause',e=>{+ paused=e.detail.paused;+ if(paused){cancelAnimationFrame(raf);raf=null}+ else start();});- // Draw rings- rings=rings.filter(r=>!r.isDead(ts));- rings.forEach(r=>{r.update(ts);r.draw(ts);});-}-resize();-if(REDUCED)paintStatic();else raf=requestAnimationFrame(loop);-window.addEventListener('resize',()=>{resize();if(REDUCED||paused)paintStatic();});-// Controls must still repaint the frozen frame when the loop is not running.-document.addEventListener('input',()=>{if(REDUCED||paused)paintStatic();});-document.addEventListener('change',()=>{if(REDUCED||paused)paintStatic();});+ // Setting the canvas size wipes it, so a real change of the stage's size starts the sources over and draws the first+ // picture again at once, playing or paused. A resize that leaves the stage as it was (a phone's address bar sliding+ // in or out) does nothing.+ function resize(){+ const w=stage.clientWidth,h=stage.clientHeight;+ if(w===W&&h===H)return;+ W=w;H=h;+ const dpr=Math.min(window.devicePixelRatio||1,2);+ cvs.width=Math.round(W*dpr);cvs.height=Math.round(H*dpr);ctx.setTransform(dpr,0,0,dpr,0,0);+ initSources();draw();+ }++ function choices(id,pick){+ const buttons=document.querySelectorAll('#'+id+' button');+ buttons.forEach(b=>b.addEventListener('click',()=>{+ buttons.forEach(x=>{x.classList.toggle('on',x===b);x.setAttribute('aria-pressed',String(x===b))});+ pick(b.dataset);+ }));+ }+ // While paused, a setting draws the picture again so the change shows without starting the loop+ function still(){if(paused)draw()}+ choices('speed-seg',d=>{+ // Rings on screen keep how far along they are, so the picture stays as it is and only their pace changes+ const dur=+d.life*1000;+ rings.forEach(r=>{const p=(clock-r.born)/r.dur;r.dur=dur;r.born=clock-p*dur});+ LIFE=+d.life;still();+ });+ choices('int-seg',d=>{+ INTERVAL=+d.secs;+ // A source that would wait longer than a new gap sends its next ring within one, so the change shows soon+ sources.forEach(s=>{s.nextEmit=Math.min(s.nextEmit,clock+Math.random()*gap())});+ still();+ });+ choices('size-seg',d=>{MAX_R=+d.px;still()});+ choices('src-seg',d=>{+ if(+d.n===SRCS)return;+ SRCS=+d.n;initSources();still();+ });+ choices('thick-seg',d=>{THICK=+d.px;still()});+ choices('color-sw',d=>{COLOR=d.rgb.split(',').map(Number);still()});+ document.getElementById('irr-tog').addEventListener('change',e=>{IRR=e.target.checked;still()});+ document.getElementById('drift-tog').addEventListener('change',e=>{DRIFT=e.target.checked;still()});-document.getElementById('src-sl').addEventListener('input',e=>{SRCS=+e.target.value;document.getElementById('src-v').textContent=SRCS;initSources();});-document.getElementById('int-sl').addEventListener('input',e=>{INTERVAL=e.target.value/10;document.getElementById('int-v').textContent=INTERVAL.toFixed(1)+'s';});-document.getElementById('rad-sl').addEventListener('input',e=>{MAX_R=+e.target.value;document.getElementById('rad-v').textContent=MAX_R+'px';});-document.getElementById('life-sl').addEventListener('input',e=>{LIFE=e.target.value/10;document.getElementById('life-v').textContent=LIFE.toFixed(1)+'s';});-document.getElementById('thick-sl').addEventListener('input',e=>{THICK=+e.target.value;document.getElementById('thick-v').textContent=THICK+'px';});-document.getElementById('color-pick').addEventListener('input',e=>{const h=e.target.value;COLOR=[parseInt(h.slice(1,3),16),parseInt(h.slice(3,5),16),parseInt(h.slice(5,7),16)];});-document.getElementById('irr-tog').addEventListener('change',e=>{IRR=e.target.checked;});-document.getElementById('drift-tog').addEventListener('change',e=>{DRIFT=e.target.checked;});-document.getElementById('pause-btn').addEventListener('click',()=>{- paused=!paused;document.getElementById('pause-btn').textContent=paused?'▶ Resume':'⏸ Pause';- if(!paused){lastT=performance.now();raf=requestAnimationFrame(loop);}-});+ resize();+ window.addEventListener('resize',resize);+ start();</script>-<script>(function(){var b=document.getElementById("ah-copy");if(!b)return;b.addEventListener("click",function(){fetch(location.href).then(function(r){return r.text();}).catch(function(){return document.documentElement.outerHTML;}).then(function(t){return navigator.clipboard.writeText(t);}).then(function(){b.textContent="Copied!";b.classList.add("ah-copied");setTimeout(function(){b.textContent="Copy source";b.classList.remove("ah-copied");},1500);}).catch(function(){b.textContent="Copy failed";setTimeout(function(){b.textContent="Copy source";},1500);});});})();</script></body></html>diff --git a/index.html b/index.htmlindex 362f220c..45682df4 100644--- a/index.html+++ b/index.html@@ -1041,7 +1041,7 @@ const CATS=[['light-leak','Light Leak','Warm light washes in from a corner at random times. Best for photo sites.'],['starfield','Starfield / Space Particles','Stars stream toward you out of the dark. Best for space themes.'],['breathing-glow','Breathing / Pulsing Glow','A soft glow slowly grows and shrinks, like calm breathing. Best for idle states.'],- ['ambient-ripple','Ambient Ripple Effect','Concentric rings emit periodically from idle sources — passive atmosphere, not click-driven.'],+ ['ambient-ripple','Ambient Ripple Effect','Rings spread from a few spots, like drops on a still pond. Best for hero areas.'],['floating-elements','Floating Elements','Geometric shapes drift on independent sine-wave paths — no two elements synchronized.'],['grid-dot-pattern-parallax','Grid / Dot Pattern Parallax','Pattern shifts subtly opposite to mouse movement — depth felt, barely seen.'],['abstract-geometric-motion','Abstract Geometric Motion','Four hypnotic loops: rotating polygons, expanding rings, sliding bars, flowing color lines.'],