Skip to content

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.

feat: move Scanline Effect to the guided-steps page

matin4038da2b77d0
diff --git a/animations/07-ambient-background/scanline/README.md b/animations/07-ambient-background/scanline/README.md
index a5f8d1b8..af2f5d2a 100644
--- a/animations/07-ambient-background/scanline/README.md
+++ b/animations/07-ambient-background/scanline/README.md
@@ -1,7 +1,7 @@
# Scanline Effect
## What it is
-Scanlines are the horizontal dark lines produced by CRT (cathode-ray tube) monitors, where the electron beam sweeps left-to-right line by line, leaving a visible gap between each row of phosphor. In digital design, scanlines are added intentionally as a CSS repeating gradient pattern to evoke retrowave, '80s synthwave, or '90s sci-fi UI aesthetics. A moving sweep beam that brightens as it passes adds a dynamic cinematic quality.
+Scanlines are the thin dark lines between the rows of light on an old tube television or computer monitor. Laying them over a design as a repeating stripe pattern gives it the look of a retro screen from the 80s or 90s. A soft band of light sweeping slowly down the screen adds movement, and darkened corners suggest the curved glass.
## When to use it
- Retrowave, cyberpunk, or synthwave themed UIs
@@ -27,7 +27,7 @@ Scanlines are the horizontal dark lines produced by CRT (cathode-ray tube) monit
}
```
-The `line-gap` CSS custom property in the demo allows the density to be adjusted: `4px` is standard CRT density; `8px` is coarser and more stylized.
+The demo's Line spacing setting changes this gap (`--line-gap`): `2px` is dense, `4px` is standard CRT density and `8px` is coarser and more stylized.
**Moving sweep beam** — a tall gradient strip animated with `translateY`:
@@ -71,13 +71,16 @@ travel without JavaScript measuring the stage.
## Key parameters
| Parameter | Default | Effect |
|-----------|---------|--------|
-| Line gap | 4px | 2px = dense vintage CRT; 4px = standard; 8px = stylized/coarse |
-| Line darkness | 0.15 | 0.05 = barely visible; 0.25 = strong retro; 0.5 = overpowering |
-| Beam speed | 4s | Faster = action/alert; slower = cinematic sci-fi |
-| Beam brightness | 0.08–0.12 | Keep it subtle — the beam should be felt, not seen clearly |
+| Line spacing | Medium | The distance between lines: tight is 2px, medium 4px and wide 8px; 4px looks like a standard old screen |
+| Line darkness | Medium | How dark the lines are: light is 8%, medium 15% and dark 30%; darker looks more retro but lowers contrast |
+| Moving beam | on | A soft band of light sweeps down the screen, again and again |
+| Beam speed | Normal | How long the beam takes to cross the screen: slow is 6.4s, normal 4s and fast 2.4s |
+| Beam brightness | Medium | How bright the beam is: faint is 6%, medium 12% and bright 24%; it should be felt more than seen |
+| Dark corners | off | A soft vignette darkens the corners, like the curved glass of an old screen |
+| Glowing text | off | A soft glow around the letters, like light spreading on an old screen |
## Production notes
-- **Purely CSS**: no JavaScript required for the scanline or beam effects. Only the panel controls use JS.
+- **Purely CSS**: no JavaScript required for the scanline or beam effects. Only the demo's settings use JavaScript.
- **`pointer-events: none`**: the scanline overlay must not intercept mouse events. Always add `pointer-events: none` to overlay elements.
- **Performance**: `repeating-linear-gradient` is composited as a texture on first render and cached. It does not repaint on each frame — it's essentially free. The `translateY` beam animation runs on the compositor thread.
- **Phosphor glow**: real CRT phosphors emit light that spreads slightly, creating a soft "halo" around bright text. CSS `text-shadow: 0 0 8px currentColor` approximates this. Keep it subtle — heavy glow degrades legibility.
@@ -85,6 +88,6 @@ travel without JavaScript measuring the stage.
- **Retrowave aesthetic**: combines well with [Grain Overlay](../grain-overlay/) (for texture), [Chromatic Aberration](../../06-3d-advanced/chromatic-aberration/) (for color fringing), and dark neon color palettes.
## See also
-- [Grain Overlay](../grain-overlay/) — texture overlay for analog warmth
-- [Light Leak](../light-leak/) — warm analog overlay for a film camera aesthetic
-- [Chromatic Aberration](../../06-3d-advanced/chromatic-aberration/) — RGB channel split for glitch/retro look
+- [Grain / Film Noise Overlay](../grain-overlay/) — a flickering texture of fine grain
+- [Light Leak](../light-leak/) — warm light washes in, like a film camera flaw
+- [Chromatic Aberration](../../06-3d-advanced/chromatic-aberration/) — colors split at the edges, like a broken signal
diff --git a/animations/07-ambient-background/scanline/index.html b/animations/07-ambient-background/scanline/index.html
index 7a86c1cf..a5d70099 100644
--- a/animations/07-ambient-background/scanline/index.html
+++ b/animations/07-ambient-background/scanline/index.html
@@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Scanline Effect — Animation Handbook</title>
- <meta name="description" content="Repeating dark lines over content create a CRT monitor aesthetic — optional sweep beam and phosphor glow.">
+ <meta name="description" content="Dark lines and a sweeping beam imitate an old TV screen. Best for retro sites.">
<link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/scanline/">
<link rel="icon" type="image/png" sizes="96x96" href="../../../favicon.png">
<link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
@@ -12,35 +12,26 @@
<meta property="og:type" content="article">
<meta property="og:site_name" content="Animation Handbook">
<meta property="og:title" content="Scanline Effect — Animation Handbook">
- <meta property="og:description" content="Repeating dark lines over content create a CRT monitor aesthetic — optional sweep beam and phosphor glow.">
+ <meta property="og:description" content="Dark lines and a sweeping beam imitate an old TV screen. Best for retro sites.">
<meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/scanline/">
<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="Scanline Effect — Animation Handbook">
- <meta name="twitter:description" content="Repeating dark lines over content create a CRT monitor aesthetic — optional sweep beam and phosphor glow.">
+ <meta name="twitter:description" content="Dark lines and a sweeping beam imitate an old TV screen. Best for retro sites.">
<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": "Scanline Effect", "name": "Scanline Effect", "description": "Repeating dark lines over content create a CRT monitor aesthetic — optional sweep beam and phosphor glow.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/scanline/", "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, Scanline Effect"}</script>
+ <script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Scanline Effect", "name": "Scanline Effect", "description": "Dark lines and a sweeping beam imitate an old TV screen. Best for retro sites.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/07-ambient-background/scanline/", "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, Scanline 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;--disp:'Bricolage','Arial Narrow',sans-serif;--mono:'PlexMono',ui-monospace,Menlo,Consolas,monospace;--stage-h:620px;--line-gap:4px;--line-dark:.15;--beam-dur:4s;--beam-bright:.12}
+ :root{--ui-accent:#ffce5a;--line-gap:4px;--line-dark:.15;--beam-dur:4s;--beam-bright:.12}
*,*::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:#05080d}
+ .stage{position:relative;overflow:hidden;background:#05080d}
/* Screen content */
.screen-content{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:32px}
- .terminal{width:100%;max-width:420px;background:#040608;border:1px solid rgba(88,166,255,.2);border-radius:6px;padding:20px 24px;font-family:monospace}
+ .terminal{width:100%;max-width:420px;background:#040608;border:1px solid rgba(88,166,255,.2);border-radius:6px;padding:20px 24px}
.term-bar{display:flex;gap:6px;margin-bottom:14px}
.dot{width:10px;height:10px;border-radius:50%}
.dot.r{background:#f85149}.dot.y{background:#ffa657}.dot.g{background:#56d364}
- .term-line{font-size:clamp(10px,1.3vw,12px);color:#58a6ff;line-height:1.7;opacity:.9}
- .term-line.dim{opacity:.4}
+ .term-line{font-size:clamp(12px,1.4vw,14px);color:#58a6ff;line-height:1.7;opacity:.9}
+ .term-line.dim{opacity:.75}
.term-cursor{display:inline-block;width:8px;height:1em;background:#58a6ff;vertical-align:text-bottom;animation:blink 1s step-end infinite}
@keyframes blink{50%{opacity:0}}
/* Scanline overlay */
@@ -62,122 +53,195 @@
background:linear-gradient(to bottom,transparent 0%,rgba(255,255,255,var(--beam-bright)) 50%,transparent 100%);
background-size:100% 120px;background-repeat:no-repeat;background-position:0 0;
animation:beam-sweep var(--beam-dur) linear infinite;
- will-change:transform;
- display:none
+ /* Starts 40% into the first sweep, so the band is on the screen at once, even in the still frame of a paused stage */
+ animation-delay:calc(var(--beam-dur) * -.4);
+ will-change:transform
}
@keyframes beam-sweep{from{transform:translateY(0)}to{transform:translateY(100%)}}
- /* CRT curvature — radial vignette darkening the corners */
+ /* Dark corners — radial vignette darkening the corners */
.crt-wrap{position:absolute;inset:0;pointer-events:none;display:none}
.crt-inner{position:absolute;inset:-5%;background:radial-gradient(ellipse at center,transparent 60%,rgba(0,0,0,.5) 100%)}
- /* Phosphor glow on text (via CSS on terminal) */
+ /* Glowing text (via CSS on terminal) */
.phosphor .term-line{text-shadow:0 0 8px #58a6ff,0 0 20px rgba(88,166,255,.3)}
- /* 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}
- button.rst{background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;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:auto}.stage{flex:none;height:auto;min-height:420px}}
- @media(prefers-reduced-motion:reduce){.beam{animation-duration:60s!important}.term-cursor{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="../grain-overlay/" rel="prev" title="Previous">‹ Prev</a><a class="ah-hideSm" href="../light-leak/" 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/scanline/index.html" target="_blank" rel="noopener noreferrer">Source ↗</a></span></div>
-<header>
- <h1>Scanline Effect</h1>
- <p>Repeating dark lines over content create a CRT monitor aesthetic — optional sweep beam and phosphor glow.</p>
-</header>
-<div class="layout">
- <div class="stage" id="stage">
- <div class="screen-content">
- <div class="terminal" id="terminal">
- <div class="term-bar"><span class="dot r"></span><span class="dot y"></span><span class="dot g"></span></div>
- <div class="term-line">$ initialize_system --mode ambient</div>
- <div class="term-line dim">// scanning for motion patterns</div>
- <div class="term-line">→ all systems nominal</div>
- <div class="term-line dim">→ rendering 60fps continuous</div>
- <div class="term-line">_ <span class="term-cursor"></span></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="../grain-overlay/" rel="prev" aria-label="Previous: Grain / Film Noise Overlay"><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>Grain / Film Noise Overlay</span></a><a href="../light-leak/" rel="next" aria-label="Next: Light Leak"><span><span class="hb-dir">Next: </span>Light Leak</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.05 · Ambient &amp; Background</p>
+ <h1>Scanline Effect</h1>
+ <p class="hb-lede">Dark lines and a sweeping beam imitate an old TV screen. Best for retro sites.</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">
+ <div class="screen-content">
+ <div class="terminal" id="terminal">
+ <div class="term-bar" aria-hidden="true"><span class="dot r"></span><span class="dot y"></span><span class="dot g"></span></div>
+ <div class="term-line">SYSTEM READY</div>
+ <div class="term-line dim">Tuning the signal…</div>
+ <div class="term-line">All channels clear</div>
+ <div class="term-line dim">Picture steady</div>
+ <div class="term-line"><span class="term-cursor" aria-hidden="true"></span></div>
+ </div>
+ </div>
+ <div class="scanlines" aria-hidden="true"></div>
+ <div class="beam" id="beam" aria-hidden="true"></div>
+ <div class="crt-wrap" id="crt-wrap" aria-hidden="true"><div class="crt-inner"></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="gap-lbl">Line spacing</p>
+ <div class="seg" id="gap-seg" role="group" aria-labelledby="gap-lbl">
+ <button type="button" data-gap="2" aria-pressed="false">Tight</button>
+ <button type="button" data-gap="4" class="on" aria-pressed="true">Medium</button>
+ <button type="button" data-gap="8" aria-pressed="false">Wide</button>
+ </div>
+ <p class="hb-hint">Tight lines look most like a real old screen.</p>
+ </div>
+ <div class="hb-setting">
+ <p class="hb-setting-name" id="dark-lbl">Line darkness</p>
+ <div class="seg" id="dark-seg" role="group" aria-labelledby="dark-lbl">
+ <button type="button" data-dark="0.08" aria-pressed="false">Light</button>
+ <button type="button" data-dark="0.15" class="on" aria-pressed="true">Medium</button>
+ <button type="button" data-dark="0.3" aria-pressed="false">Dark</button>
+ </div>
+ <p class="hb-hint">Darker lines look more retro but are harder to read.</p>
+ </div>
+ <div class="hb-setting">
+ <label class="hb-switch-row"><span>Moving beam</span><input class="hb-switch" type="checkbox" role="switch" id="beam-tog" checked autocomplete="off"></label>
+ <p class="hb-hint">A band of light sweeps down the screen.</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" id="speed-setting">
+ <p class="hb-setting-name" id="speed-lbl">Beam speed</p>
+ <div class="seg" id="speed-seg" role="group" aria-labelledby="speed-lbl">
+ <button type="button" data-secs="6.4" aria-pressed="false">Slow</button>
+ <button type="button" data-secs="4" class="on" aria-pressed="true">Normal</button>
+ <button type="button" data-secs="2.4" aria-pressed="false">Fast</button>
+ </div>
+ <p class="hb-hint">How long the beam takes to cross the screen.</p>
+ </div>
+ <div class="hb-setting" id="bright-setting">
+ <p class="hb-setting-name" id="bright-lbl">Beam brightness</p>
+ <div class="seg" id="bright-seg" role="group" aria-labelledby="bright-lbl">
+ <button type="button" data-bright="0.06" aria-pressed="false">Faint</button>
+ <button type="button" data-bright="0.12" class="on" aria-pressed="true">Medium</button>
+ <button type="button" data-bright="0.24" aria-pressed="false">Bright</button>
+ </div>
+ <p class="hb-hint">Keep the beam faint: it should be felt, not seen.</p>
+ </div>
+ <div class="hb-setting">
+ <label class="hb-switch-row"><span>Dark corners</span><input class="hb-switch" type="checkbox" role="switch" id="crt-tog" autocomplete="off"></label>
+ <p class="hb-hint">Darkens the corners like an old screen's curved glass.</p>
+ </div>
+ <div class="hb-setting">
+ <label class="hb-switch-row"><span>Glowing text</span><input class="hb-switch" type="checkbox" role="switch" id="glow-tog" autocomplete="off"></label>
+ <p class="hb-hint">A soft glow around the letters.</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="scanlines" id="scanlines"></div>
- <div class="beam" id="beam"></div>
- <div class="crt-wrap" id="crt-wrap"><div class="crt-inner"></div></div>
- </div>
- <aside>
- <p class="note">Scanlines = nostalgic. Static + sweep beam = cinematic sci-fi. Add curvature + phosphor = full CRT simulation. Use sparingly — the look is dated by design.</p>
- <div class="lbl">Line Density</div>
- <select id="density-sel">
- <option value="2">Dense (every 2px)</option>
- <option value="4" selected>Medium (every 4px)</option>
- <option value="8">Coarse (every 8px)</option>
- </select>
- <div class="lbl">Line Darkness</div>
- <div class="sr"><input type="range" id="dark-sl" min="5" max="40" value="15" step="1"><span class="sv" id="dark-v">0.15</span></div>
- <label class="tog"><input type="checkbox" id="beam-tog"><span>Moving beam sweep</span></label>
- <div class="lbl">Beam Speed</div>
- <div class="sr"><input type="range" id="beam-sl" min="2" max="15" value="4" step="1"><span class="sv" id="beam-v">4s</span></div>
- <div class="lbl">Beam Brightness</div>
- <div class="sr"><input type="range" id="bri-sl" min="5" max="30" value="12" step="1"><span class="sv" id="bri-v">0.12</span></div>
- <label class="tog"><input type="checkbox" id="crt-tog"><span>CRT curvature vignette</span></label>
- <label class="tog"><input type="checkbox" id="phos-tog"><span>Phosphor text glow</span></label>
- <div class="div"></div>
- <button class="rst" id="pause-btn">⏸ Pause</button>
- </aside>
-</div>
+ <div class="hb-card">
+ <p class="hb-prompt">Add a scanline effect to [the screen, panel or section you want to look like an old monitor]. Lay thin, dark horizontal lines over the content with a repeating stripe pattern, in a layer that clicks pass through, so it looks like the rows of an old tube screen. When the settings include them, sweep a soft band of light slowly down the screen again and again, darken the corners like curved glass, and give the text a soft glow. Make sure the text stays readable through the lines. If the visitor has reduced motion turned on, keep the beam 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>Retro and gaming sites</li><li>Terminal screens</li><li>Music players</li><li>Sci-fi interfaces</li></ul>
+ <h3>Avoid on</h3>
+ <ul class="hb-tags hb-avoid"><li>Long reading</li><li>Forms</li></ul>
+ </div>
+ </section>
+
+ <section class="hb-related" aria-labelledby="hb-related-title" hidden>
+ <h2 id="hb-related-title">Similar animations</h2>
+ <div class="hb-rel-list"></div>
+ </section>
+</main>
+<footer class="hb-foot"><span>Animation Handbook</span><a href="#top">Back to top ↑</a></footer>
<script>
- let paused=false;
- document.getElementById('density-sel').addEventListener('change',e=>{
- document.documentElement.style.setProperty('--line-gap',e.target.value+'px');
+ const beam=document.getElementById('beam');
+ const beamTog=document.getElementById('beam-tog');
+ const beamOnly=[document.getElementById('speed-setting'),document.getElementById('bright-setting')];
+ const vars=document.documentElement.style;
+ let beamSecs=4;
+
+ 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('gap-seg',d=>{vars.setProperty('--line-gap',d.gap+'px')});
+ choices('dark-seg',d=>{vars.setProperty('--line-dark',d.dark)});
+ // A new --beam-dur keeps the time the beam has already swept, so it would jump to another point of its sweep.
+ // Scaling that time by the same factor as the sweep keeps the beam where it is, moving or paused
+ // (its start offset is a share of the sweep, so it scales too).
+ choices('speed-seg',d=>{
+ const next=+d.secs;
+ beam.getAnimations().forEach(a=>{if(a.currentTime!=null)a.currentTime=a.currentTime*next/beamSecs});
+ beamSecs=next;
+ vars.setProperty('--beam-dur',next+'s');
});
- document.getElementById('dark-sl').addEventListener('input',e=>{
- const v=(e.target.value/100).toFixed(2);document.getElementById('dark-v').textContent=v;
- document.documentElement.style.setProperty('--line-dark',v);
- });
- document.getElementById('beam-tog').addEventListener('change',e=>{
- document.getElementById('beam').style.display=e.target.checked?'block':'none';
- });
- document.getElementById('beam-sl').addEventListener('input',e=>{
- document.getElementById('beam-v').textContent=e.target.value+'s';
- document.documentElement.style.setProperty('--beam-dur',e.target.value+'s');
- });
- document.getElementById('bri-sl').addEventListener('input',e=>{
- const v=(e.target.value/100).toFixed(2);document.getElementById('bri-v').textContent=v;
- document.documentElement.style.setProperty('--beam-bright',v);
+ choices('bright-seg',d=>{vars.setProperty('--beam-bright',d.bright)});
+
+ // The beam's own settings only matter while the beam is showing
+ beamTog.addEventListener('change',()=>{
+ beam.style.display=beamTog.checked?'block':'none';
+ beamOnly.forEach(s=>{s.hidden=!beamTog.checked});
});
document.getElementById('crt-tog').addEventListener('change',e=>{
document.getElementById('crt-wrap').style.display=e.target.checked?'block':'none';
});
- document.getElementById('phos-tog').addEventListener('change',e=>{
+ document.getElementById('glow-tog').addEventListener('change',e=>{
document.getElementById('terminal').classList.toggle('phosphor',e.target.checked);
});
- document.getElementById('pause-btn').addEventListener('click',()=>{
- paused=!paused;
- const state=paused?'paused':'running';
- document.getElementById('beam').style.animationPlayState=state;
- document.querySelector('.term-cursor').style.animationPlayState=state;
- document.getElementById('pause-btn').textContent=paused?'▶ Resume':'⏸ Pause';
- });
</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.html
index a81399bb..d4b9f664 100644
--- a/index.html
+++ b/index.html
@@ -1037,7 +1037,7 @@ const CATS=[
['mesh-gradient','Mesh Gradient Animation','Blurred blobs of color drift and melt together. Best for landing pages.'],
['aurora','Aurora / Northern Lights','Blurred bands of light sway like the northern lights. Best for dark backgrounds.'],
['grain-overlay','Grain / Film Noise Overlay','Fine grain flickers over the page, like old film. Best for editorial sites.'],
- ['scanline','Scanline Effect','CRT horizontal lines with optional sweep beam, curvature, and phosphor glow.'],
+ ['scanline','Scanline Effect','Dark lines and a sweeping beam imitate an old TV screen. Best for retro sites.'],
['light-leak','Light Leak','Warm gradient fires at random irregular intervals — analog film camera aesthetic.'],
['starfield','Starfield / Space Particles','Stars drift outward from center with parallax depth — slow ambient speed, never hyperspace.'],
['breathing-glow','Breathing / Pulsing Glow','Radial glow expands and contracts on a 5-second breath cycle — calm resting state.'],