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

Gallery: one height for the math and diagrams pair and the site's cards

razorback16a4e63b9726a6
diff --git a/README.md b/README.md
index a73e0d3..1b98833 100644
--- a/README.md
+++ b/README.md
@@ -75,7 +75,7 @@ In other terminals, the mod shows the normal text. Refer to [Install](docs/insta
<picture>
<source media="(prefers-color-scheme: dark)" srcset="outcomes/out/2-math-dark.png">
<source media="(prefers-color-scheme: light)" srcset="outcomes/out/2-math-light.png">
- <img alt="Typeset LaTeX math in Claude Code: the Gaussian integral, Maxwell's equations, a rotation matrix and a piecewise function" src="outcomes/out/2-math-light.png" width="100%">
+ <img alt="Typeset LaTeX math in Claude Code: the Gaussian integral, Maxwell's equations, a rotation matrix, a piecewise function, the Fourier transform and the Schrödinger equation" src="outcomes/out/2-math-light.png" width="100%">
</picture>
</td>
</tr>
diff --git a/docs/gallery.md b/docs/gallery.md
index c7ba77f..fba7232 100644
--- a/docs/gallery.md
+++ b/docs/gallery.md
@@ -24,12 +24,12 @@ Headings, an image, a table, inline math, a code block with syntax colours, a ta
## LaTeX math that reads like a paper
-Euler's identity, the Gaussian integral, Maxwell's equations, a matrix and a piecewise function.
+Euler's identity, the Gaussian integral, Maxwell's equations, a matrix, a piecewise function, the Fourier transform and the Schrödinger equation.
<picture>
<source media="(prefers-color-scheme: dark)" srcset="../outcomes/out/2-math-dark.png">
<source media="(prefers-color-scheme: light)" srcset="../outcomes/out/2-math-light.png">
- <img alt="Typeset LaTeX math in Claude Code: the Gaussian integral, Maxwell's equations, a rotation matrix and a piecewise function" src="../outcomes/out/2-math-light.png" width="800">
+ <img alt="Typeset LaTeX math in Claude Code: the Gaussian integral, Maxwell's equations, a rotation matrix, a piecewise function, the Fourier transform and the Schrödinger equation" src="../outcomes/out/2-math-light.png" width="800">
</picture>
## A fractal, calculated as it draws
diff --git a/outcomes/build.sh b/outcomes/build.sh
index 4499224..2480112 100755
--- a/outcomes/build.sh
+++ b/outcomes/build.sh
@@ -85,17 +85,28 @@ ls "$out/raw"
# The bullet offset of a sample (pt), from sizes().
bullet() { cut -d' ' -f2 "$work/$1.top"; }
-# Frames: headline and the prompt for each sample.
-frame() { # name title ask
+# The room (pt) that makes the window of sample $1 as tall as that of $2: the
+# README shows them side by side (0 when $1 is the taller).
+pad() {
+ python3 - "$out/raw/$1-dark-1.png" "$out/raw/$2-dark-1.png" "$img_w" <<'EOF'
+import struct, sys
+size = lambda f: struct.unpack(">II", open(f, "rb").read(24)[16:24])
+(w1, h1), (w2, h2) = size(sys.argv[1]), size(sys.argv[2])
+print(round(max(0, h2 / w2 - h1 / w1) * float(sys.argv[3]), 2))
+EOF
+}
+
+# Frames: headline and the prompt for each sample (and its pad).
+frame() { # name title ask [pad]
for mode in dark light; do
typst compile --root / --ppi 216 --input img="$out/raw/$1-$mode-1.png" --input mode=$mode --input bullet="$(bullet "$1")" \
- --input img-w="$img_w" --input title="$2" --input ask="$3" "$here/frame.typ" "$out/$1-$mode.png" 2>/dev/null
+ --input img-w="$img_w" --input title="$2" --input ask="$3" --input pad="${4:-0}" "$here/frame.typ" "$out/$1-$mode.png" 2>/dev/null
done
}
frame 1-overview "Real Markdown, right in the terminal" \
"show me what Markdown you can draw"
frame 2-math "LaTeX math that reads like a paper" \
- "write out Maxwell's equations"
+ "write out Maxwell's equations" "$(pad 2-math 6-diagrams)"
frame 3-mandelbrot "A fractal, calculated as it draws" \
"draw the Mandelbrot set"
frame 4-fractal "Recursion and colour, live" \
@@ -103,7 +114,7 @@ frame 4-fractal "Recursion and colour, live" \
frame 5-plot "Plots with axes and a legend" \
"plot a damped oscillator"
frame 6-diagrams "Flow charts and commutative diagrams" \
- "diagram the agent loop and the first isomorphism theorem"
+ "diagram the agent loop and the first isomorphism theorem" "$(pad 6-diagrams 2-math)"
ls "$out"
# Heroes: each answer in a dark and a light terminal.
diff --git a/outcomes/frame.typ b/outcomes/frame.typ
index 682a714..a4176e4 100644
--- a/outcomes/frame.typ
+++ b/outcomes/frame.typ
@@ -1,5 +1,5 @@
// Outcome frame: Intelligent UI renders in terminal windows, with a headline.
-// One window: --input img=<abs png> --input mode=dark|light --input ask=..
+// One window: --input img=<abs png> --input mode=dark|light --input ask=.. [--input pad=<pt>]
// Hero (two): --input layout=hero --input img-dark=.. --input img-light=.. --input ask=..
// Both: --input title=.. (typst compile --root / frame.typ out.png)
#let inp = sys.inputs
@@ -57,7 +57,8 @@
image(img, width: img-w))
#v(10pt)
#text(fill: c.dim)[✻ Brewed for 6s]
- #v(26pt)
+ // `pad` (pt): more empty room, so two windows side by side have one height.
+ #v(26pt + float(inp.at("pad", default: "0")) * 1pt)
#align(right, text(fill: c.dim)[● high · /effort])
#v(-4pt)
#rule
diff --git a/outcomes/gif.sh b/outcomes/gif.sh
index 81eed13..94e9736 100755
--- a/outcomes/gif.sh
+++ b/outcomes/gif.sh
@@ -1,7 +1,7 @@
#!/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), with
-# no header, the answer cut after its code block (0.8285 of its width) and
+# no header, the answer cut after its code block (0.85 of its width) and
# the picture at 0.65 of its width, at 2x density, then made 1200 px wide
# with no dither.
# Usage: outcomes/gif.sh (needs node with playwright and sharp, python3 with Pillow
@@ -13,6 +13,6 @@ 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.65 2 0.8285
+ PW_ROOT="$pw" node "$here/gif/capture.mjs" "$root" "$work/$theme" "$theme" 25 0.65 2 0.85
python3 -I "$here/gif/encode.py" "$work/$theme" "$here/out/hero-$theme.gif" 1200 none
done
diff --git a/outcomes/gif/capture.mjs b/outcomes/gif/capture.mjs
index f3058c1..862f67b 100644
--- a/outcomes/gif/capture.mjs
+++ b/outcomes/gif/capture.mjs
@@ -27,9 +27,9 @@ const page = `<!doctype html><html data-theme="${theme}"><head><meta charset="ut
#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; }
+ /* The picture at its own pixels (see pic.png below); the clip-path cuts it at the box's
+ bottom (the raw render is taller: room under the answer), not at its other edges. */
+ .t-pic img { height: auto; bottom: auto; right: auto; }
/* No empty room between the answer and the input box. */
.t-status { padding-top: calc(var(--pt) * 10); }
:root[data-theme="dark"] { --shadow: 0 18px 40px -18px rgba(0,0,0,.8); }
@@ -91,7 +91,7 @@ const length = await tab.evaluate(({ a, pic, scale }) => {
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)`;
+ picEl.style.clipPath = now < drawn ? "inset(0 0 100% 0)" : `inset(-4px -4px ${(1 - ease(Math.min((now - drawn) / ms, 1))) * 100}% -4px)`;
brew.style.opacity = now < done ? 0 : fade(done, 300, now);
};
// One height: the finished answer's, so the window never moves.
@@ -100,11 +100,19 @@ const length = await tab.evaluate(({ a, pic, scale }) => {
return done + HOLD;
}, { a, pic, scale });
-// The picture made as wide as its box in pixels (Lanczos), as Chrome's own downscale
-// of a large render loses the top rows of its first line.
+// The picture made as wide as its box in pixels (Lanczos), and drawn at whole pixels:
+// Chrome resamples a picture at a fraction of a pixel, which loses its thin edge lines
+// (a code block's left border is one column at x 0).
const px = await tab.evaluate((dsf) => Math.round(document.querySelector(".t-pic").getBoundingClientRect().width * dsf), dsf);
await sharp(new URL(pic).pathname).resize({ width: px, kernel: "lanczos3" }).png().toFile(`${out}/pic.png`);
-await tab.evaluate((src) => { document.querySelector(".t-pic img").src = src; }, `file://${out}/pic.png`);
+await tab.evaluate(({ src, px, dsf }) => {
+ const img = document.querySelector(".t-pic img");
+ img.src = src;
+ img.style.width = `${px / dsf}px`;
+ const r = img.getBoundingClientRect();
+ const snap = (v) => (Math.round(v * dsf) - v * dsf) / dsf;
+ img.style.transform = `translate(${snap(r.left)}px, ${snap(r.top)}px)`;
+}, { src: `file://${out}/pic.png`, px, dsf });
await tab.waitForFunction(() => document.querySelector(".t-pic img").complete);
await tab.evaluate(() => document.fonts.ready);
mkdirSync(out, { recursive: true });
diff --git a/outcomes/out/0-hero-1-attention.png b/outcomes/out/0-hero-1-attention.png
index 5670c67..47ed9d2 100644
Binary files a/outcomes/out/0-hero-1-attention.png and b/outcomes/out/0-hero-1-attention.png differ
diff --git a/outcomes/out/0-hero-2-latency.png b/outcomes/out/0-hero-2-latency.png
index 3b9282b..fdc060f 100644
Binary files a/outcomes/out/0-hero-2-latency.png and b/outcomes/out/0-hero-2-latency.png differ
diff --git a/outcomes/out/0-hero-3-rebase.png b/outcomes/out/0-hero-3-rebase.png
index 49eae4d..2eca015 100644
Binary files a/outcomes/out/0-hero-3-rebase.png and b/outcomes/out/0-hero-3-rebase.png differ
diff --git a/outcomes/out/1-overview-dark.png b/outcomes/out/1-overview-dark.png
index a8c9ae2..33a911d 100644
Binary files a/outcomes/out/1-overview-dark.png and b/outcomes/out/1-overview-dark.png differ
diff --git a/outcomes/out/1-overview-light.png b/outcomes/out/1-overview-light.png
index cabc4b8..e0b6b80 100644
Binary files a/outcomes/out/1-overview-light.png and b/outcomes/out/1-overview-light.png differ
diff --git a/outcomes/out/2-math-dark.png b/outcomes/out/2-math-dark.png
index 98f857e..70656f6 100644
Binary files a/outcomes/out/2-math-dark.png and b/outcomes/out/2-math-dark.png differ
diff --git a/outcomes/out/2-math-light.png b/outcomes/out/2-math-light.png
index f52fd20..e0bd693 100644
Binary files a/outcomes/out/2-math-light.png and b/outcomes/out/2-math-light.png differ
diff --git a/outcomes/out/3-mandelbrot-dark.png b/outcomes/out/3-mandelbrot-dark.png
index 9d06511..8bf874d 100644
Binary files a/outcomes/out/3-mandelbrot-dark.png and b/outcomes/out/3-mandelbrot-dark.png differ
diff --git a/outcomes/out/3-mandelbrot-light.png b/outcomes/out/3-mandelbrot-light.png
index 3dab117..cc4893f 100644
Binary files a/outcomes/out/3-mandelbrot-light.png and b/outcomes/out/3-mandelbrot-light.png differ
diff --git a/outcomes/out/4-fractal-dark.png b/outcomes/out/4-fractal-dark.png
index 3648979..d95f1e6 100644
Binary files a/outcomes/out/4-fractal-dark.png and b/outcomes/out/4-fractal-dark.png differ
diff --git a/outcomes/out/4-fractal-light.png b/outcomes/out/4-fractal-light.png
index 799e1d2..0d55aec 100644
Binary files a/outcomes/out/4-fractal-light.png and b/outcomes/out/4-fractal-light.png differ
diff --git a/outcomes/out/5-plot-dark.png b/outcomes/out/5-plot-dark.png
index df0a52c..e128ee3 100644
Binary files a/outcomes/out/5-plot-dark.png and b/outcomes/out/5-plot-dark.png differ
diff --git a/outcomes/out/5-plot-light.png b/outcomes/out/5-plot-light.png
index 6c9490b..7cfd87f 100644
Binary files a/outcomes/out/5-plot-light.png and b/outcomes/out/5-plot-light.png differ
diff --git a/outcomes/out/6-diagrams-dark.png b/outcomes/out/6-diagrams-dark.png
index 3d002e4..d123681 100644
Binary files a/outcomes/out/6-diagrams-dark.png and b/outcomes/out/6-diagrams-dark.png differ
diff --git a/outcomes/out/6-diagrams-light.png b/outcomes/out/6-diagrams-light.png
index 1f9abba..9a594ed 100644
Binary files a/outcomes/out/6-diagrams-light.png and b/outcomes/out/6-diagrams-light.png differ
diff --git a/outcomes/out/hero-dark.gif b/outcomes/out/hero-dark.gif
index 46c88be..8fddc96 100644
Binary files a/outcomes/out/hero-dark.gif and b/outcomes/out/hero-dark.gif differ
diff --git a/outcomes/out/hero-light.gif b/outcomes/out/hero-light.gif
index dc97cc5..5b2a505 100644
Binary files a/outcomes/out/hero-light.gif and b/outcomes/out/hero-light.gif differ
diff --git a/outcomes/samples/2-math.md b/outcomes/samples/2-math.md
index 356a047..9f85a07 100644
--- a/outcomes/samples/2-math.md
+++ b/outcomes/samples/2-math.md
@@ -20,3 +20,11 @@ R(\theta) = \begin{pmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta
\qquad
\lvert x \rvert = \begin{cases} x & x \ge 0 \\ -x & x < 0 \end{cases}
$$
+
+The Fourier transform and the Schrödinger equation:
+
+$$
+\hat{f}(\xi) = \int_{-\infty}^{\infty} f(x)\, e^{-2\pi i x \xi}\,dx,
+\qquad
+i\hbar \frac{\partial}{\partial t} \Psi(x, t) = \hat{H}\, \Psi(x, t)
+$$
diff --git a/site/assets/answers.js b/site/assets/answers.js
index d574d02..d304d2c 100644
--- a/site/assets/answers.js
+++ b/site/assets/answers.js
@@ -6,9 +6,9 @@ window.IUI_ANSWERS = [
"label": "Markdown",
"ask": "show me what Markdown you can draw",
"brew": 6,
- "v": "73f9e536",
+ "v": "2d3feb58",
"frame": 600,
- "ratio": 0.94563,
+ "ratio": 0.96625,
"bullet": 0.00847
},
{
@@ -50,9 +50,9 @@ window.IUI_ANSWERS = [
"label": "LaTeX math",
"ask": "write out Maxwell's equations",
"brew": 3,
- "v": "960ea72a",
+ "v": "b81fd5bb",
"frame": 600,
- "ratio": 0.31833,
+ "ratio": 0.415,
"bullet": 0.02542
},
{
diff --git a/site/assets/render/1-overview-dark.webp b/site/assets/render/1-overview-dark.webp
index 75e5cbc..19f60b0 100644
Binary files a/site/assets/render/1-overview-dark.webp and b/site/assets/render/1-overview-dark.webp differ
diff --git a/site/assets/render/1-overview-light.webp b/site/assets/render/1-overview-light.webp
index 67e1935..0dc3b56 100644
Binary files a/site/assets/render/1-overview-light.webp and b/site/assets/render/1-overview-light.webp differ
diff --git a/site/assets/render/2-math-dark.webp b/site/assets/render/2-math-dark.webp
index dc5373d..9e78938 100644
Binary files a/site/assets/render/2-math-dark.webp and b/site/assets/render/2-math-dark.webp differ
diff --git a/site/assets/render/2-math-light.webp b/site/assets/render/2-math-light.webp
index 656ea0a..c59ddd4 100644
Binary files a/site/assets/render/2-math-light.webp and b/site/assets/render/2-math-light.webp differ
diff --git a/site/index.html b/site/index.html
index 960b0e8..3403b4e 100644
--- a/site/index.html
+++ b/site/index.html
@@ -206,8 +206,12 @@
/* ---------- Gallery ---------- */
.gallery { padding: clamp(96px, 14vw, 160px) 0 40px; }
.gallery .kicker { text-align: center; margin: 0 0 44px; font: italic 400 clamp(30px, 4vw, 44px)/1 var(--serif); color: var(--muted); }
- .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); gap: 32px 28px; align-items: start; }
- .card { margin: 0; }
+ /* All the cards have one height (the tallest's); a shorter answer leaves room under it, as a terminal does. */
+ .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); grid-auto-rows: 1fr; gap: 32px 28px; }
+ .card { margin: 0; display: flex; flex-direction: column; }
+ .card > .t-wrap { flex: 1; display: flex; flex-direction: column; }
+ .card .term { flex: 1; display: flex; flex-direction: column; }
+ .card .t-body { flex: 1; }
.card figcaption {
margin-top: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
font: 500 12px/1 var(--mono); letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted);
@@ -289,7 +293,7 @@
</div>
</footer>
-<script src="assets/answers.js?v=79feb452"></script>
+<script src="assets/answers.js?v=c207e323"></script>
<script>
(() => {
const answers = window.IUI_ANSWERS;