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 Chromatic Aberration to the guided-steps page
matine461f405a40f
diff --git a/animations/06-3d-advanced/chromatic-aberration/README.md b/animations/06-3d-advanced/chromatic-aberration/README.mdindex 3e5d2724..dda9147d 100644--- a/animations/06-3d-advanced/chromatic-aberration/README.md+++ b/animations/06-3d-advanced/chromatic-aberration/README.md@@ -1,7 +1,7 @@# Chromatic Aberration## What it is-Chromatic aberration is a lens defect where different wavelengths of light refract at slightly different angles, causing color fringing at high-contrast edges — red fringing on one side, blue on the other. In digital design it is used deliberately as an aesthetic, evoking analog imperfection, glitch aesthetics, or a stylized photographic look. The CSS implementation stacks three mix-blend-mode: screen layers tinted red, green, and blue, offset in opposite directions.+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.## When to use it- Glitch-aesthetic branding for music, gaming, and tech-edge products@@ -47,10 +47,11 @@ function applyOffset(amount, angleDeg) {## Key parameters| Parameter | Default | Effect ||-----------|---------|--------|-| Intensity | 4px | 1–3px = subtle fringing; 6–12px = obvious glitch; above 15px = illegible |-| Angle | 30° | 0° = pure horizontal split; 90° = vertical; 45° = diagonal (most "lens-like") |-| Animation mode | Static | Static = editorial print; Pulse = organic breathing; Glitch = digital artifact |-| Channel blur | 0px | Soft blur on R/B channels adds lens chromatic fringing rather than digital pixel offset |+| 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 |## Production notes- **`mix-blend-mode: screen`** requires a dark background — screen blending adds RGB values, so on white backgrounds all three channels sum to white and the offset is invisible. This effect works exclusively on dark backgrounds.@@ -59,6 +60,6 @@ function applyOffset(amount, angleDeg) {- **Performance**: CSS stacked elements with `mix-blend-mode` trigger compositing on the GPU. Three `screen`-blended layers is inexpensive. Avoid applying it to large image areas on mobile.## See also-- [WebGL Shader Animation](../webgl-shader-animation/) — GPU shader approach to the same effect with radial falloff-- [Scramble / Glitch Text](../../05-text-typography/scramble-text/) — companion glitch effect for text characters-- [Kinetic Typography](../../05-text-typography/kinetic-typography/) — broader context for distressed visual aesthetics+- [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 textdiff --git a/animations/06-3d-advanced/chromatic-aberration/index.html b/animations/06-3d-advanced/chromatic-aberration/index.htmlindex 316fb1a1..37ac094b 100644--- a/animations/06-3d-advanced/chromatic-aberration/index.html+++ b/animations/06-3d-advanced/chromatic-aberration/index.html@@ -4,7 +4,7 @@<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Chromatic Aberration — Animation Handbook</title>- <meta name="description" content="RGB channels offset in opposite directions — three screened layers faking lens color fringing.">+ <meta name="description" content="A word splits into red, green and blue fringes. Best for bold titles."><link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/animations/06-3d-advanced/chromatic-aberration/"><link rel="icon" type="image/png" sizes="96x96" href="../../../favicon.png"><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">@@ -12,47 +12,29 @@<meta property="og:type" content="article"><meta property="og:site_name" content="Animation Handbook"><meta property="og:title" content="Chromatic Aberration — Animation Handbook">- <meta property="og:description" content="RGB channels offset in opposite directions — three screened layers faking lens color fringing.">+ <meta property="og:description" content="A word splits into red, green and blue fringes. Best for bold titles."><meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/animations/06-3d-advanced/chromatic-aberration/"><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="Chromatic Aberration — Animation Handbook">- <meta name="twitter:description" content="RGB channels offset in opposite directions — three screened layers faking lens color fringing.">+ <meta name="twitter:description" content="A word splits into red, green and blue fringes. Best for bold titles."><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": "Chromatic Aberration", "name": "Chromatic Aberration", "description": "RGB channels offset in opposite directions — three screened layers faking lens color fringing.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/06-3d-advanced/chromatic-aberration/", "inLanguage": "en", "articleSection": "3D & Advanced", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, 3D & Advanced, Chromatic Aberration"}</script>+ <script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Chromatic Aberration", "name": "Chromatic Aberration", "description": "A word splits into red, green and blue fringes. Best for bold titles.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/06-3d-advanced/chromatic-aberration/", "inLanguage": "en", "articleSection": "3D & Advanced", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, 3D & Advanced, Chromatic Aberration"}</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:#3fd6c4;--ui-text:#f4f4f2;--ui-muted:#77777e;--disp:'Bricolage','Arial Narrow',sans-serif;--mono:'PlexMono',ui-monospace,Menlo,Consolas,monospace;--stage-h:620px;--ca-amt:4px;--ca-angle:30deg;--ca-blur:0px}+ :root{--ui-accent:#3fd6c4;--ca-amt:4px;--ca-angle:30deg;--ca-blur:0px}*,*::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);padding:0 clamp(16px,4vw,40px);border:1px solid var(--ui-border);border-radius:8px;background:#04060c;display:flex;align-items:center;justify-content:center;overflow:hidden;position:relative}- /* The CA wrapper */+ .stage{position:relative;display:flex;align-items:center;justify-content:center;padding:24px clamp(16px,4vw,40px);background:#04060c}+ /* The wrapper takes its size from the see-through base copy; the three colored copies sit on top of it */.ca-wrap{position:relative;display:inline-block;max-width:100%;text-align:center;overflow-wrap:anywhere;-webkit-user-select:none;user-select:none}- /* Three stacked layers */.ca-layer{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;mix-blend-mode:screen;pointer-events:none}.ca-layer.base{position:relative;mix-blend-mode:normal}- .ca-text{- font-family:Georgia,'Times New Roman',serif;- font-size:clamp(52px,9vw,100px);- font-style:italic;- line-height:1;- letter-spacing:-0.02em;- font-weight:bold;- -webkit-user-select:none;user-select:none- }+ .ca-text{font-size:clamp(52px,9vw,100px);font-weight:800;line-height:1;letter-spacing:-0.02em;-webkit-user-select:none;user-select:none}.ca-r .ca-text{color:#ff2020;filter:blur(var(--ca-blur))}.ca-g .ca-text{color:#20ff20}.ca-b .ca-text{color:#2060ff;filter:blur(var(--ca-blur))}- /* Base layer invisible — just for spacing */+ /* The base copy is invisible: it only gives the wrapper its size */.ca-layer.base .ca-text{color:transparent;-webkit-text-stroke:0}- /* Animation modes */+ /* Movement: the red and blue copies breathe (Pulse) or jump near the end of each 4s cycle (Glitch) */.ca-wrap.pulse .ca-r{animation:ca-pulse-r 2s ease-in-out infinite}.ca-wrap.pulse .ca-b{animation:ca-pulse-b 2s ease-in-out infinite}.ca-wrap.glitch .ca-r{animation:ca-glitch-r 4s step-end infinite}@@ -73,119 +55,171 @@86%{transform:translate(calc(var(--ca-amt)*2),calc(var(--ca-amt)*-1))}88%{transform:var(--b-t)}}- /* Panel */- 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)}- select{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:8px 6px;border-radius:4px;width:100%;min-height:44px}- .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=text]{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:11px;padding:8px 10px;border-radius:4px;width:100%;min-height:44px;outline:none}- input[type=text]:focus{border-color:var(--ui-accent)}- @media(max-width:600px){.layout{flex-direction:column}aside{width:100%}:root{--stage-h:auto}.stage{width:100%;height:auto;min-height:380px}}- @media(prefers-reduced-motion:reduce){.ca-r,.ca-b{animation:none!important}}</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="../svg-path-animation/" rel="prev" title="Previous">‹ Prev</a><a class="ah-hideSm" href="../2-5d-pseudo-3d/" 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/06-3d-advanced/chromatic-aberration/index.html" target="_blank" rel="noopener noreferrer">Source ↗</a></span></div>-<header>- <h1>Chromatic Aberration</h1>- <p>RGB channels offset in opposite directions — three screened layers faking lens color fringing.</p>-</header>-<div class="layout">- <div class="stage">- <div class="ca-wrap" id="ca-wrap">- <div class="ca-layer base"><div class="ca-text" id="ca-base-text">PRISM</div></div>- <div class="ca-layer ca-r" id="ca-r"><div class="ca-text" id="ca-r-text">PRISM</div></div>- <div class="ca-layer ca-g" id="ca-g"><div class="ca-text" id="ca-g-text">PRISM</div></div>- <div class="ca-layer ca-b" id="ca-b"><div class="ca-text" id="ca-b-text">PRISM</div></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="../svg-path-animation/" rel="prev" aria-label="Previous: SVG Path Animation"><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>SVG Path Animation</span></a><a href="../2-5d-pseudo-3d/" rel="next" aria-label="Next: 2.5D / Pseudo-3D"><span><span class="hb-dir">Next: </span>2.5D / Pseudo-3D</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">06.10 · 3D & Advanced</p>+ <h1>Chromatic Aberration</h1>+ <p class="hb-lede">A word splits into red, green and blue fringes. Best for bold titles.</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 class="stage hb-dots hb-grow">+ <div class="ca-wrap pulse" id="ca-wrap">+ <div class="ca-layer base"><div class="ca-text" id="ca-base-text">PRISM</div></div>+ <div class="ca-layer ca-r" id="ca-r" aria-hidden="true"><div class="ca-text" id="ca-r-text">PRISM</div></div>+ <div class="ca-layer ca-g" id="ca-g" aria-hidden="true"><div class="ca-text" id="ca-g-text">PRISM</div></div>+ <div class="ca-layer ca-b" id="ca-b" aria-hidden="true"><div class="ca-text" id="ca-b-text">PRISM</div></div>+ </div>+ </div>+ <div class="hb-player">+ <button class="hb-play" type="button" id="btn-pause" data-hb-pause="css" 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="css" 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="move-lbl">Movement</p>+ <div class="seg" id="move-seg" role="group" aria-labelledby="move-lbl">+ <button type="button" data-move="pulse" class="on" aria-pressed="true">Pulse</button>+ <button type="button" data-move="glitch" aria-pressed="false">Glitch</button>+ <button type="button" data-move="none" aria-pressed="false">None</button>+ </div>+ <p class="hb-hint">Pulse breathes in and out; Glitch jumps now and then.</p>+ </div>+ <div class="hb-setting">+ <p class="hb-setting-name" id="amt-lbl">Color split</p>+ <div class="seg" id="amt-seg" role="group" aria-labelledby="amt-lbl">+ <button type="button" data-amt="2" aria-pressed="false">Small</button>+ <button type="button" data-amt="4" class="on" aria-pressed="true">Medium</button>+ <button type="button" data-amt="8" aria-pressed="false">Large</button>+ </div>+ <p class="hb-hint">How far the red and blue copies sit from the word.</p>+ </div>+ <div class="hb-setting">+ <p class="hb-setting-name" id="angle-lbl">Direction</p>+ <div class="seg" id="angle-seg" role="group" aria-labelledby="angle-lbl">+ <button type="button" data-angle="0" aria-pressed="false">Sideways</button>+ <button type="button" data-angle="30" class="on" aria-pressed="true">Slanted</button>+ <button type="button" data-angle="90" aria-pressed="false">Up and down</button>+ </div>+ <p class="hb-hint">Which way the red and blue copies move apart.</p>+ </div>+ </div>+ <details class="hb-options">+ <summary><span class="hb-more-label">More options</span><span class="hb-less">Fewer options</span><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg></summary>+ <div class="hb-settings">+ <div class="hb-setting">+ <label class="hb-switch-row"><span>Soft color edges</span><input class="hb-switch" type="checkbox" role="switch" id="blur-tog" autocomplete="off"></label>+ <p class="hb-hint">Blurs the colored copies, like a real lens.</p>+ </div>+ <div class="hb-setting">+ <label class="hb-setting-name" for="text-inp">Your text</label>+ <input class="hb-text" type="text" id="text-inp" value="PRISM" autocomplete="off">+ <p class="hb-hint">Short words work best.</p>+ </div>+ </div>+ </details>+ </section>++ <section class="hb-step hb-prompt-step" aria-labelledby="hb-prompt-title">+ <div class="hb-step-head">+ <span class="hb-num" aria-hidden="true">3</span>+ <div><h2 id="hb-prompt-title">Copy the prompt</h2><p>Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.</p></div>+ </div>+ <div class="hb-card">+ <p class="hb-prompt">Add 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.</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>++ <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>Bold titles</li><li>Music and games</li><li>Error pages</li></ul>+ <h3>Avoid on</h3>+ <ul class="hb-tags hb-avoid"><li>Body text</li><li>Light backgrounds</li></ul></div>- </div>- <aside>- <p class="note">Three mix-blend-mode: screen layers — red, green, blue — offset in opposite directions. Lens aberration comes from different wavelengths refracting at slightly different angles.</p>- <div class="lbl">Intensity</div>- <div class="sr"><input type="range" id="amt-sl" min="0" max="20" value="4" step="1"><span class="sv" id="amt-v">4px</span></div>- <div class="lbl">Direction Angle</div>- <div class="sr"><input type="range" id="angle-sl" min="0" max="360" value="30" step="5"><span class="sv" id="angle-v">30°</span></div>- <div class="lbl">Channel Blur</div>- <div class="sr"><input type="range" id="blur-sl" min="0" max="4" value="0" step="0.5"><span class="sv" id="blur-v">0px</span></div>- <div class="lbl">Animation Mode</div>- <select id="mode-sel">- <option value="static" selected>Static</option>- <option value="pulse">Pulse</option>- <option value="glitch">Glitch</option>- </select>- <label class="tog"><input type="checkbox" id="blur-tog"><span>Blur offset channels</span></label>- <div class="div"></div>- <div class="lbl">Text</div>- <input type="text" id="text-inp" value="PRISM">- </aside>-</div>+ </section>++ <section class="hb-related" aria-labelledby="hb-related-title" hidden>+ <h2 id="hb-related-title">Similar animations</h2>+ <div class="hb-rel-list"></div>+ </section>+</main>+<footer class="hb-foot"><span>Animation Handbook</span><a href="#top">Back to top ↑</a></footer><script>- let amt=4,angle=30;const wrap=document.getElementById('ca-wrap');- const rLayer=document.getElementById('ca-r');- const bLayer=document.getElementById('ca-b');+ const rLayer=document.getElementById('ca-r'),bLayer=document.getElementById('ca-b');+ const vars=document.documentElement.style;+ const txtIn=document.getElementById('text-inp');+ let amt=4,angle=30;+ // The resting offset of the red and blue copies, from the split and the direction. The keyframes start+ // and end at it (--r-t, --b-t) and read the amount and angle for their own moves.function applyOffset(){const rad=angle*Math.PI/180;const dx=(Math.cos(rad)*amt).toFixed(1);const dy=(Math.sin(rad)*amt).toFixed(1);rLayer.style.transform=`translate(${dx}px,${dy}px)`;bLayer.style.transform=`translate(${-dx}px,${-dy}px)`;- document.documentElement.style.setProperty('--r-t',`translate(${dx}px,${dy}px)`);- document.documentElement.style.setProperty('--b-t',`translate(${-dx}px,${-dy}px)`);- document.documentElement.style.setProperty('--ca-amt',amt+'px');- document.documentElement.style.setProperty('--ca-angle',angle+'deg');+ vars.setProperty('--r-t',`translate(${dx}px,${dy}px)`);+ vars.setProperty('--b-t',`translate(${-dx}px,${-dy}px)`);+ vars.setProperty('--ca-amt',amt+'px');+ vars.setProperty('--ca-angle',angle+'deg');}-- function setBlur(v){- document.getElementById('blur-sl').value=v;- document.getElementById('blur-v').textContent=v+'px';- document.getElementById('blur-tog').checked=+v>0;- document.documentElement.style.setProperty('--ca-blur',v+'px');- }-function setText(t){- ['ca-base-text','ca-r-text','ca-g-text','ca-b-text'].forEach(id=>{- document.getElementById(id).textContent=t||'PRISM';- });+ ['ca-base-text','ca-r-text','ca-g-text','ca-b-text'].forEach(id=>{document.getElementById(id).textContent=t});}- document.getElementById('amt-sl').addEventListener('input',e=>{- amt=+e.target.value;document.getElementById('amt-v').textContent=amt+'px';applyOffset();- });- document.getElementById('angle-sl').addEventListener('input',e=>{- angle=+e.target.value;document.getElementById('angle-v').textContent=angle+'°';applyOffset();- });- document.getElementById('blur-sl').addEventListener('input',e=>setBlur(e.target.value));- document.getElementById('mode-sel').addEventListener('change',e=>{+ 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);+ }));+ }+ choices('move-seg',d=>{wrap.classList.remove('pulse','glitch');- if(e.target.value!=='static')wrap.classList.add(e.target.value);+ if(d.move!=='none')wrap.classList.add(d.move);applyOffset();});- document.getElementById('blur-tog').addEventListener('change',e=>setBlur(e.target.checked?1:0));- document.getElementById('text-inp').addEventListener('input',e=>setText(e.target.value));+ choices('amt-seg',d=>{amt=+d.amt;applyOffset()});+ choices('angle-seg',d=>{angle=+d.angle;applyOffset()});+ document.getElementById('blur-tog').addEventListener('change',e=>{vars.setProperty('--ca-blur',e.target.checked?'2px':'0px')});+ // Blank text (nothing, or only spaces) falls back to the default word; anything else stays as typed+ txtIn.addEventListener('input',()=>{const v=txtIn.value;setText(v.trim()?v:'PRISM')});applyOffset();</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 46589d3b..35934e0c 100644--- a/index.html+++ b/index.html@@ -1017,7 +1017,7 @@ const CATS=[['webgl-shader-animation','WebGL Shader Animation','Moving color patterns computed for every pixel. Best for bold backgrounds.'],['noise-based-motion','Noise-Based Motion','Smooth noise makes dots sway and a blob ripple. Best for calm backgrounds.'],['svg-path-animation','SVG Path Animation','A line drawing draws itself, stroke by stroke. Best for icons and logos.'],- ['chromatic-aberration','Chromatic Aberration','RGB channels offset via mix-blend-mode: screen — static, pulse, and glitch modes.'],+ ['chromatic-aberration','Chromatic Aberration','A word splits into red, green and blue fringes. Best for bold titles.'],['2-5d-pseudo-3d','2.5D / Pseudo-3D','Seven depth layers parallax at different rates — mouse-driven or auto-panning camera.'],['ray-marching-sdf','Ray Marching / SDF','3D scene entirely in a fragment shader — sphere blend, boolean ops, infinite repetition.'],['gpgpu-particle-system','GPGPU Particle System','65k+ particles computed in WebGL2 textures — physics in a shader, texture ping-pong.'],