Skip to content

Claude's answers, rendered: Markdown, math, charts and diagrams drawn in the Claude Code terminal. Independent project, not affiliated with Anthropic.

TypeScript claude-code-mod

README hero: an animated GIF of the site's first answer

razorback1659ab5b6b76f0
diff --git a/README.md b/README.md
index 65587fe..a73e0d3 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,8 @@
-<img alt="Introducing Intelligent UI" src="outcomes/samples/intelligent-ui.png" width="100%">
+<picture>
+ <source media="(prefers-color-scheme: dark)" srcset="outcomes/out/hero-dark.gif">
+ <source media="(prefers-color-scheme: light)" srcset="outcomes/out/hero-light.gif">
+ <img alt="Claude Code: a prompt asks Claude to show what Markdown it can draw, and the answer draws as one rendered picture: a cover image, a heading, a table, LaTeX math, a code block with syntax colours, a task list and a note" src="outcomes/out/hero-light.gif" width="100%">
+</picture>
# Intelligent UI for Claude Code
diff --git a/outcomes/gif.sh b/outcomes/gif.sh
new file mode 100755
index 0000000..4153f24
--- /dev/null
+++ b/outcomes/gif.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Makes the README's hero GIFs (outcomes/out/hero-dark.gif, hero-light.gif):
+# the site's first hero answer with its animation (site/index.html), the
+# picture at 0.8 of its width so the whole window fits with no scroll, at
+# 2x density, then made 1400 px wide with no dither: about 1 MB each.
+# Usage: outcomes/gif.sh (needs node with playwright, python3 with Pillow
+# and libimagequant; the site's renders: site/build.sh)
+set -eu
+here=$(cd "$(dirname "$0")" && pwd)
+root=$(dirname "$here")
+work="$here/.work/gif"
+pw=${PW_ROOT:-$(npm root -g)}
+for theme in dark light; do
+ rm -rf "$work/$theme"
+ PW_ROOT="$pw" node "$here/gif/capture.mjs" "$root" "$work/$theme" "$theme" 25 0.8 2
+ python3 -I "$here/gif/encode.py" "$work/$theme" "$here/out/hero-$theme.gif" 1400 none
+done
diff --git a/outcomes/gif/capture.mjs b/outcomes/gif/capture.mjs
new file mode 100644
index 0000000..e5bfba7
--- /dev/null
+++ b/outcomes/gif/capture.mjs
@@ -0,0 +1,110 @@
+// Records the site's first hero answer (its animation from site/index.html) as PNG
+// frames, one theme at a time. Usage: node capture.mjs <repo> <out dir> <theme> [fps] [scale] [density]
+// The frames are drawn from a timeline (frameAt), not in real time, so none is dropped.
+import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
+import { createRequire } from "node:module";
+const require = createRequire(process.env.PW_ROOT + "/");
+const { chromium } = require("playwright");
+
+const [repo, out, theme, fpsArg, scaleArg, dsfArg] = process.argv.slice(2);
+const fps = Number(fpsArg || 25), scale = Number(scaleArg || 0.8), dsf = Number(dsfArg || 2);
+const html = readFileSync(`${repo}/site/index.html`, "utf8");
+const css = html.slice(html.indexOf("<style>") + 7, html.indexOf("</style>"));
+const js = readFileSync(`${repo}/site/assets/answers.js`, "utf8");
+const answers = JSON.parse(js.slice(js.indexOf("["), js.lastIndexOf("]") + 1));
+const a = answers.find((x) => x.group === "hero");
+// GitHub's page colours, so the window sits on the README as on the site.
+const pageBg = theme === "dark" ? "#0d1117" : "#ffffff";
+const W = 1000, PAD = 28;
+
+const page = `<!doctype html><html data-theme="${theme}"><head><meta charset="utf-8">
+<style>${css}
+ body { background: ${pageBg}; min-height: 0; }
+ #box { padding: ${PAD}px; width: ${W}px; }
+ /* The timeline sets every state itself. */
+ *, *::before, *::after { transition: none !important; animation: none !important; }
+ /* The raw render is taller than the site's (empty room under the answer): cut at the box. */
+ .t-pic { overflow: hidden; }
+ .t-pic img { height: auto; bottom: auto; }
+ :root[data-theme="dark"] { --shadow: 0 18px 40px -18px rgba(0,0,0,.8); }
+ :root[data-theme="light"] { --shadow: 0 18px 40px -18px rgba(0,0,0,.28); }
+</style></head><body><div id="box"></div></body></html>`;
+
+const browser = await chromium.launch();
+const tab = await browser.newPage({ viewport: { width: W, height: 1400 }, deviceScaleFactor: dsf });
+mkdirSync(out, { recursive: true });
+writeFileSync(`${out}/page.html`, page);
+await tab.goto(`file://${out}/page.html`);
+// The lossless render (outcomes/build.sh), else the site's WebP.
+const raw = `${repo}/outcomes/out/raw/${a.name}-${theme}-1.png`;
+const pic = `file://${existsSync(raw) ? raw : `${repo}/site/assets/render/${a.name}-${theme}.webp`}`;
+const length = await tab.evaluate(({ a, pic, scale }) => {
+ const w = a.frame * scale;
+ const mascot = '<svg viewBox="0 0 75 48"><g fill="#d77757"><rect x="9" width="57" height="36"/><rect y="20" width="75" height="8"/><rect x="9" y="36" width="4" height="12"/><rect x="18" y="36" width="4" height="12"/><rect x="52" y="36" width="4" height="12"/><rect x="61" y="36" width="4" height="12"/></g><g fill="#050302"><rect x="18" y="8" width="4" height="12"/><rect x="52" y="8" width="4" height="12"/></g></svg>';
+ const tri = '<svg viewBox="0 0 4.2 5.2"><path d="M0 0l4.2 2.6L0 5.2z"/></svg>';
+ document.getElementById("box").innerHTML = `<div class="t-wrap">
+ <div class="term full" style="--f:${a.frame + 40};--w:${w};--ar:${1 / a.ratio};--dot:calc(var(--pt) * ${w * a.bullet})">
+ <div class="t-bar"><span class="t-lights"><i></i><i></i><i></i></span><span class="t-title">Claude Code</span><span class="t-key">⌥⌘1</span></div>
+ <div class="t-body"><div class="t-scroll">
+ <div class="t-head">${mascot}<div><b>Claude Code</b> <span class="t-dim">v2.1.301</span><br><span class="t-dim">Opus 5.5 with high effort · Claude Max</span><br><span class="t-dim">~/projects/cc-intelligent-ui ·</span> <span class="t-green">/rc</span></div></div>
+ <div class="t-ask">❯ <span class="q"></span></div>
+ <div class="t-answer">
+ <span class="t-spin"><b>✻</b> <i>Brewing…</i> <span></span></span>
+ <span class="t-dot">●</span>
+ <div class="t-pic"><img src="${pic}"></div>
+ </div>
+ <div class="t-brew">✻ Brewed for ${a.brew}s</div></div>
+ <div class="t-status">● high · /effort</div><div class="t-rule"></div><div class="t-input">❯ <span class="in"></span><span class="t-cur"></span></div><div class="t-rule"></div><div class="t-mode"><b>${tri}${tri} auto mode on</b> (shift+tab to cycle)</div>
+ </div>
+ </div></div>`;
+ const t = document.querySelector(".term");
+ const $ = (s) => t.querySelector(s);
+ const q = $(".q"), input = $(".in"), cur = $(".t-cur"), ask = $(".t-ask"), spinEl = $(".t-spin"), spin = $(".t-spin b"), secs = $(".t-spin span");
+ const dot = $(".t-dot"), picEl = $(".t-pic"), brew = $(".t-brew");
+
+ // The site's steps (site/index.html, play()), as times in ms.
+ const key = (i) => 30 + (i % 3) * 8, chars = [...a.ask];
+ const T0 = 450, typed = chars.reduce((n, _, i) => n + key(i), 0);
+ const sent = T0 + typed + 320, drawn = sent + 12 * 110, ms = 900 + a.ratio * 600;
+ const done = drawn + 1000 + a.ratio * 600, HOLD = 3000;
+ const ease = (p) => (p < 0.5 ? 4 * p ** 3 : 1 - (2 - 2 * p) ** 3 / 2);
+ const fade = (from, dur, now) => Math.max(0, Math.min(1, (now - from) / dur));
+ const glyphs = "·✢✳✶✻✽✻✶✳✢";
+
+ window.frameAt = (now) => {
+ // The prompt as typed so far, in the input box.
+ let n = 0, at = T0;
+ while (n < chars.length && now >= at + key(n)) { at += key(n); n++; }
+ const typing = now >= T0 && now < sent;
+ input.textContent = now < sent ? chars.slice(0, now >= T0 ? n : 0).join("") : "";
+ // The cursor blinks (1.05 s) but not while typing.
+ cur.style.opacity = typing || now % 1050 < 525 ? 1 : 0;
+ q.textContent = now >= sent ? a.ask : "";
+ ask.style.opacity = fade(sent, 300, now);
+ spinEl.style.opacity = now < sent ? 0 : now < drawn ? fade(sent, 300, now) : 1 - fade(drawn, 300, now);
+ const step = Math.min(11, Math.floor((now - sent) / 110));
+ spin.textContent = glyphs[Math.max(0, step) % glyphs.length];
+ secs.textContent = `(${1 + Math.floor(Math.max(0, step) / 9)}s · esc to interrupt)`;
+ dot.style.opacity = now < drawn ? 0 : fade(drawn, 300, now);
+ picEl.style.opacity = now < drawn ? 0 : fade(drawn, 350, now);
+ picEl.style.clipPath = now < drawn ? "inset(0 0 100% 0)" : `inset(0 0 ${(1 - ease(Math.min((now - drawn) / ms, 1))) * 100}% 0)`;
+ brew.style.opacity = now < done ? 0 : fade(done, 300, now);
+ };
+ // One height: the finished answer's, so the window never moves.
+ window.frameAt(done + 1000);
+ t.style.height = t.offsetHeight + "px";
+ return done + HOLD;
+}, { a, pic, scale });
+
+await tab.waitForFunction(() => document.querySelector(".t-pic img").complete);
+await tab.evaluate(() => document.fonts.ready);
+mkdirSync(out, { recursive: true });
+const box = await tab.$("#box");
+const count = Math.round((length / 1000) * fps);
+for (let i = 0; i < count; i++) {
+ await tab.evaluate((now) => window.frameAt(now), (i * 1000) / fps);
+ await box.screenshot({ path: `${out}/f${String(i).padStart(4, "0")}.png` });
+}
+writeFileSync(`${out}/info.json`, JSON.stringify({ fps, count, length }));
+await browser.close();
+console.log(`${theme}: ${count} frames, ${length} ms`);
diff --git a/outcomes/gif/encode.py b/outcomes/gif/encode.py
new file mode 100644
index 0000000..31cbcd5
--- /dev/null
+++ b/outcomes/gif/encode.py
@@ -0,0 +1,39 @@
+# Frames (capture.mjs) to one looping GIF: one palette for all frames (from a
+# montage of key frames, libimagequant), Floyd-Steinberg dither (fs) or none,
+# identical frames merged.
+# Usage: python3 encode.py <frames dir> <out.gif> [width] [fs|none]
+import glob, json, sys
+from PIL import Image, ImageChops
+
+src, out = sys.argv[1], sys.argv[2]
+width = int(sys.argv[3]) if len(sys.argv) > 3 else 0
+DITHER = Image.Dither.FLOYDSTEINBERG if (sys.argv[4] if len(sys.argv) > 4 else 'fs') == 'fs' else Image.Dither.NONE
+info = json.load(open(f"{src}/info.json"))
+step = round(1000 / info["fps"])
+files = sorted(glob.glob(f"{src}/f*.png"))
+frames = [Image.open(f).convert("RGB") for f in files]
+if width:
+ h = round(frames[0].height * width / frames[0].width)
+ frames = [f.resize((width, h), Image.LANCZOS) for f in frames]
+
+# The palette: the finished frame (all the colours of the answer) and a frame mid-draw.
+keys = [frames[-1], frames[len(frames) // 2], frames[len(frames) // 3]]
+w, h = frames[0].size
+montage = Image.new("RGB", (w, h * len(keys)))
+for i, k in enumerate(keys):
+ montage.paste(k, (0, h * i))
+pal = montage.quantize(colors=256, method=Image.Quantize.LIBIMAGEQUANT)
+
+out_frames, durations = [], []
+prev = None
+for f in frames:
+ q = f.quantize(palette=pal, dither=DITHER)
+ if prev is not None and ImageChops.difference(q.convert("RGB"), prev.convert("RGB")).getbbox() is None:
+ durations[-1] += step
+ continue
+ out_frames.append(q)
+ durations.append(step)
+ prev = q
+
+out_frames[0].save(out, save_all=True, append_images=out_frames[1:], duration=durations, loop=0, optimize=False, disposal=1)
+print(out, len(out_frames), "frames", f"{w}x{h}")
diff --git a/outcomes/out/hero-dark.gif b/outcomes/out/hero-dark.gif
new file mode 100644
index 0000000..faecb95
Binary files /dev/null and b/outcomes/out/hero-dark.gif differ
diff --git a/outcomes/out/hero-light.gif b/outcomes/out/hero-light.gif
new file mode 100644
index 0000000..0686492
Binary files /dev/null and b/outcomes/out/hero-light.gif differ