Terminal run
terminal-runA command types itself, a spinner works, the output streams in with its checks and the file it made lights up.
Install
$ npx paper-motion add terminal-runWrites a scene to pieces/, wired to your brand folder.
Tune it, then add it to your kit
Parameters
cwd
command
working
format
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>terminal-run</title>
<!--
Code · terminal run (6.2 s). A command types itself at a prompt and runs: a spinner works, then the output streams
in line by line with its checks popping on, and the file it made lights up. The camera starts close on the prompt,
rides the output down and pushes in on the result.
Arrive 0–0.6 s · Type 0.6–1.5 s · Run 1.65–2.5 s · Output 2.5–3.7 s · Result 4.0 s · Hold to 6.2 s.
Vertical/square: the terminal is sized from the short side (vertical: ~31 columns, lines wrap like a real terminal,
taller window); the camera fits its width, follows the output's bottom edge and pushes in on the result, anchored left.
-->
<style>
#stage { overflow: hidden; }
.abs { position: absolute; box-sizing: border-box; }
#term { position: absolute; box-sizing: border-box; overflow: hidden; display: flex; flex-direction: column; }
.bar { display: flex; align-items: center; gap: 0.45em; padding: 0 1.2em; }
#out { position: relative; padding: 1.4em 1.8em; }
.ln { height: 1.8em; line-height: 1.8em; white-space: pre; position: relative; }
.ck { display: inline-block; width: 1.4em; }
.hl { position: absolute; left: -0.5em; top: 0.1em; bottom: 0.1em; border-radius: 0.3em; transform-origin: 0 50%; z-index: -1; }
.narrow .ln { height: auto; min-height: 1.8em; white-space: pre-wrap; }
.narrow .ln.ckr { display: flex; }
.narrow .ln.ckr > span:last-child { flex: 1; }
#caret { display: inline-block; width: 0.55em; height: 1.1em; vertical-align: -0.15em; }
</style>
</head>
<body>
<main id="stage">
<div id="bg" class="abs" style="inset:0"></div>
<div id="world"><div id="term"><div class="bar" id="bar"></div><div id="out"></div></div></div>
</main>
<script type="module">
import { scene, progress, ease, spring } from 'paper-motion';
import { camera } from 'paper-motion/kit';
import { loadBrand } from 'paper-motion/brand';
const CONFIG = {
background: null,
cwd: '~/launch',
command: 'npx paper-motion add push-in',
working: 'Resolving push-in',
output: [ // [check?, text]; a line with `result: true` lights up at the end
{ check: true, text: 'Found push-in · shot · 4 s' },
{ check: true, text: 'scene.html → pieces/push-in/scene.html', result: true },
{ check: true, text: 'brief.md → pieces/push-in/brief.md' },
{ check: true, text: 'Brand applied: paper-motion' },
{ text: '' },
{ text: 'Done in 0.8 s. Render it with', muted: true },
{ text: ' npx paper-motion render pieces/push-in', accent: true },
],
format: [1920, 1080],
};
const B = await loadBrand();
const [W, H] = CONFIG.format, SHORT = Math.min(W, H), D = 6.2;
const s = scene({ width: W, height: H, fps: 30, duration: D, background: B.color('ground') });
const bgId = CONFIG.background ?? B.set.entries.find((e) => e.shader && !e.image)?.id;
if (bgId) B.shader(s, '#bg', bgId);
document.querySelector('#bg').style.opacity = 0.3;
const $ = (id) => document.getElementById(id);
const DIST = SHORT * 0.62, K = 1 + DIST / (SHORT * 1.7);
const cam = camera($('stage'), $('world'), { perspective: SHORT * 1.7 });
const wide = W / H > 1.2, tall = H > W;
const FS = SHORT * (tall ? 0.031 : 0.026); // non-wide: the terminal's type size in the world
const term = $('term'), cw = wide ? W * 0.62 * K : FS * (tall ? 31 * 0.6 + 4.2 : 44 * 0.6 + 4.2); let ch = wide ? cw * 0.58 : cw * 0.7; const R = (B.tokens?.shape?.radius ?? 12) * (SHORT / 1080) * K;
// a terminal is always dark, so its type is always light, whatever the brand's mode
const ground = B.color('ground'), muted = B.color('muted'), figure = '#EDEAE3', accent = B.color('accent', '#E9E4D8');
const GREEN = '#8fbf8f';
Object.assign(term.style, { width: `${cw}px`, height: `${ch}px`, borderRadius: `${R}px`, background: '#070707', border: `1.5px solid ${muted}55`, boxShadow: `0 ${SHORT * 0.04}px ${SHORT * 0.12}px rgba(0,0,0,0.55)`, fontSize: `${wide ? cw * 0.022 : FS}px`, fontFamily: B.font('mono'), color: figure });
$('bar').style.height = '2.6em'; $('bar').style.borderBottom = `1px solid ${muted}22`;
$('bar').innerHTML = ['#ffffff33', '#ffffff22', '#ffffff18'].map((c) => `<i style="display:block;width:0.7em;height:0.7em;border-radius:50%;background:${c}"></i>`).join('') + `<span style="margin:auto;color:${muted};font-size:0.75em">zsh — ${CONFIG.cwd}</span>`;
const out = $('out');
const row = (html) => { const d = document.createElement('div'); d.className = 'ln'; d.innerHTML = html; out.append(d); return d; };
const prompt = row(`<span style="color:${muted}">${CONFIG.cwd} </span><span style="color:${accent}">$ </span><span id="cmd"></span><span id="caret" style="background:${accent}"></span>`);
const work = row(`<span id="spin" style="color:${accent}"></span> <span style="color:${muted}">${CONFIG.working}…</span>`);
const lines = CONFIG.output.map((o) => {
const d = row(`${o.check ? `<span class="ck" style="color:${GREEN}">✓</span>` : ''}<span style="color:${o.muted ? muted : o.accent ? accent : figure}">${wide ? o.text : o.text.replace(/\S+/g, (w) => `<span style="white-space:nowrap">${w}</span>`)}</span>`);
if (o.result) { const h = document.createElement('div'); h.className = 'hl'; h.style.background = `${accent}26`; h.style.boxShadow = `inset 0.16em 0 0 ${accent}`; h.style.right = '-0.5em'; d.prepend(h); d.style.zIndex = 0; }
if (o.check) d.classList.add('ckr');
return d;
});
if (!wide) term.classList.add('narrow');
cam.place(term, { x: 0, y: 0, z: 0 });
await document.fonts.ready;
const T = { type: [0.6, 1.5], enter: 1.65, done: 2.5, line: 0.2, result: 4.0 };
const lineAt = lines.map((_, i) => T.done + i * T.line + (i >= 4 ? 0.15 : 0));
const lineH = prompt.offsetHeight, outTop = out.offsetTop + parseFloat(getComputedStyle(out).paddingTop);
const SPIN = '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏';
const cmd = $('cmd'), caret = $('caret'), spin = $('spin');
const shown = (u) => { let k = progress(u, T.enter, T.enter + 0.4, ease.inOutSine); lineAt.forEach((a) => { k += progress(u, a, a + 0.6, ease.inOutSine); }); return k; }; // continuous, so the camera glides // rows visible after the prompt
const resIdx = CONFIG.output.findIndex((o) => o.result);
// non-wide: measure the finished output once (every line shown), then the camera follows a continuous bottom edge
const P = SHORT * 1.7, pad = parseFloat(getComputedStyle(out).paddingTop);
work.style.display = 'none';
const lineHs = lines.map((d) => d.offsetHeight), resTop = out.offsetTop + lines[resIdx].offsetTop + lines[resIdx].offsetHeight / 2;
if (!wide) { ch = Math.max(out.offsetTop + out.offsetHeight + lineH, tall ? (H * 0.86) / ((W * 0.94) / cw) : cw * 0.62); term.style.height = `${ch}px`; }
const bottomAt = (u) => {
let b = out.offsetTop + prompt.offsetTop + lineH * Math.round(prompt.offsetHeight / lineH) + lineH * progress(u, T.enter, T.enter + 0.4, ease.inOutSine) * (1 - progress(u, T.done, T.done + 0.6, ease.inOutSine));
lineAt.forEach((a, i) => { b += lineHs[i] * progress(u, a, a + 0.6, ease.inOutSine); });
return b;
};
s.update((t) => {
// the command, typed with a slightly uneven hand
const p = progress(t, ...T.type);
const n = Math.round(CONFIG.command.length * (p + 0.04 * Math.sin(p * 17) * (1 - p)) );
cmd.textContent = CONFIG.command.slice(0, Math.max(0, Math.min(CONFIG.command.length, n)));
caret.style.opacity = t < T.enter ? (t < T.type[0] || t > T.type[1] ? (Math.sin(t * 10) > 0 ? '1' : '0') : '1') : '0';
// the run: a spinner that turns into the first check
work.style.display = t >= T.enter ? '' : 'none';
work.style.opacity = t >= T.done ? '0' : '1';
work.style.height = t >= T.done ? '0' : '';
spin.textContent = SPIN[Math.floor(t * 14) % SPIN.length];
// the output, line by line, each check popping on a spring
lines.forEach((d, i) => {
const a = lineAt[i], v = t >= a;
d.style.display = v ? '' : 'none';
const e = progress(t, a, a + 0.15, ease.outCubic);
d.style.opacity = String(e); d.style.transform = `translateY(${(1 - e) * 0.3}em)`;
const ck = d.querySelector('.ck');
if (ck) ck.style.transform = `scale(${v ? 0.4 + 0.6 * spring(t - a, { stiffness: 380, damping: 14 }) : 0})`;
});
// the result lights up
const hl = lines[resIdx]?.querySelector('.hl');
if (hl) hl.style.transform = `scaleX(${progress(t, T.result, T.result + 0.45, ease.outCubic)})`;
// the camera: close on the prompt, riding the output down (smoothed), then onto the result
const arrive = progress(t, 0, 0.6, ease.outCubic), focus = progress(t, T.result - 0.2, T.result + 1.2, ease.inOutCubic);
let ry = 0; for (let j = 0; j < 8; j++) ry += Math.max(3.5, shown(t - j * 0.07)); ry /= 8;
const rideY = outTop + lineH * (ry - 2.5) - ch / 2;
const resY = outTop + (lines[resIdx].offsetTop - prompt.offsetTop) + lineH * 1.8 - ch / 2;
const y = rideY + (resY - rideY) * focus;
if (!wide) {
const sNow = ((W * 0.94) / cw) * (0.74 + 0.26 * arrive) * (1 + 0.05 * progress(t, 0.6, T.result, ease.inOutSine)) * (1 + (tall ? 0.05 : 0.07) * focus), half = H / (2 * sNow);
const x = Math.min(0, -cw / 2 + (W / 2) / sNow - FS * 0.6);
const lo = -ch / 2 + half - H * 0.06 / sNow, hi = ch / 2 - half + H * 0.04 / sNow;
const follow = bottomAt(t) - ch / 2 - half * 0.45, fy = follow + ((resTop + bottomAt(D)) / 2 - ch / 2 - follow) * focus;
const ny = lo <= hi ? Math.min(hi, Math.max(lo, fy)) : (lo + hi) / 2;
cam.at({ x, y: ny, z: P / sNow - P, yaw: -6 * (1 - arrive) + 1.5 * focus, pitch: 3 * (1 - arrive) });
} else
cam.at({ x: -cw * 0.2, y, z: DIST + SHORT * 0.3 * (1 - arrive) - SHORT * 1.0 - SHORT * 0.3 * focus, yaw: -6 * (1 - arrive) + 2 * focus, pitch: 3 * (1 - arrive) });
term.style.opacity = String(progress(t, 0, 0.3));
});
B.cue(s, 'transition', 0); B.cue(s, 'text', T.type[0]); B.cue(s, 'land', T.enter); B.cue(s, 'text', T.done); B.cue(s, 'land', T.result);
B.sound(s);
await s.start();
</script>
</body>
</html>
Defaults
Structure
Terminal run01 / 06
Arrive
arrive
0.0 / 6.2 s
02Type
03Run
04Output
06Hold
0 s6.2 s
- 010–0.6 sArrivearrive
- 020.6–1.5 sTypetype
- 031.65–2.5 sRunrun
- 042.5–3.7 sOutputoutput
- 054–4.6 sResultresult
- 064.6–6.2 sHoldhold
The script, sketched: the beats in order and their length, in the brand's colors and type. The clip above is the engine's render of the same recipe.
Notes
- Wired to the brand folder: needs brand/tokens.json (a palette and a font pair work) and, for the field, a shader-set entry.
- Recomposes for 16:9, 9:16 and 1:1: set
formatand the layout and camera follow.
Spec
- Id
- terminal-run
- Type
- Blocks
- Version
- 1.0.0
- Engine
- >=0.2.6
- License
- MIT