Skip to content

majiayu000/spellbook / skills/ascii-backdrop

ascii-backdrop

Verified

Turn any subject into an animated ASCII backdrop behind a UI, like a dark prompt page with jellyfish drawn in drifting characters, or a swarm of colour-tile bodies that veer away from the cursor. The subject is open-ended: creatures, objects, particles, smoke, a word or logo, an image or video, a per-pixel field, a shaded 3D solid, or your own canvas draw function. Six print modes can be mixed: brightness glyphs, edge-following glyphs, shape-matched glyphs, braille dots, ordered-dither dots and colour tiles; plus cursor glow, click ripples, a CRT terminal finish, and two page helpers (text decode and image-to-ASCII dissolve). Ships a dependency-free JS engine with HTML and React wiring. Use when the user asks for an ASCII background, ASCII art animation, glyph or braille backdrop, text scramble/decode, or an ASCII image reveal, or says 'ASCII 背景' / '字符画动效'.

FileKindSize
SKILL.mdskill md11.4 KB
assets/ascii-backdrop.jsscript53.1 KB
assets/demo.htmlother14.8 KB
scripts/check.mjsexecutablescript2.2 KB
scripts/regression.mjsscript36.5 KB

assets/demo.html

View on GitHub
<title>ASCII Backdrop</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="claude:viewport-fit-sides" content="cover">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500&family=JetBrains+Mono:wght@400;500&display=swap">
<style>
  :root {
    --bg: #05070b; --panel: rgba(14, 18, 26, 0.72); --line: rgba(160, 200, 255, 0.12);
    --fg: #e6edf5; --dim: #8a96a8; --accent: #8fd9cf; --accent2: #b9a6ff;
    --mono: "JetBrains Mono", ui-monospace, Menlo, monospace; --sans: Geist, system-ui, sans-serif;
    color-scheme: dark;
  }
  html, body { height: 100%; }
  body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--sans); overflow: hidden; }
  #bd { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
  .app { position: relative; z-index: 1; height: 100%; display: grid; grid-template-columns: 56px 1fr; }
  .rail { border-right: 1px solid var(--line); background: rgba(5, 7, 11, 0.55); display: flex; flex-direction: column; align-items: center; gap: 18px; padding-block: 18px; }
  .rail i { width: 18px; height: 18px; border: 1.4px solid var(--dim); border-radius: 5px; opacity: .7; }
  .rail i:first-child { border-color: var(--fg); background: rgba(255,255,255,.06); }
  .rail .sp { flex: 1; }
  main { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .hist { position: absolute; top: 18px; right: 20px; font: 400 12px var(--sans); color: var(--dim); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; background: var(--panel); backdrop-filter: blur(8px); }
  .hist kbd { font: 400 10px var(--mono); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; margin-left: 8px; }
  .hello { font: 400 12px var(--mono); color: var(--dim); display: flex; align-items: center; gap: 8px; }
  .hello::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
  h1 { margin: 0; font-weight: 300; font-size: clamp(30px, 4.4vw, 52px); letter-spacing: -0.02em; text-wrap: balance; text-align: center; }
  h1 span { background: linear-gradient(90deg, var(--accent2), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
  .box { width: min(560px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px 16px 12px; backdrop-filter: blur(10px); box-shadow: 0 20px 60px rgba(0,0,0,.45); }
  .box textarea { width: 100%; resize: none; border: 0; outline: 0; background: none; color: var(--fg); font: 400 14px var(--sans); height: 44px; }
  .box textarea::placeholder { color: var(--dim); }
  .row { display: flex; align-items: center; gap: 10px; font: 400 11px var(--mono); color: var(--dim); }
  .row .grow { flex: 1; }
  .pill { border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; color: var(--fg); }
  .send { width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line); display: grid; place-items: center; color: var(--fg); }
  .chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
  .chips span { font: 400 11px var(--mono); color: var(--dim); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; background: var(--panel); backdrop-filter: blur(6px); }
  .ctl { position: absolute; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); left: 16px; right: 16px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
  .ctl button, .ctl label { font: 400 11px var(--mono); color: var(--dim); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; backdrop-filter: blur(6px); }
  .ctl button[aria-pressed="true"] { color: var(--bg); background: var(--accent); border-color: var(--accent); }
  .ctl input { display: none; }
  .ctl .sep { width: 1px; background: var(--line); margin: 0 4px; }
  .ctl .group { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
  .ctl { flex-direction: column; align-items: center; }
  .card { position: absolute; right: 20px; bottom: calc(110px + env(safe-area-inset-bottom, 0px)); width: 240px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); backdrop-filter: blur(8px); }
  .card .frame { position: relative; aspect-ratio: 16 / 10; max-width: 100%; }
  .card img { display: block; width: 100%; height: 100%; object-fit: cover; }
  .card p { margin: 0; padding: 8px 10px; font: 400 11px var(--mono); color: var(--dim); }
  @media (max-width: 900px) { .card { display: none; } }
  @media (max-width: 640px) { .app { grid-template-columns: 1fr; } .rail { display: none; } .hist { display: none; } }
</style>

<canvas id="bd" aria-hidden="true"></canvas>
<div class="app">
  <nav class="rail" aria-hidden="true"><i></i><i></i><i></i><i></i><i></i><span class="sp"></span><i></i><i></i></nav>
  <main>
    <div class="hist">ascii-backdrop<kbd>demo</kbd></div>
    <div class="hello">Backdrop demo</div>
    <h1 id="title">any subject, in characters</h1>
    <div class="box">
      <textarea placeholder="Type here. The backdrop fades behind this box so text stays readable." aria-label="Sample input"></textarea>
      <div class="row"><span class="pill">+</span><span class="pill" id="modeLabel">glyph</span><span class="grow"></span><span>move or click to interact</span><span class="send">↗</span></div>
    </div>
    <div class="chips"><span>presets</span><span>text</span><span>image or video</span><span>custom draw()</span></div>
    <figure class="card" aria-label="Image reveal example">
      <div class="frame"><img id="revealImg" alt="Generated landscape used for the reveal example"></div>
      <p>hover: characters dissolve into the image</p>
    </figure>
    <div class="ctl" role="toolbar" aria-label="Backdrop">
      <div class="group">
        <button data-s="tiles">tiles</button>
        <button data-s="jellyfish">jellyfish</button>
        <button data-s="school">school</button>
        <button data-s="cloud">cloud</button>
        <button data-s="strands">kelp</button>
        <button data-s="fire">fire</button>
        <button data-s="solid">wireframe</button>
        <button data-s="sdf">3D solid</button>
        <button data-s="field">field</button>
        <button data-s="text">text</button>
        <label>image…<input type="file" accept="image/*,video/*" id="file"></label>
      </div>
      <div class="group">
        <button data-r="ramp">ramp</button>
        <button data-r="edges">edges</button>
        <button data-r="shape">shape match</button>
        <button data-r="braille">braille</button>
        <button data-r="dither">dither</button>
        <button data-k="kana" aria-pressed="false">kana</button>
        <button data-c="crt" aria-pressed="false">crt</button>
        <span class="sep"></span>
        <button data-p="abyss">abyss</button>
        <button data-p="ember">ember</button>
        <button data-p="mono">mono</button>
        <button data-p="phosphor">phosphor</button>
        <button data-p="amber">amber</button>
      </div>
    </div>
  </main>
</div>

<script src="ascii-backdrop.js"></script>
<script>
  const S = AsciiBackdrop.subjects;
  const PALETTES = AsciiBackdrop.PALETTES;
  // One composition for every subject: a hero below the prompt, one above, two faded at the sides.
  function scene(make) {
    return [
      { subject: make(1), x: 0.56, y: 0.76, scale: 0.72, depth: 1, drift: { x: 0.01, y: 0.012, phase: 0 } },
      { subject: make(2), x: 0.5, y: 0.17, scale: 0.5, depth: 0.8, drift: { x: 0.015, y: 0.015, phase: 2 } },
      { subject: make(3), x: 0.15, y: 0.3, scale: 0.42, depth: 0.45, timeOffset: 3, drift: { x: 0.02, y: 0.02, phase: 4 } },
      { subject: make(4), x: 0.87, y: 0.45, scale: 0.42, depth: 0.55, timeOffset: 6, drift: { x: 0.015, y: 0.025, phase: 1 } },
    ];
  }
  const plasma = (u, v, t) => 0.5 + 0.5 * Math.sin(10 * u + t) * Math.cos(8 * v - t * 0.7) * Math.sin(6 * Math.hypot(u, v) - t * 1.3);
  const SCENES = {
    jellyfish: () => scene((seed) => S.jellyfish({ seed, tentacles: 6 + seed })),
    school: () => scene((seed) => S.school({ seed })),
    cloud: () => scene((seed) => S.cloud({ seed })),
    strands: () => [{ subject: S.strands({ count: 14, seed: 1 }), x: 0.3, y: 0.8, scale: 0.9, depth: 0.9 }, { subject: S.strands({ count: 10, seed: 2 }), x: 0.78, y: 0.82, scale: 0.8, depth: 0.6 }],
    fire: () => [{ subject: S.rising({ seed: 5 }), x: 0.5, y: 0.66, scale: 1.0, depth: 1, speed: 1.6 }, { subject: S.rising({ seed: 8, count: 40 }), x: 0.15, y: 0.5, scale: 0.6, depth: 0.45 }, { subject: S.rising({ seed: 9, count: 40 }), x: 0.86, y: 0.5, scale: 0.6, depth: 0.5 }],
    solid: () => scene((seed) => S.solid({ seed, shape: seed % 2 ? 'icosa' : 'cube' })),
    sdf: () => [{ subject: S.sdf({ shape: 'torus' }), x: 0.53, y: 0.8, scale: 0.7, depth: 1 }, { subject: S.sdf({ shape: 'sphere', spin: 0.3 }), x: 0.14, y: 0.3, scale: 0.45, depth: 0.6 }, { subject: S.sdf({ shape: 'box', spin: 0.45 }), x: 0.86, y: 0.32, scale: 0.45, depth: 0.7 }],
    field: () => [{ subject: S.field(plasma, { resolution: 0.6 }), x: 0.5, y: 0.5, scale: 2.2, depth: 0.85 }],
    // Tile mode: coloured bodies over glyph ripples; move the cursor near one or click anywhere.
    tiles: () => ({
      options: { background: '#1b1a18', grid: 'dots', palette: ['#34322f', '#5f5c56', '#9a968e', '#e6e2da'], clear: { x: 0.5, y: 0.46, rx: 0.3, ry: 0.2, strength: 0.6 } },
      layers: [
        { subject: S.ripples(), x: 0.5, y: 0.5, scale: 1.9, depth: 0.7 },
        { subject: S.wanderers({ count: 7 }), mode: 'tile', x: 0.5, y: 0.5, scale: 1.7, depth: 1 },
      ],
    }),
    text: () => [{ subject: S.text('hello'), x: 0.5, y: 0.82, scale: 1.1, depth: 1 }, { subject: S.text('✦'), x: 0.15, y: 0.3, scale: 0.6, depth: 0.5 }, { subject: S.text('∞'), x: 0.86, y: 0.35, scale: 0.6, depth: 0.5 }],
  };

  const BASE = { background: '#05070b', grid: 'lines', clear: { x: 0.5, y: 0.46, rx: 0.3, ry: 0.2, strength: 0.85 } };
  const state = { scene: 'tiles', render: 'ramp', pal: 'abyss', kana: false, crt: false, image: null };
  const bd = AsciiBackdrop.create(document.getElementById('bd'), {
    interactive: true,
    pointerGlow: { radius: 110, strength: 0.35 },
    clear: BASE.clear,
  });
  bd.start();
  window.BD = bd;

  const press = (attr, val) => document.querySelectorAll(`[data-${attr}]`).forEach((b) => b.setAttribute('aria-pressed', String(b.dataset[attr] === val)));
  // Re-apply everything from state: scene layers, then the render mode on every non-tile layer.
  function apply() {
    const sc = state.image ? [{ subject: S.image(state.image, { motion: 'float' }), x: 0.5, y: 0.62, scale: 1.15, depth: 1 }] : SCENES[state.scene]();
    const layers = Array.isArray(sc) ? sc : sc.layers;
    const mode = state.render === 'braille' || state.render === 'dither' ? state.render : 'glyph';
    for (const L of layers) if ((L.mode || 'glyph') !== 'tile') L.mode = mode;
    bd.set(Object.assign({}, BASE, { palette: PALETTES[state.pal] }, (!Array.isArray(sc) && sc.options) || {}, {
      ramp: state.kana ? AsciiBackdrop.RAMPS.katakana : AsciiBackdrop.RAMPS.dense,
      glyph: { edges: state.render === 'edges', match: state.render === 'shape' ? 'shape' : 'ramp' },
      crt: state.crt ? { scanlines: 0.16, glow: 0.35, vignette: 0.35, flicker: 0.03 } : null,
    }));
    bd.setLayers(layers);
    press('s', state.image ? '' : state.scene); press('r', state.render); press('p', state.pal);
    document.querySelector('[data-k]').setAttribute('aria-pressed', String(state.kana));
    document.querySelector('[data-c]').setAttribute('aria-pressed', String(state.crt));
    document.getElementById('modeLabel').textContent = state.render;
    try { localStorage.setItem('bd-state', JSON.stringify(Object.assign({}, state, { image: null }))); } catch (e) {}
  }
  function releaseUpload() {
    const el = state.image;
    state.image = null;
    if (!el) return;
    const url = el.src, video = el.tagName === 'VIDEO';
    if (video) el.pause();
    el.removeAttribute('src');
    if (video) el.load();
    URL.revokeObjectURL(url);
  }
  document.querySelectorAll('[data-s]').forEach((b) => b.addEventListener('click', () => { releaseUpload(); state.scene = b.dataset.s; apply(); }));
  document.querySelectorAll('[data-r]').forEach((b) => b.addEventListener('click', () => { state.render = b.dataset.r; apply(); }));
  document.querySelectorAll('[data-p]').forEach((b) => b.addEventListener('click', () => { state.pal = b.dataset.p; apply(); }));
  document.querySelector('[data-k]').addEventListener('click', () => { state.kana = !state.kana; apply(); });
  document.querySelector('[data-c]').addEventListener('click', () => { state.crt = !state.crt; apply(); });
  document.getElementById('file').addEventListener('change', (e) => {
    const f = e.target.files[0];
    if (!f) return;
    releaseUpload();
    const url = URL.createObjectURL(f);
    let el;
    if (f.type.startsWith('video/')) { el = document.createElement('video'); el.src = url; el.muted = true; el.loop = true; el.playsInline = true; }
    else { el = new Image(); el.src = url; }
    state.image = el;
    apply();
    if (el.tagName === 'VIDEO') el.play().catch((error) => {
      if (state.image === el) console.error('Uploaded video playback failed:', error);
    });
  });
  try { Object.assign(state, JSON.parse(localStorage.getItem('bd-state') || '{}'), { image: null }); } catch (e) {}
  if (!SCENES[state.scene]) state.scene = 'tiles';
  apply();

  // Title decodes on load and again on hover.
  AsciiBackdrop.scramble(document.getElementById('title'), { trigger: 'load' });
  AsciiBackdrop.scramble(document.getElementById('title'), { trigger: 'hover' });

  // Reveal example: paint a small landscape in a canvas, use it as a same-origin image, dissolve on hover.
  (function () {
    const c = document.createElement('canvas'); c.width = 480; c.height = 300;
    const x = c.getContext('2d');
    const sky = x.createLinearGradient(0, 0, 0, 300); sky.addColorStop(0, '#1d2b4f'); sky.addColorStop(0.6, '#c9707a'); sky.addColorStop(1, '#f2c98a');
    x.fillStyle = sky; x.fillRect(0, 0, 480, 300);
    x.fillStyle = '#ffe9b8'; x.beginPath(); x.arc(330, 170, 46, 0, Math.PI * 2); x.fill();
    const hill = (col, base, amp, f) => { x.fillStyle = col; x.beginPath(); x.moveTo(0, 300); for (let i = 0; i <= 480; i += 8) x.lineTo(i, base - amp * Math.sin(i / f) - amp * 0.5 * Math.sin(i / (f * 0.37))); x.lineTo(480, 300); x.fill(); };
    hill('#5b4a6e', 210, 26, 60); hill('#33304a', 240, 20, 45); hill('#1a1a26', 270, 12, 30);
    const img = document.getElementById('revealImg');
    img.src = c.toDataURL();
    AsciiBackdrop.reveal(img, { trigger: 'hover', pattern: 'center' });
  })();
</script>
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall