T Minus
A mission clock ticks T-minus with rolling characters, then slams 'LIFTOFF' over a sunrise glow.
Source
components/kuchi/t-minus.tsx
1"use client";23import { loadFont } from "@remotion/google-fonts/IBMPlexMono";4import type React from "react";5import { useId } from "react";6import {7 AbsoluteFill,8 Easing,9 interpolate,10 useCurrentFrame,11 useVideoConfig,12} from "remotion";1314const { fontFamily: mono } = loadFont("normal", {15 weights: ["400", "500"],16 subsets: ["latin"],17});1819export interface TMinusProps {20 /** Seconds on the clock when it starts. */21 from?: number;22 /** Frames per counted second (the countdown is compressed). */23 beat?: number;24 /** The word that slams in at T–0. Set in caps. */25 title?: string;26 /** Small line under the title. Pass "" to hide it. */27 subtitle?: string;28 /** Telemetry, top left. */29 stage?: string;30 /** Telemetry, top right, next to the live pip. */31 status?: string;32 /** Live pip and the small accent marks. */33 accent?: string;34 /** Text color of the count, title and readouts; overrides the theme. */35 ink?: string;36 background?: string;37 /** Typeface for the count, title and subtitle. Load it yourself; IBM Plex Mono by default. The telemetry stays mono. */38 fontFamily?: string;39 /** Strength of the ignition bloom; 0 hides it. */40 bloom?: number;41 /** White hit at T–0. */42 flash?: boolean;43 /** Size of the count, title and telemetry, around the frame's center. */44 scale?: number;45 /** Frames to hold the first frame before anything moves. */46 delay?: number;47 grain?: boolean;48 theme?: "dark" | "light";49 speed?: number;50}5152// Beat sheet (30fps, speed 1, from 10, beat 8):53// 0–14 "T–10" is already up; the edge telemetry boots with a flicker54// 14–86 one hard cut per counted second, each with a small scale snap; the55// small clock above rolls its last digit; from T–3 the bottom of the56// frame starts to warm57// 86 T–0: the bloom fires from the bottom ("halo" palette), a white hit58// 89 LIFTOFF slams in where the number was; the clock flips to59// T+00:00:01 and keeps counting up in real seconds60// 100– poster: clock, LIFTOFF, subtitle, the bloom breathing at the bottom61const FIRST = 14;62const SLAM = Easing.bezier(0.22, 1, 0.36, 1);63const CLAMP = {64 extrapolateLeft: "clamp",65 extrapolateRight: "clamp",66} as const;6768// gradients.sh "halo": bg #030306, #fff4ec #ffb36b #e2457a #3d4dff.69const HALO = ["#FFF4EC", "#FFB36B", "#E2457A", "#3D4DFF"] as const;7071const THEMES = {72 dark: {73 stage: "#050508",74 ink: "#F4F2EE",75 dim: "#76757D",76 faint: "#3A3A42",77 title: "#FFF7F0",78 bloomOp: 1,79 hit: `radial-gradient(130% 110% at 50% 100%, ${HALO[0]} 0%, ${HALO[1]} 30%, ${HALO[2]} 62%, ${HALO[3]} 100%)`,80 grain: 0.07,81 },82 light: {83 stage: "#F5F4F0",84 ink: "#121214",85 dim: "#86857F",86 faint: "#C9C7C0",87 title: "#121214",88 bloomOp: 0.8,89 hit: `radial-gradient(130% 110% at 50% 100%, #FFFFFF 0%, ${HALO[0]} 35%, ${HALO[1]} 70%, ${HALO[2]} 100%)`,90 grain: 0.05,91 },92} as const;9394function ramp(t: number, from: number, len: number) {95 return interpolate(t, [from, from + len], [0, 1], CLAMP);96}9798/** A short hit: up in 1 frame, eases back over `len`. */99function kick(d: number, len: number) {100 if (d < 0 || d > len + 1) return 0;101 if (d < 1) return d;102 const k = 1 - (d - 1) / len;103 return k * k;104}105106function hash(n: number) {107 const s = Math.sin(n * 127.1 + 311.7) * 43758.5453;108 return s - Math.floor(s);109}110111function pad(n: number) {112 return String(n).padStart(2, "0");113}114115/** "T–00:00:10" / "T+00:00:01". */116function clockText(sign: "–" | "+", s: number) {117 const h = Math.floor(s / 3600);118 const m = Math.floor((s % 3600) / 60);119 return `T${sign}${pad(h)}:${pad(m)}:${pad(s % 60)}`;120}121122/** Boot flicker: on, off, on, dim, on — then steady. */123function boot(t: number, at: number) {124 const d = Math.floor(t - at);125 if (d < 0) return 0;126 return [1, 0, 1, 0.35, 1][d] ?? 1;127}128129function Grain({ opacity }: { opacity: number }) {130 const id = `g${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;131 return (132 <svg133 width="100%"134 height="100%"135 style={{ position: "absolute", inset: 0, opacity }}136 aria-hidden137 >138 <filter id={id}>139 <feTurbulence140 type="fractalNoise"141 baseFrequency="0.9"142 numOctaves={2}143 seed={7}144 stitchTiles="stitch"145 />146 <feColorMatrix values="0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.9 0" />147 </filter>148 <rect width="100%" height="100%" filter={`url(#${id})`} />149 </svg>150 );151}152153/** One character that rolls up when it changes. Every glyph sits in the same clipped box. */154function RollChar({155 prev,156 next,157 p,158}: {159 prev: string;160 next: string;161 p: number;162}) {163 const rolling = prev !== next && p < 1;164 return (165 <span166 style={{167 display: "inline-block",168 position: "relative",169 height: "1.2em",170 lineHeight: "1.2em",171 overflow: "hidden",172 verticalAlign: "top",173 }}174 >175 <span176 style={{177 display: "block",178 transform: rolling ? `translateY(${(1 - p) * 100}%)` : undefined,179 }}180 >181 {next}182 </span>183 {rolling ? (184 <span185 style={{186 position: "absolute",187 left: 0,188 top: 0,189 transform: `translateY(${-p * 100}%)`,190 }}191 >192 {prev}193 </span>194 ) : null}195 </span>196 );197}198199/** The foreground at `scale`, around the frame's center; nothing extra at 1. */200function ScaleLayer({201 scale,202 children,203}: {204 scale: number;205 children: React.ReactNode;206}) {207 if (scale === 1) return children;208 return (209 <AbsoluteFill style={{ transform: `scale(${scale})` }}>210 {children}211 </AbsoluteFill>212 );213}214215export function TMinus({216 from = 10,217 beat = 8,218 title = "Liftoff",219 subtitle = "acme 2.0 is live",220 stage = "Stage 1",221 status = "Go",222 accent = "#3B5BFD",223 ink,224 background,225 fontFamily = mono,226 bloom: bloomK = 1,227 flash = true,228 scale = 1,229 delay = 0,230 grain = true,231 theme = "dark",232 speed = 1,233}: TMinusProps) {234 const t = Math.max(0, useCurrentFrame() - delay) * speed;235 const { width: W, height: H, fps } = useVideoConfig();236 const c = THEMES[theme];237 const fg = ink ?? c.ink;238 const u = Math.min(W / 1280, H / 720);239240 const start = Math.max(1, Math.floor(from));241 const zeroAt = FIRST + (start - 1) * beat;242 const liftAt = zeroAt + 3;243244 // Countdown value and the frame the current value appeared.245 const ticks =246 t < FIRST ? 0 : Math.min(start, 1 + Math.floor((t - FIRST) / beat));247 const n = start - ticks;248 const tickAt = ticks === 0 ? 0 : FIRST + (ticks - 1) * beat;249 const lifted = t >= liftAt;250251 // Small clock: counts down with the big one, then up in real seconds.252 const upS = lifted ? 1 + Math.floor((t - liftAt) / fps) : 0;253 const upAt = lifted ? liftAt + (upS - 1) * fps : tickAt;254 const clock = lifted ? clockText("+", upS) : clockText("–", n);255 const prevClock = lifted256 ? upS === 1257 ? clockText("–", 0)258 : clockText("+", upS - 1)259 : ticks === 0260 ? clock261 : clockText("–", n + 1);262 const rollP = SLAM(ramp(t, upAt - 1.5, lifted && upS === 1 ? 7 : 4));263264 // ── Motion ────────────────────────────────────────────────────────────────265 const snap = ticks === 0 ? 0 : kick(t - tickAt, 5);266 const numScale =267 (1 + 0.045 * snap) * (n === 0 ? 1 + 0.03 * kick(t - zeroAt, 3) : 1);268 const intro = SLAM(ramp(t, -4, 10));269270 const warm = Easing.bezier(271 0.65,272 0,273 0.35,274 1,275 )(ramp(t, FIRST + (start - 3) * beat, 3 * beat));276 const fire = SLAM(ramp(t, zeroAt, 16));277 const hit = kick(t - zeroAt - 1, 7);278 const breathe = lifted ? Math.sin((t - liftAt) / 14) * 0.5 + 0.5 : 0;279280 const titleIn = SLAM(ramp(t, liftAt, 8));281 const titleHit = kick(t - (liftAt + 4), 8);282 const subIn = SLAM(ramp(t, liftAt + 9, 10));283284 // ── Layout ────────────────────────────────────────────────────────────────285 const numFs = 330 * u;286 const numCY = H / 2 + 22 * u;287 const titleFs = 210 * u;288 const titleCY = H / 2 - 4 * u;289 const clockFs = 34 * u;290 const clockY = lifted291 ? interpolate(292 titleIn,293 [0, 1],294 [numCY - numFs * 0.5 - 70 * u, titleCY - titleFs * 0.5 - 62 * u],295 )296 : numCY - numFs * 0.5 - 70 * u;297 const margin = 56 * u;298299 // Telemetry values flicker in their last digit.300 const flick = (k: number, every: number) =>301 hash(Math.floor(t / every) * 13 + k);302 const lox = (99.6 + flick(1, 3) * 0.3).toFixed(1);303 const rp1 = (99.8 + flick(2, 4) * 0.2).toFixed(1);304 const press = (3.4 + flick(3, 3) * 0.05).toFixed(2);305 const sinceLift = Math.max(0, t - liftAt) / fps;306 const kmh = Math.round(sinceLift * sinceLift * 38);307 const alt = (sinceLift * sinceLift * 0.012).toFixed(2);308309 const label: React.CSSProperties = {310 fontFamily: mono,311 fontWeight: 400,312 fontSize: 15 * u,313 letterSpacing: "0.14em",314 textTransform: "uppercase",315 color: c.dim,316 lineHeight: 1.6,317 whiteSpace: "nowrap",318 fontVariantNumeric: "tabular-nums",319 };320 const value: React.CSSProperties = {321 color: fg,322 fontWeight: 500,323 };324325 const bloom = (size: number) =>326 [327 `radial-gradient(${size * 0.9}% ${size * 0.62}% at 50% 112%, ${HALO[0]} 0%, ${HALO[1]} 20%, color-mix(in oklab, ${HALO[2]} 85%, transparent) 42%, color-mix(in oklab, ${HALO[3]} 55%, transparent) 66%, transparent 86%)`,328 ].join(", ");329 const bloomSize = interpolate(fire, [0, 1], [26, 100]) + breathe * 4;330 const bloomOp =331 bloomK *332 c.bloomOp *333 (lifted || t >= zeroAt334 ? interpolate(fire, [0, 0.4, 1], [0.6, 1, 0.92])335 : 0);336337 const blink = Math.floor(t / 12) % 2 === 0 ? 1 : 0.3;338339 return (340 <AbsoluteFill341 style={{ background: background ?? c.stage, overflow: "hidden" }}342 >343 {/* Pre-ignition warmth. */}344 <div345 style={{346 position: "absolute",347 inset: 0,348 background: `radial-gradient(60% 34% at 50% 108%, color-mix(in oklab, ${HALO[1]} 70%, transparent) 0%, color-mix(in oklab, ${HALO[2]} 35%, transparent) 45%, transparent 75%)`,349 opacity: warm * (1 - fire) * (theme === "dark" ? 1 : 0.7),350 }}351 />352 {/* The bloom. */}353 <div354 style={{355 position: "absolute",356 inset: 0,357 background: bloom(bloomSize),358 opacity: bloomOp,359 }}360 />361 {grain ? <Grain opacity={c.grain} /> : null}362363 <ScaleLayer scale={scale}>364 {/* Corner telemetry. */}365 <div366 style={{367 ...label,368 position: "absolute",369 left: margin,370 top: margin - 8 * u,371 opacity: boot(t, 2),372 }}373 >374 <div>{stage}</div>375 <div>376 Vehicle <span style={value}>{lifted ? "Ascent" : "Pad 39"}</span>377 </div>378 </div>379 <div380 style={{381 ...label,382 position: "absolute",383 right: margin,384 top: margin - 8 * u,385 textAlign: "right",386 opacity: boot(t, 4),387 }}388 >389 <div390 style={{391 display: "flex",392 alignItems: "center",393 justifyContent: "flex-end",394 gap: 10 * u,395 }}396 >397 <div398 style={{399 width: 8 * u,400 height: 8 * u,401 background: accent,402 opacity: lifted ? 1 : blink,403 }}404 />405 Status <span style={value}>{status}</span>406 </div>407 <div>408 Range <span style={value}>{lifted ? "Clear" : "Green"}</span>409 </div>410 </div>411 <div412 style={{413 ...label,414 position: "absolute",415 left: margin,416 bottom: margin - 8 * u,417 opacity: boot(t, 6),418 }}419 >420 {lifted ? (421 <>422 <div>423 Speed <span style={value}>{kmh}</span> km/h424 </div>425 <div>426 Alt <span style={value}>{alt}</span> km427 </div>428 </>429 ) : (430 <>431 <div>432 LOX <span style={value}>{lox}</span>%433 </div>434 <div>435 RP-1 <span style={value}>{rp1}</span>%436 </div>437 </>438 )}439 </div>440 <div441 style={{442 ...label,443 position: "absolute",444 right: margin,445 bottom: margin - 8 * u,446 textAlign: "right",447 opacity: boot(t, 8),448 }}449 >450 <div>451 Tank press <span style={value}>{press}</span> bar452 </div>453 <div>454 Engines <span style={value}>{t >= zeroAt ? "9 / 9" : "Chill"}</span>455 </div>456 </div>457458 {/* Small clock. */}459 <div460 style={{461 position: "absolute",462 left: 0,463 right: 0,464 top: clockY,465 display: "flex",466 justifyContent: "center",467 fontFamily: mono,468 fontWeight: 400,469 fontSize: clockFs,470 lineHeight: 1.1,471 letterSpacing: "0.06em",472 color: lifted ? fg : c.dim,473 fontVariantNumeric: "tabular-nums",474 opacity: intro,475 }}476 >477 {clock.split("").map((ch, i) => (478 <RollChar key={i} prev={prevClock[i] ?? ch} next={ch} p={rollP} />479 ))}480 </div>481482 {/* The big number, hard cut per second. */}483 {!lifted ? (484 <div485 style={{486 position: "absolute",487 left: 0,488 right: 0,489 top: numCY - numFs / 2,490 height: numFs,491 display: "flex",492 justifyContent: "center",493 alignItems: "center",494 fontFamily,495 fontWeight: 500,496 fontSize: numFs,497 lineHeight: 1,498 letterSpacing: "-0.05em",499 fontVariantNumeric: "tabular-nums",500 whiteSpace: "nowrap",501 transform: `translateY(${(1 - intro) * 40 * u}px) scale(${numScale})`,502 opacity: intro,503 }}504 >505 <span style={{ color: c.faint }}>T–</span>506 <span style={{ color: fg }}>{n}</span>507 </div>508 ) : null}509510 {/* LIFTOFF. */}511 <div512 style={{513 position: "absolute",514 left: 0,515 right: 0,516 top: titleCY - titleFs / 2,517 height: titleFs,518 display: "flex",519 justifyContent: "center",520 alignItems: "center",521 fontFamily,522 fontWeight: 500,523 fontSize: titleFs,524 lineHeight: 1,525 letterSpacing: "-0.04em",526 textTransform: "uppercase",527 whiteSpace: "nowrap",528 color: ink ?? c.title,529 opacity: lifted ? ramp(titleIn, 0, 0.2) : 0,530 transform: `scale(${(1.24 - 0.24 * titleIn) * (1 + 0.02 * titleHit)})`,531 }}532 >533 {title}534 </div>535 {subtitle ? (536 <div537 style={{538 position: "absolute",539 left: 0,540 right: 0,541 top: titleCY + titleFs * 0.5 + 18 * u,542 display: "flex",543 justifyContent: "center",544 fontFamily,545 fontWeight: 400,546 fontSize: 30 * u,547 letterSpacing: "0.02em",548 color: fg,549 whiteSpace: "nowrap",550 opacity: subIn,551 transform: `translateY(${(1 - subIn) * 24 * u}px)`,552 }}553 >554 {subtitle}555 </div>556 ) : null}557 </ScaleLayer>558559 {/* Ignition hit. */}560 {flash && hit > 0 ? (561 <div562 style={{563 position: "absolute",564 inset: 0,565 background: c.hit,566 opacity: hit,567 }}568 />569 ) : null}570 </AbsoluteFill>571 );572}









