// THE INSTRUMENTS' PAGES (instruments.mjs): the dial, the odometer, the trail // -- each one HyperFrames page for the whole cut, in its region of the // instruments' column (deck.mjs instrumentsGeometry) -- and the dial's finale, // a page over the finale's window in the finale's lower column. // // PURE, like chrome-stats.mjs: a schedule (its `measure`) and a render block in, // an HTML string out. compose-chrome.mjs copies the assets in beside it, writes // it and renders it; the build lays the frames over the cut. Play the cut and // the live preview load the same page (`?preview=1`) and seek it by message. // // Every page is a cue interpreter (measure-draw.mjs cueList, pageHtml): every // state is its own block shown over exactly its span, every move a cue that // states its from, so a seek lands on the same pixels from either side and a // frame whose values did not move keys as the frame before it -- the needle at // rest between two weights is captured once, not once a frame. import { cueTime, deckChoreography, even, instrumentsGeometry, railGap } from "./deck.mjs"; import { stackedGeometry, stackedOn, stackedStandDowns } from "./vertical-deck.mjs"; import { mix, rgba } from "./chrome-deck.mjs"; import { finaleLayout } from "./chrome-finale.mjs"; import { FINALE_MOTION } from "./finale.mjs"; import { resolveDial, resolveOdometer, resolveTrail } from "./instruments.mjs"; import { TRAIL_REFLOW, trailLayout, trailPoints, trailStates } from "./trail-plan.mjs"; import { deckAwaySpans, flashCss, flashCues, flashOn, flashTimes } from "./update-flash.mjs"; import { promiseStates, upSpans } from "./measure-extras.mjs"; import { ghostOpacity, ghostRamp, ghostTicks, resolveGhosts } from "./measure-ghosts.mjs"; import { goalBoard, goalsAt } from "./measure-goals.mjs"; import { resolveMeasureExtra } from "./modules/measure-extras-settings.mjs"; import { cueList, dayNumber, dialAngle, dialFaceSvg, dialFigures, DIAL_SWEEP, esc, fmtDate, fmtSigned, fmtWeight, INSTANT, measureTrack, pageHtml, polar, qualifierMark, r4, sectorPath, wedgeRange, weightWords, wheelCount, wheelRoll, wheelStrip, } from "./measure-draw.mjs"; /** The motion's seconds: the needle's swing, a ghost's move, the odometer's roll, a block's fade. */ export const INSTRUMENT_MOTION = Object.freeze({ needle: 0.9, needleEase: "back.out(1.7)", needlePlain: "power2.inOut", ghost: 0.7, goal: 0.6, roll: 1.3, fade: 0.25, point: 0.4, segment: 0.45, }); /** The faces a measure page draws in: the deck's, and the manifest's display and condensed faces when it names them. */ export const INSTRUMENT_FONTS = Object.freeze({ display: "MeasureDisplay", condensed: "MeasureCond" }); export const fontStack = (fonts, which) => which === "display" ? `'${fonts.MeasureDisplay ? "MeasureDisplay" : "DeckSansBold"}', sans-serif` : which === "condensed" ? `'${fonts.MeasureCond ? "MeasureCond" : "DeckSans"}', sans-serif` : which === "bold" ? "'DeckSansBold', sans-serif" : "'DeckSans', sans-serif"; /** The palette roles every instrument draws in. */ export function colorsOf(render, dial = resolveDial(render)) { const pal = render.palette ?? {}; const bg = pal.bg ?? "#0f1311", fg = pal.fg ?? "#edf0ec"; return { bg, fg, muted: pal.muted ?? "#98a29b", accent: pal.accent ?? "#22ab83", amber: pal.amber ?? "#e8a33f", needle: dial?.needle ?? "#ff5a4e", card: mix(bg, fg, 0.05), rule: mix(bg, fg, 0.16), face: mix(bg, fg, 0.07), bezel: mix(bg, fg, 0.2), ink: mix(bg, fg, 0.92), ghost: pal.muted ?? "#98a29b", }; } /** The measure, or a sentence why the page cannot draw. */ function measureOf(schedule, what) { const m = schedule?.measure; if (!m || !Array.isArray(m.state) || !m.scale) throw new Error(`${what}: the schedule has no measure (a measure ledger and render.chrome.deck.measure)`); return m; } /** A whole-cut page's window of the cut (`from`/`duration`, a preview's), or null for the whole cut. */ function windowOf(schedule, opts, what) { const total = schedule.total; const from = Number(opts.from ?? 0); const dur = opts.duration != null ? r4(Number(opts.duration)) : r4(total - from); if (!(dur > 0)) throw new Error(`${what}: nothing to render from ${from}s of a ${total}s cut`); const windowed = from > 0 || Math.abs(dur - total) > 1e-6; return windowed ? { from: r4(from), dur } : null; } /** The instruments come and go with the deck (a card, the finale): its root `k` on the deck's own visibility. */ function withDeck(L, schedule, render, k) { L.set(k, { autoAlpha: 1 }); const fin = Number.isFinite(schedule?.finale?.from) ? schedule.finale.from : null; const stacked = stackedOn(render); const shown = []; for (const v of deckChoreography(schedule, render).visibility) { const [a, b] = v.at; // Going under the finale: over its grow, as the dial's finale comes in (dialFinaleHtml) -- a crossfade. const intoFinale = v.hide && fin !== null && Math.abs(a - fin) < 0.6; const dur = intoFinale ? Math.max(b - a, FINALE_MOTION.grow) : Math.max(INSTANT, b - a); if (!stacked) L.add(k, a, dur, { autoAlpha: v.hide ? 0 : 1 }, v.hide ? "power1.in" : "power2.out"); else shown.push({ at: a, dur, hide: v.hide }); } if (!stacked) return; // THE STACKED VERTICAL DECK (vertical-deck.mjs): the panel stands down over a post item (its card takes the // room) and a twocrop clip (its strip carries the numbers) -- out over the join into it, back over the join out. const D = Number(schedule.transition) || 0; const m = Math.max(D, 0.3); for (const sd of mergedSpans(stackedStandDowns(schedule))) { // Standing down from the cut's first instant is init, not a fade over the opening (cue-start.mjs). shown.push({ at: Math.max(0, sd.from), dur: sd.from <= 0 ? INSTANT : m, hide: true }); if (sd.to < (schedule.total ?? Infinity) - 0.05) shown.push({ at: sd.to, dur: m, hide: false }); } // Each change once, in time: a stand-down inside a span the deck is already away for adds nothing. shown.sort((p, q) => p.at - q.at); let hidden = false; let depth = 0; for (const v of shown) { depth += v.hide ? 1 : -1; const want = depth > 0; if (want === hidden) continue; hidden = want; L.add(k, v.at, v.dur, { autoAlpha: want ? 0 : 1 }, want ? "power1.in" : "power2.out"); } } /** Spans that touch or overlap, as one. */ function mergedSpans(spans) { const out = []; for (const sp of [...spans].sort((a, b) => a.from - b.from)) { const last = out[out.length - 1]; if (last && sp.from <= last.to + 0.05) last.to = Math.max(last.to, sp.to); else out.push({ ...sp }); } return out; } /** Blocks shown one at a time: block j from `list[j].t` to the next one's. */ function blocks(L, list, key, { fade = INSTANT, shown = (x) => true } = {}) { list.forEach((x, j) => { const k = `${key}${j}`; // A block from the cut's first instant is up in init: a cue at 0 is at its own start there (opacity 0). if (!shown(x)) { L.set(k, { autoAlpha: 0 }); return; } if (x.t <= 0) L.set(k, { autoAlpha: 1 }); else { L.set(k, { autoAlpha: 0 }); L.add(k, x.t, fade, { autoAlpha: 1 }, "power1.out"); } const next = list[j + 1]; if (next) L.add(k, next.t, INSTANT, { autoAlpha: 0 }); }); } export const goalWords = (g) => { if (!g) return ""; const loss = Number.isFinite(g.loss) ? Math.abs(g.loss) : null; // A loss goal resolved against its run's start (`base`) reads as both: "GOAL 250 · LOSE 50"; a range he gave // stays a range ("GOAL 230–240"); an unresolved loss is his words alone ("LOSE 75"). const what = Array.isArray(g.range) && g.range.length === 2 ? `GOAL ${fmtWeight(g.range[0])}–${fmtWeight(g.range[1])}` : Number.isFinite(g.value) ? `GOAL ${fmtWeight(g.value)}${loss !== null && g.base ? ` · LOSE ${fmtWeight(loss)}` : ""}` : loss !== null ? `LOSE ${fmtWeight(loss)}` : "GOAL"; const when = g.deadline ?? g.due ?? null; return when ? `${what} · ${String(when).toUpperCase()}` : what; }; /** A goal's day as the dial says it: his words ("BY CHRISTMAS 2026", the year added when they name none), else "BY APR 2026". */ export function goalWhen(g) { const year = /^(\d{4})-/.exec(String(g?.deadlineDate ?? ""))?.[1] ?? null; if (g?.deadline) return `${String(g.deadline).toUpperCase()}${year && !/\d{4}/.test(g.deadline) ? ` ${year}` : ""}`; return g?.deadlineDate ? `BY ${fmtDate(g.deadlineDate, { day: false })}` : ""; } /** * A goal board's goal (measure-goals.mjs) in words: "GOAL 320 · BY APR 2026", "GOAL 230–240", * "GOAL 250 · LOSE 50" (a loss resolved, no day), "LOSE 75" (unresolved); `missed`: "MISSED 320 · BY APR 2026". */ export function boardGoalWords(g, { missed = false } = {}) { if (!g) return ""; const when = goalWhen(g); const num = Array.isArray(g.range) && g.range.length === 2 ? `${fmtWeight(g.range[0])}–${fmtWeight(g.range[1])}` : Number.isFinite(g.target) ? fmtWeight(g.target) : null; if (missed) return [`MISSED ${num ?? (Number.isFinite(g.loss) ? `LOSE ${fmtWeight(g.loss)}` : "GOAL")}`, when].filter(Boolean).join(" · "); const what = num !== null ? `GOAL ${num}${g.kind === "goalLoss" && Number.isFinite(g.loss) && !when ? ` · LOSE ${fmtWeight(g.loss)}` : ""}` : Number.isFinite(g.loss) ? `LOSE ${fmtWeight(g.loss)}` : "GOAL"; return [what, when].filter(Boolean).join(" · "); } /** * The goal board's goals as the dial marks them: each goal the board ever holds (in the order it first does), its * angle (null when it has no weight on the face), and its status in each board state -- "head", "other", "missed" * (with `wasHeadline`) or "off". */ export function goalMarks(board, scale) { const goals = []; const index = new Map(); for (const b of board) { for (const g of [...b.active, ...b.missed]) { if (index.has(g.row)) continue; index.set(g.row, goals.length); const onFace = Number.isFinite(g.target) && g.target >= scale.min && g.target <= scale.max; const r = g.range; const band = Array.isArray(r) && dialAngle(r[1], scale) > dialAngle(r[0], scale); goals.push({ goal: g, angle: onFace ? dialAngle(g.target, scale) : null, band }); } } const statusIn = (b, row) => { const m = b.missed.find((x) => x.row === row); if (m) return { status: "missed", wasHeadline: !!m.wasHeadline }; if (b.headline?.row === row) return { status: "head" }; return b.active.some((x) => x.row === row) ? { status: "other" } : { status: "off" }; }; return goals.map((x) => ({ ...x, states: board.map((b) => ({ t: b.t, ...statusIn(b, x.goal.row) })) })); } /** What the goal line under the digits says in each board state: the latest miss while it is held, else the headline. */ export function goalLines(board) { return board.map((b) => { const miss = [...b.missed].sort((x, y) => x.at - y.at).pop(); return { t: b.t, words: miss ? boardGoalWords(miss, { missed: true }) : boardGoalWords(b.headline), missed: !!miss }; }); } // --------------------------------------------------------------------------- // The dial. // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // Words on the face, kept off its figures. // --------------------------------------------------------------------------- /** Whether boxes `a` and `b` ({x0, x1, y0, y1}) come within `m` px of each other. */ const boxesTouch = (a, b, m = 0) => a.x0 < b.x1 + m && b.x0 < a.x1 + m && a.y0 < b.y1 + m && b.y0 < a.y1 + m; /** How far boxes `a` and `b` overlap, with `m` px between them counted in: 0 when they are clear. */ const touchArea = (a, b, m = 0) => Math.max(0, Math.min(a.x1, b.x1 + m) - Math.max(a.x0, b.x0 - m)) * Math.max(0, Math.min(a.y1, b.y1 + m) - Math.max(a.y0, b.y0 - m)); /** * The first of `spots` (each {box, ...}, in order of preference) whose box clears every one of `obstacles` by `m` * px; when none does, the one that touches them least. The words' boxes are estimates in the face's px (see * dialFigures), deliberately a little wide. */ export function clearSpot(spots, obstacles, m = 0) { let best = null, least = Infinity; for (const s of spots) { if (!obstacles.some((o) => boxesTouch(s.box, o, m))) return s; const t = obstacles.reduce((n, o) => n + touchArea(s.box, o, m), 0); if (t < least) { least = t; best = s; } } return best; } /** A centred box `w` x `h` at (x, y). */ const boxAt = (x, y, w, h) => ({ x0: x - w / 2, x1: x + w / 2, y0: y - h / 2, y1: y + h / 2 }); /** How the dial shows a remembered weight (`deck.dial.rememberedAs`): "needle" (the long grey needle, as it was), "rim", "readout", "callout". */ export const rememberedMode = (cfg) => (["rim", "readout", "callout"].includes(cfg?.rememberedAs) ? cfg.rememberedAs : "needle"); /** His highest remembered weight above every one he stated (the peak extra's `totals.peakDrift`), or null. */ export const heaviestOf = (measure) => { const drift = Array.isArray(measure?.totals?.peakDrift) ? measure.totals.peakDrift.filter(Number.isFinite) : []; return drift.length ? Math.max(...drift) : null; }; /** * A remembered weight's words, from its own fields: `value` with its qualifier ("≈390"), `when` its asOf's month * ("FEB 2023", null without one), `kind` "HEAVIEST HE'S SAID" when it is `heaviest` (heaviestOf) else "HE SAYS HE * WAS"; and the forms the looks draw -- `head`/`sub` (the rim's flag), `line` (the readout's). */ export function rememberedWords(g, heaviest = null) { const value = weightWords(g); const top = heaviest !== null && Number.isFinite(g.value) && Math.abs(g.value - heaviest) < 0.05; const when = g.asOf ? fmtDate(g.asOf, { day: false }) : null; const kind = top ? "HEAVIEST HE'S SAID" : "HE SAYS HE WAS"; return { value, when, kind, heaviest: top, head: top ? `HEAVIEST ${value}` : value, sub: [when ? `AS OF ${when}` : "REMEMBERED", top ? "HE SAYS" : ""].filter(Boolean).join(" · "), line: `${kind}: ${value}${when ? ` (${when})` : ""}`, }; } /** * An as-of label's places, best first: along its ghost (angle `a`) at half the face's radius, each of its `forms` * (its small words on one line, then on two), then stepping in toward the hub; never lower than just under the hub, * where the readout's words are. Its box from its css (.asof: the head 24, the small words 13 condensed with * 0.08em spacing, 3/7 padding). */ function asofSpots({ C, Rf, u, a, head, forms, px, fpx }) { const hb = px(24), hs = fpx(13); const spots = []; for (let r = Rf * 0.52; r >= Rf * 0.26 - 1e-9; r -= Rf * 0.04) { const [x, y0] = polar(C, C, r, a); const y = Math.min(y0, Math.round((C + 30 * u) * 100) / 100); for (const lines of forms) { const w = Math.max(head.length * hb * 0.6, ...lines.map((l) => l.length * hs * 0.66)) + 2 * px(7); const h = hb * 1.05 + lines.length * hs * 1.05 + 2 * px(3); spots.push({ x, y, lines, box: boxAt(x, y, w, h) }); } } return spots; } /** * The dial's face and everything on it, `size` px square at (ox, oy) in the * page: the static face, the ghosts, the wedges, the goal tick, the needles, * the hub and the readout blocks. Shared by the column's dial and the * finale's. Returns its markup and css; its cues are the caller's. */ function dialParts({ size, ox, oy, scale, cfg, colors, fonts, track, marks = [], lines = [], ghosts = null, prefix = "", preState = true, heaviest = null }) { const face = dialFaceSvg({ size, scale, mark: cfg.mark, colors: { ...colors, mark: colors.accent }, labelFont: fontStack(fonts, "condensed") }); const { C, R, Rf, u } = face; const px = (v) => Math.round(v * u * 100) / 100; // Small words keep a floor: a corner dial is a third of the column's, and 8 px does not read. const fpx = (v) => Math.max(12, px(v)); const layer = (k, inner, cls = "ly") => `
${inner}
`; const parts = []; parts.push(`
${face.svg}
`); // The claim ghosts (deck.measure.ghosts, measure-ghosts.mjs): under everything on the face, a thin tick across the // rim at each value he has claimed -- one line per step of the ramp (its colour, a little thicker each step), the // step its count is on shown, and a pulse line that flashes as a repeat lands. if (ghosts) { // From just in from the bezel's outer edge to just short of the scale's ticks (they start 6 px in). const r0 = C - R + 2 * u, r1 = C - Rf + 8 * u; ghosts.ticks.forEach((x, i) => { const lines = ghosts.ramp.map((c, k) => `
`).join(""); const pulses = ghosts.cfg.pulse ? ghosts.ramp.map((c, k) => (k === 0 ? "" : `
`)).join("") : ""; parts.push(`
${lines}${pulses}
`); }); } // Where words laid on the face must not go: its scale figures, and the hub. const faceFigures = dialFigures({ size, scale, mark: cfg.mark }); const hub = { x0: C - 18 * u, x1: C + 18 * u, y0: C - 18 * u, y1: C + 18 * u }; if (cfg.ghosts) { track.remembered.forEach((g, j) => { parts.push(layer(`g${j}`, ``)); // A remembered RANGE ("330-340"): a ghost band across it, not its middle alone. if (Array.isArray(g.range)) { const b0 = dialAngle(g.range[0], scale), b1 = dialAngle(g.range[1], scale); if (b1 > b0) parts.push(`
`); } }); } track.current.forEach((c, j) => { const w = Number.isFinite(c.value) ? wedgeRange(c.value, c.qualifier, c.range) : null; if (!w) return; const a0 = dialAngle(w[0], scale), a1 = dialAngle(w[1], scale); if (!(a1 > a0)) return; // The wedge reads at a glance (rev 9: ">300" was lost against the 300 mark): a strong fill, an outline in the // face's own dark around the accent, and its words -- the glyph and the digits -- at its outer edge. parts.push(layer(`q${j}`, `` + ``)); // Its words clear of every scale figure (rev 9: "3>300", the words on the 300 at the top): inside the wedge // on its middle, stepping in toward the hub until their box (.qlab: 26 display, 1/6 padding) is clear. const words = weightWords(c); const fs = px(26), bw = words.length * fs * 0.6 + 2 * px(6), bh = fs * 1.2 + 2 * px(1); const spots = []; for (let r = Rf - 108 * u; r >= Rf - 190 * u - 1e-9; r -= 8 * u) { const [x, y] = polar(C, C, r, (a0 + a1) / 2); spots.push({ x, y, box: boxAt(x, y, bw, bh) }); } const spot = clearSpot(spots, [...faceFigures.map((f) => f.box), hub], 10 * u); parts.push(`
${esc(words)}
`); }); if (cfg.goal) { // EVERY goal in force (measure-goals.mjs goalBoard), each a mark on the bezel at its weight: the headline -- the // closest -- the full amber triangle; the others a thin amber tick; a missed one struck through in the needle's // red, a red flash as it is missed. A range is an amber band on the bezel besides (its headline's brighter). const svg = (k, inner) => `
${inner}
`; marks.forEach((m, i) => { const r = m.goal.range; if (m.band) parts.push(svg(`gb${i}`, ``)); if (m.angle === null) return; const head = ``; const other = ``; const strike = `` + ``; const flash = ``; parts.push(`
${svg(`gm${i}h`, head)}${svg(`gm${i}o`, other)}${svg(`gm${i}x`, strike)}${svg(`gm${i}p`, flash)}
`); }); } const mode = rememberedMode(cfg); if (cfg.ghosts && track.remembered.length && (mode === "needle" || mode === "callout")) { parts.push(layer("gn", ``)); } // The needle: a tapered blade from a counterweight through the hub. parts.push(layer("nd", `` + ``)); parts.push(`
`); // The as-of labels, each by its ghost, up while it is the latest -- and never on a scale figure (rev 9: "≈390 · // AS OF FEB 2025 · TOLD 4×" sat on the 380). Along its ghost, never down into the readout's words under the hub; // where its box would touch a figure's, its words go on two lines, then it steps in toward the hub. if (cfg.ghosts && mode === "needle") { track.remembered.forEach((g, j) => { const a = dialAngle(g.value, scale); const head = weightWords(g); const asOf = g.asOf ? `AS OF ${fmtDate(g.asOf)}` : "REMEMBERED"; // The moving start's count rides on its ghost (rev 9: "≈390 · TOLD 5×", the peak module off beside the dial). const told = g.told > 1 ? `TOLD ${g.told}×` : ""; const forms = told ? [[`${asOf} · ${told}`], [asOf, told]] : [[asOf]]; const spot = clearSpot(asofSpots({ C, Rf, u, a, head, forms, px, fpx }), [...faceFigures.map((f) => f.box), hub], 3 * u); parts.push(`
${esc(head)}${spot.lines.map((l) => `${esc(l)}`).join("")}
`); }); } // THE REMEMBERED WEIGHT'S OTHER LOOKS (`deck.dial.rememberedAs`, 11 Nov: the long grey second needle and its // small words crossed the main needle and the readout and did not say what the weight was). Each from the // ledger's own fields -- the qualifier, the asOf, "heaviest" only for the record's highest remembered weight above // every one he stated (the peak extra's `totals.peakDrift`) -- never words of ours. // rim a bold marker on the rim at the value and a flag inside it, clear of the hub, the figures and the readout // readout a line in the readout under the date ("HEAVIEST HE'S SAID: ≈390 (FEB 2023)"), a marker on the rim // callout a ghost needle sweeps to the value as he says it, a clear label holds ~2 s, then the rim's flag const readoutBox = { x0: C - 128 * u, x1: C + 128 * u, y0: C + 60 * u, y1: C + 230 * u }; if (cfg.ghosts && mode !== "needle") { const ink = mix(colors.ghost, colors.fg, 0.55); track.remembered.forEach((g, j) => { const w = rememberedWords(g, heaviest); const a = dialAngle(g.value, scale); // The marker: a bold wedge across the rim, pointing in -- the scale's own ticks show through either side. parts.push(layer(`gk${j}`, ``)); if (mode === "readout") { parts.push(`
${esc(w.line)}
`); return; } // The flag: inside the rim by the marker -- along it, then turning a little either way, stepping in -- clear of // the scale's figures, the hub, the readout and the needle where it stands as he says it. const hb = px(22), hs = fpx(12); const flagLines = [w.heaviest ? "HEAVIEST" : "REMEMBERED", w.when ? w.when : ""].filter(Boolean); const fw = Math.max(w.value.length * hb * 0.56, ...flagLines.map((l) => l.length * hs * 0.66)) + 2 * px(8); const fh = hb * 1.08 + flagLines.length * hs * 1.12 + 2 * px(4); const stands = [...track.current].filter((c) => c.t <= g.t + 1e-9 && Number.isFinite(c.value)).pop(); const needle = []; if (stands) { const na = dialAngle(stands.value, scale); for (let r = 24 * u; r <= Rf - 30 * u; r += 14 * u) { const [x, y] = polar(C, C, r, na); needle.push(boxAt(x, y, 10 * u, 10 * u)); } } const spots = []; for (const da of [0, -8, 8, -16, 16, -24, 24, -32, 32, -40, -48]) { for (let r = Rf * 0.64; r >= Rf * 0.34 - 1e-9; r -= Rf * 0.04) { const [x, y] = polar(C, C, r, a + da); spots.push({ x, y, box: boxAt(x, y, fw, fh) }); } } const spot = clearSpot(spots, [...faceFigures.map((f) => f.box), hub, readoutBox, ...needle], 4 * u); const [l0, l1] = flagLines; parts.push(`
${esc(l0)}${esc(w.value)}${l1 ? `${esc(l1)}` : ""}
`); if (mode === "callout") { parts.push(`
${esc(w.kind)}${esc(w.value)}${w.when ? `AS OF ${esc(w.when)}` : ""}
`); } }); } // The readout under the hub: the words, the weight, the weighing's date, the goal. // Inside the face's open quarter: each line kept within the chord at its height. parts.push(`
${esc(cfg.label)}
`); track.current.forEach((c, j) => { const has = Number.isFinite(c.value); // Before he states a weight: the pre-state, in words -- never a number he did not give. const pre = !has && preState && j === 0; parts.push(`
${has ? `${esc(weightWords(c))}LB` : pre ? "NO WEIGHT
STATED YET" : "—"}
${has && c.date ? `
${esc(fmtDate(c.date))}
` : ""}
`); }); if (cfg.goal) { lines.forEach((g, j) => { // Under the remembered line when the readout carries one (rememberedAs "readout"). const gy = cfg.ghosts && mode === "readout" && track.remembered.length ? C + 210 * u : C + 188 * u; parts.push(`
${esc(g.words)}
`); }); } const css = ` .dial { position: absolute; left: ${ox}px; top: ${oy}px; width: ${size}px; height: ${size}px; } .dial .ly { position: absolute; left: 0; top: 0; width: ${size}px; height: ${size}px; transform-origin: ${C}px ${C}px; } .dial .ly svg { display: block; } .dial .asof { position: absolute; transform: translate(-50%, -50%); text-align: center; white-space: nowrap; color: ${colors.ghost}; line-height: 1.05; padding: ${px(3)}px ${px(7)}px; border-radius: ${px(6)}px; background: ${rgba(colors.face, 0.86)}; } .dial .asof b { display: block; font-family: ${fontStack(fonts, "display")}; font-weight: 400; font-size: ${px(24)}px; } .dial .asof span { display: block; font-family: ${fontStack(fonts, "condensed")}; font-size: ${fpx(13)}px; letter-spacing: 0.08em; } .dial .rlab { position: absolute; left: 0; width: ${size}px; text-align: center; font-family: ${fontStack(fonts, "condensed")}; font-size: ${fpx(15)}px; letter-spacing: 0.14em; color: ${colors.muted}; } .dial .read { position: absolute; left: 0; width: ${size}px; text-align: center; } .dial .read .big { font-family: ${fontStack(fonts, "display")}; font-size: ${px(72)}px; line-height: ${px(76)}px; color: ${colors.fg}; font-variant-numeric: tabular-nums; white-space: nowrap; } .dial .read .big i { font-style: normal; font-family: ${fontStack(fonts, "condensed")}; font-size: ${px(20)}px; letter-spacing: 0.1em; color: ${colors.muted}; margin-left: ${px(6)}px; } .dial .read .when { position: absolute; left: 0; width: ${size}px; font-family: ${fontStack(fonts, "condensed")}; font-size: ${fpx(16)}px; line-height: ${Math.max(15, px(20))}px; letter-spacing: 0.1em; color: ${colors.muted}; } .dial .read.pre .big { font-size: ${px(30)}px; line-height: ${px(34)}px; letter-spacing: 0.06em; color: ${colors.muted}; padding-top: ${px(6)}px; } .dial .qlab { position: absolute; transform: translate(-50%, -50%); font-family: ${fontStack(fonts, "display")}; font-size: ${px(26)}px; color: ${colors.accent}; white-space: nowrap; padding: ${px(1)}px ${px(6)}px; border-radius: ${px(5)}px; background: ${rgba(colors.face, 0.9)}; } .dial .goalw { position: absolute; left: 0; width: ${size}px; text-align: center; font-family: ${fontStack(fonts, "bold")}; font-size: ${fpx(17)}px; line-height: ${Math.max(15, px(20))}px; letter-spacing: 0.05em; color: ${colors.amber}; white-space: nowrap; } .dial .goalw.miss { color: ${colors.needle}; }${cfg.ghosts && mode !== "needle" && track.remembered.length ? ` .dial .rflag { position: absolute; transform: translate(-50%, -50%); text-align: center; white-space: nowrap; line-height: 1.08; padding: ${px(4)}px ${px(8)}px; border-radius: ${px(6)}px; background: ${rgba(colors.face, 0.92)}; border: ${px(1.5)}px solid ${rgba(mix(colors.ghost, colors.fg, 0.55), 0.7)}; color: ${mix(colors.ghost, colors.fg, 0.6)}; } .dial .rflag b { display: block; font-family: ${fontStack(fonts, "display")}; font-weight: 400; font-size: ${px(22)}px; } .dial .rflag span { display: block; font-family: ${fontStack(fonts, "condensed")}; font-size: ${fpx(12)}px; letter-spacing: 0.1em; color: ${colors.ghost}; } .dial .rline { position: absolute; left: 0; width: ${size}px; text-align: center; font-family: ${fontStack(fonts, "condensed")}; font-size: ${fpx(16)}px; line-height: ${Math.max(15, px(20))}px; letter-spacing: 0.06em; color: ${mix(colors.ghost, colors.fg, 0.55)}; white-space: nowrap; } .dial .rcall { position: absolute; left: 50%; transform: translate(-50%, -50%); text-align: center; white-space: nowrap; line-height: 1.05; padding: ${px(6)}px ${px(14)}px; border-radius: ${px(8)}px; background: ${rgba(colors.face, 0.94)}; border: ${px(2)}px solid ${mix(colors.ghost, colors.fg, 0.55)}; color: ${mix(colors.ghost, colors.fg, 0.7)}; } .dial .rcall b { display: block; font-family: ${fontStack(fonts, "display")}; font-weight: 400; font-size: ${px(40)}px; } .dial .rcall span { display: block; font-family: ${fontStack(fonts, "condensed")}; font-size: ${fpx(15)}px; letter-spacing: 0.1em; color: ${colors.ghost}; }` : ""}`; return { html: `
${parts.join("\n ")}
`, css, face }; } /** A claim ghost's width (face px at 524) on step `k` of a ramp of `n`: 1.8 at 1x to 3.4 at the last. */ export const ghostWidth = (k, n) => Math.round((1.8 + (n > 1 ? (k / (n - 1)) * 1.6 : 0)) * 100) / 100; /** The claim ghosts' seconds: a step's fade, a pulse's flash and its decay. */ export const GHOST_MOTION = Object.freeze({ fade: 0.35, flash: 0.12, decay: 0.9 }); /** A miss's flash: in, held, out (s). */ export const MISS_MOTION = Object.freeze({ in: 0.15, hold: 0.5, out: 0.8 }); /** The needle's ease (`deck.dial.motion`): the spring's overshoot and settle, or a plain ease. */ const needleEase = (cfg, spring = INSTRUMENT_MOTION.needleEase) => (cfg.motion === "ease" ? INSTRUMENT_MOTION.needlePlain : spring); /** The dial's cues over the cut: the needle on each stated weight, the ghosts, the wedges, the goal, the readout. */ function dialCues(L, { track, scale, cfg, marks = [], lines = [], ghosts = null, prefix = "", finale = false, at = 0 }) { const M = INSTRUMENT_MOTION; const a0 = DIAL_SWEEP.a0; const k = (s) => `${prefix}${s}`; // The finale drives its own needle (dialFinaleHtml). // Before any stated weight the needle rests at the scale's foot, dimmed (the pre-state); it comes up with the first. const pre = !finale && track.current.length && !Number.isFinite(track.current[0].value); if (!finale) L.set(k("nd"), { rotation: a0, opacity: pre ? 0.3 : 1 }); let lit = !pre; track.current.forEach((c, j) => { if (j > 0 && !finale) { const has = Number.isFinite(c.value); L.add(k("nd"), c.t, M.needle, { rotation: has ? dialAngle(c.value, scale) : a0, ...(has && !lit ? { opacity: 1 } : {}) }, needleEase(cfg)); if (has) lit = true; } // The wedge once the needle is all but there, gone with its state -- and its words with it. const w = Number.isFinite(c.value) ? wedgeRange(c.value, c.qualifier, c.range) : null; if (w && dialAngle(w[1], scale) > dialAngle(w[0], scale)) { for (const key of [`q${j}`, `ql${j}`]) { L.set(k(key), { autoAlpha: 0 }); L.add(k(key), c.t + M.needle * 0.6, M.fade, { autoAlpha: 1 }, "power1.out"); const next = track.current[j + 1]; if (next) L.add(k(key), next.t, M.fade * 0.6, { autoAlpha: 0 }, "power1.in"); } } }); blocks(L, track.current, k("cv")); if (cfg.ghosts) { track.remembered.forEach((g, j) => { L.set(k(`g${j}`), { rotation: dialAngle(g.value, scale), autoAlpha: 0 }); L.add(k(`g${j}`), g.t, M.fade, { autoAlpha: 0.55 }, "power1.out"); if (Array.isArray(g.range) && dialAngle(g.range[1], scale) > dialAngle(g.range[0], scale)) { L.set(k(`gb${j}`), { autoAlpha: 0 }); L.add(k(`gb${j}`), g.t, M.fade, { autoAlpha: 1 }, "power1.out"); } }); if (rememberedMode(cfg) !== "needle") rememberedCues(L, { track, scale, cfg, k, finale }); else if (track.remembered.length && finale) { // All at once: the long ghost and its words on the last (the finale puts his highest there). const last = track.remembered.length - 1; const g = track.remembered[last]; L.set(k("gn"), { rotation: dialAngle(g.value, scale), autoAlpha: 0 }); L.add(k("gn"), g.t, M.fade, { autoAlpha: 0.9 }, "power1.out"); track.remembered.forEach((_, j) => L.set(k(`ga${j}`), { autoAlpha: 0 })); L.add(k(`ga${last}`), g.t, M.fade, { autoAlpha: 1 }, "power1.out"); } else if (track.remembered.length) { L.set(k("gn"), { rotation: dialAngle(track.remembered[0].value, scale), autoAlpha: 0 }); track.remembered.forEach((g, j) => { if (j === 0) L.add(k("gn"), g.t, M.fade, { autoAlpha: 0.9 }, "power1.out"); else L.add(k("gn"), g.t, M.ghost, { rotation: dialAngle(g.value, scale) }, "power2.inOut"); }); blocks(L, track.remembered, k("ga"), { fade: M.fade }); } } if (cfg.goal) goalCues(L, { marks, lines, k }); if (ghosts) ghostCues(L, { ghosts, scale, k, finale, at }); } /** The callout's hold (rememberedAs "callout"): the label up this long after he says it, then the rim's flag. */ export const CALLOUT_HOLD = 2.2; /** * The remembered weight's cues in the looks other than the long needle (dialParts, `deck.dial.rememberedAs`): its * rim marker and its flag (or its readout line) up while it is the latest remembered; with "callout", first the * ghost needle sweeping from where the needle stands to the value and the label held CALLOUT_HOLD s. In the finale, * the last one's, all at once. The finale never plays the callout: its labels and its ghost needle are hidden there, the * rim's marker and flag stay. */ function rememberedCues(L, { track, scale, cfg, k, finale }) { const M = INSTRUMENT_MOTION; const R = track.remembered; if (!R.length) return; const mode = rememberedMode(cfg); const call = mode === "callout" && !finale; const label = mode === "readout" ? "gr" : "gl"; const startOf = (g) => (call ? g.t + CALLOUT_HOLD : g.t); R.forEach((g, j) => { L.set(k(`gk${j}`), { rotation: dialAngle(g.value, scale), autoAlpha: 0 }); L.set(k(`${label}${j}`), { autoAlpha: 0 }); // The callout's label is drawn whenever the look is "callout" (dialParts), so it is hidden whenever it is drawn: // in the finale too, where nothing calls it up (rev9-a9: every box sat at its CSS default over the hub). if (mode === "callout") L.set(k(`gc${j}`), { autoAlpha: 0 }); if (finale && j !== R.length - 1) return; const next = finale ? null : R[j + 1]; for (const key of [`gk${j}`, `${label}${j}`]) { L.add(k(key), startOf(g), M.fade, { autoAlpha: 1 }, "power1.out"); if (next) L.add(k(key), startOf(next), M.fade * 0.6, { autoAlpha: 0 }, "power1.in"); } }); // The ghost needle likewise: drawn with the look, hidden with it -- the finale never sweeps it. if (mode === "callout") L.set(k("gn"), { rotation: dialAngle(R[0].value, scale), autoAlpha: 0 }); if (!call) return; const a0 = dialAngle(scale.min, scale); R.forEach((g, j) => { // From where the needle stands as he says it (his stated weight in force then; the scale's foot before one). const cur = [...track.current].filter((c) => c.t <= g.t + 1e-9 && Number.isFinite(c.value)).pop(); L.add(k("gn"), g.t, INSTANT, { rotation: cur ? dialAngle(cur.value, scale) : a0, autoAlpha: 0.9 }, "none"); L.add(k("gn"), g.t + 0.05, M.needle, { rotation: dialAngle(g.value, scale) }, "power2.inOut"); L.add(k("gn"), g.t + CALLOUT_HOLD, 0.4, { autoAlpha: 0 }, "power1.in"); L.add(k(`gc${j}`), g.t + 0.25, M.fade, { autoAlpha: 1 }, "power1.out"); L.add(k(`gc${j}`), g.t + CALLOUT_HOLD, 0.4, { autoAlpha: 0 }, "power1.in"); }); } /** * The goal board's cues (goalMarks, goalLines): each mark's status from each board state -- the headline's triangle, * an other's tick, a miss struck in red with a flash -- and the goal line's words. */ function goalCues(L, { marks, lines, k }) { const M = INSTRUMENT_MOTION; const view = { head: { h: 1, o: 0, x: 0, b: 0.9 }, other: { h: 0, o: 0.85, x: 0, b: 0.4 }, off: { h: 0, o: 0, x: 0, b: 0 } }; const look = (st) => (st.status === "missed" ? { h: st.wasHeadline ? 0.45 : 0, o: st.wasHeadline ? 0 : 0.45, x: 1, b: 0.3 } : view[st.status]); marks.forEach((m, i) => { const hasBand = m.band; if (m.angle !== null) { L.set(k(`gm${i}`), { rotation: m.angle, autoAlpha: 1 }); for (const c of ["h", "o", "x", "p"]) L.set(k(`gm${i}${c}`), { autoAlpha: 0 }); } if (hasBand) L.set(k(`gb${i}`), { autoAlpha: 0 }); let was = view.off; let wasMissed = false; for (const st of m.states) { const v = look(st); if (m.angle !== null) { for (const c of ["h", "o", "x"]) if (v[c] !== was[c]) L.add(k(`gm${i}${c}`), st.t, c === "x" ? MISS_MOTION.in : M.fade, { autoAlpha: v[c] }, "power1.out"); // The miss is the beat: a red flash round the mark as it lands. if (st.status === "missed" && !wasMissed) { L.add(k(`gm${i}p`), st.t, MISS_MOTION.in, { autoAlpha: 1 }, "power1.out"); L.add(k(`gm${i}p`), st.t + MISS_MOTION.in + MISS_MOTION.hold, MISS_MOTION.out, { autoAlpha: 0 }, "power2.in"); } } if (hasBand && v.b !== was.b) L.add(k(`gb${i}`), st.t, M.fade, { autoAlpha: v.b }, "power1.out"); was = v; wasMissed = st.status === "missed"; } }); blocks(L, lines, k("gw"), { shown: (g) => !!g.words }); } /** * The claim ghosts' cues (measure-ghosts.mjs ghostTicks): each tick at its angle, from each claim the step its count * is on faded in and the one before out, and a repeat's pulse. The finale (`finale`) shows every tick at its count * at the end of the cut from `at`, no pulses. */ function ghostCues(L, { ghosts, scale, k, finale, at }) { const G = GHOST_MOTION; const n = ghosts.ramp.length; ghosts.ticks.forEach((x, i) => { L.set(k(`gt${i}`), { rotation: dialAngle(x.value, scale) }); for (let s = 0; s < n; s += 1) { L.set(k(`gt${i}s${s}`), { autoAlpha: 0 }); if (ghosts.cfg.pulse && s > 0) L.set(k(`gt${i}p${s}`), { autoAlpha: 0 }); } if (finale) { const s = Math.min(n - 1, x.claims.length - 1); L.add(k(`gt${i}s${s}`), at, G.fade, { autoAlpha: ghostOpacity(ghosts.cfg.opacity, s) }, "power1.out"); return; } let prev = -1; for (const c of x.claims) { const s = Math.min(n - 1, c.n - 1); if (s !== prev) { L.add(k(`gt${i}s${s}`), c.t, G.fade, { autoAlpha: ghostOpacity(ghosts.cfg.opacity, s) }, "power1.out"); if (prev >= 0) L.add(k(`gt${i}s${prev}`), c.t, G.fade, { autoAlpha: 0 }, "power1.in"); } if (ghosts.cfg.pulse && c.n > 1) { L.add(k(`gt${i}p${s}`), c.t, G.flash, { autoAlpha: 0.9 }, "power1.out"); L.add(k(`gt${i}p${s}`), c.t + G.flash, G.decay, { autoAlpha: 0 }, "power2.in"); } prev = s; } }); } /** The claim ghosts a page draws (deck.measure.ghosts), or null when off. */ function ghostsOf(measure, render, colors) { const cfg = resolveGhosts(render); if (!cfg) return null; return { cfg, ticks: ghostTicks(measure, cfg), ramp: ghostRamp(cfg, colors, mix) }; } /** * The dial's page for the whole cut (or a window of it, `from`/`duration`). * `fonts` = asset-relative paths by face name (DeckSans, DeckSansBold, and * MeasureDisplay / MeasureCond when the manifest names them). */ export function dialHtml(schedule, render, opts = {}) { const M = measureOf(schedule, "dial"); const cfg = resolveDial(render) ?? resolveDial({ chrome: { deck: { dial: true } } }); const geo = instrumentsGeometry(render).dial ?? instrumentsGeometry({ ...render, chrome: { ...render.chrome, deck: { ...render.chrome?.deck, dial: true } } }).dial; const W = geo.width, H = geo.height; const fps = schedule.fps ?? render.fps ?? 30; const fonts = opts.fonts ?? {}; const colors = colorsOf(render, cfg); const track = measureTrack(M); const size = even(Math.min(W, H)); const board = goalBoard(M); const marks = goalMarks(board, M.scale); const lines = goalLines(board); const ghosts = ghostsOf(M, render, colors); const parts = dialParts({ size, ox: Math.floor((W - size) / 2), oy: Math.floor((H - size) / 2), scale: M.scale, cfg, colors, fonts, track, marks, lines, ghosts, heaviest: heaviestOf(M) }); const L = cueList(fps); withDeck(L, schedule, render, "rt"); dialCues(L, { track, scale: M.scale, cfg, marks, lines, ghosts }); // THE UPDATE FLASH (update-flash.mjs): the bezel lights as a weight is stated or remembered, or the goal changes. let flash = { html: "", css: "" }; if (flashOn(render, cfg.flash)) { const times = [...track.current.slice(1), ...track.remembered, ...track.goals.slice(1)].map((x) => x.t); flashCues(L, "fl", flashTimes(times, { fps, away: deckAwaySpans(schedule, render) })); flash = { html: `
`, css: `\n .flw { position: absolute; }\n ${flashCss(".flw .fl", colors.accent, { radius: "50%", width: 3 })}`, }; } const { init, cues } = L.build(); return pageHtml({ id: "dial", W, H, fps, fonts, gsap: opts.gsap, data: { total: r4(schedule.total), window: windowOf(schedule, opts, "dial"), init, cues }, css: `#rt { position: absolute; inset: 0; }${parts.css}${flash.css}`, body: `
${parts.html}${flash.html}
`, }); } // --------------------------------------------------------------------------- // The odometer. // --------------------------------------------------------------------------- /** The odometer's wheels and words, in a box `W`x`H`, scale `u` (1 at its column size). */ function odometerParts({ W, H, u, cfg, colors, fonts, track, wheels, netList, prefix = "", big = false }) { const px = (v) => Math.round(v * u * 100) / 100; const wh = px(big ? 104 : 72), ww = px(big ? 74 : 52), gap = px(5); const parts = []; const strip = (i) => `
${wheelStrip()}
`; const ws = []; for (let i = 0; i <= wheels; i += 1) { if (i === wheels) ws.push(`
`); ws.push(strip(i)); } const left = `
${esc(cfg.label)}
${ws.join("")}
${cfg.runs ? track.lost.map((x, j) => `
${x.runs ? `ACROSS ${x.runs} RUN${x.runs === 1 ? "" : "S"}` : ""}
`).join("") : ""}
`; parts.push(left); if (cfg.net) { const nets = netList.map((n, j) => { const f = n.net?.from, to = n.net?.to; const fv = typeof f === "number" ? f : f?.value, tv = typeof to === "number" ? to : to?.value; const value = Number.isFinite(fv) && Number.isFinite(tv) ? fmtSigned(tv - fv) : "—"; const sub = Number.isFinite(fv) ? `${fmtWeight(fv)} → ${Number.isFinite(tv) ? fmtWeight(tv) : "?"}` : ""; return `
${esc(value)}
${esc(sub)}
`; }).join(""); parts.push(`
NET
${nets}
`); } const lw = cfg.net ? (big ? Math.round(W) : Math.round(W * 0.56)) : W; const css = ` .odo { position: absolute; inset: 0; ${big ? "" : `border-radius: ${px(10)}px; background: ${colors.card};`} } .odo .lft { position: absolute; left: ${big ? 0 : px(20)}px; top: ${big ? 0 : px(12)}px; width: ${lw - (big ? 0 : px(20))}px; } .odo .lab { font-family: ${fontStack(fonts, "condensed")}; font-size: ${px(big ? 22 : 15)}px; letter-spacing: 0.12em; color: ${colors.muted}; white-space: nowrap; } .odo .wheels { display: flex; align-items: flex-end; gap: ${gap}px; margin-top: ${px(big ? 10 : 7)}px; } .odo .wheel { position: relative; width: ${ww}px; height: ${wh}px; overflow: hidden; border-radius: ${px(5)}px; background: ${colors.fg}; box-shadow: inset 0 ${px(8)}px ${px(10)}px rgba(0,0,0,0.28), inset 0 -${px(8)}px ${px(10)}px rgba(0,0,0,0.28); } .odo .wheel.tenth { background: ${colors.needle}; } .odo .strip { position: absolute; left: 0; top: 0; width: ${ww}px; } .odo .dg { height: ${wh}px; line-height: ${wh}px; text-align: center; font-family: ${fontStack(fonts, "display")}; font-size: ${px(big ? 86 : 60)}px; color: ${colors.bg}; font-variant-numeric: tabular-nums; } .odo .wheel.tenth .dg { color: #ffffff; } .odo .dot { width: ${px(big ? 12 : 8)}px; height: ${px(big ? 12 : 8)}px; border-radius: 50%; background: ${colors.fg}; margin: 0 ${px(2)}px ${px(big ? 10 : 8)}px; } .odo .runs { position: absolute; left: 0; top: ${px(big ? 152 : 104)}px; font-family: ${fontStack(fonts, "condensed")}; font-size: ${px(big ? 20 : 14)}px; letter-spacing: 0.12em; color: ${colors.muted}; white-space: nowrap; } .odo .rgt { position: absolute; ${big ? `left: 0; top: ${px(210)}px;` : `left: ${Math.round(W * 0.6)}px; top: ${px(12)}px; border-left: ${px(2)}px solid ${colors.rule}; padding-left: ${px(18)}px; height: ${H - px(24)}px;`} right: ${big ? 0 : px(14)}px; } .odo .net { position: absolute; left: ${big ? 0 : px(18)}px; top: ${px(big ? 28 : 22)}px; white-space: nowrap; } .odo .net .val { font-family: ${fontStack(fonts, "display")}; font-size: ${px(big ? 96 : 58)}px; line-height: 1; color: ${colors.fg}; font-variant-numeric: tabular-nums; } .odo .net .sub { font-family: ${fontStack(fonts, "condensed")}; font-size: ${px(big ? 24 : 17)}px; letter-spacing: 0.08em; color: ${colors.muted}; margin-top: ${px(big ? 6 : 4)}px; font-variant-numeric: tabular-nums; }`; return { html: `
${parts.join("")}
`, css, wh }; } /** The wheels rolled from `a` to `b` at `t` over `dur`, each settled back to its digit after. */ function rollCues(L, { a, b, t, dur, wheels, wh, prefix = "", ease = "power2.inOut" }) { wheelRoll(a, b, wheels).forEach((w, i) => { if (w.to === w.from) return; const k = `${prefix}w${i}`; L.add(k, t, dur, { y: -w.to * wh }, ease); if (w.settle !== null) L.add(k, t + dur, INSTANT, { y: -w.settle * wh }); }); } /** The odometer's page for the whole cut (or a window of it). */ export function odometerHtml(schedule, render, opts = {}) { const M = measureOf(schedule, "odometer"); const cfg = resolveOdometer(render) ?? resolveOdometer({ chrome: { deck: { odometer: true } } }); const geo = instrumentsGeometry(render).odometer ?? instrumentsGeometry({ ...render, chrome: { ...render.chrome, deck: { ...render.chrome?.deck, odometer: true } } }).odometer; const W = geo.width, H = geo.height; const u = W / 600; const fps = schedule.fps ?? render.fps ?? 30; const fonts = opts.fonts ?? {}; const colors = colorsOf(render); const track = measureTrack(M); const top = Math.max(Number(M.totals?.lost) || 0, ...track.lost.map((x) => x.total)); const wheels = wheelCount(top); const parts = odometerParts({ W, H, u, cfg, colors, fonts, track, wheels, netList: track.net }); const L = cueList(fps); withDeck(L, schedule, render, "rt"); for (let i = 0; i <= wheels; i += 1) L.set(`w${i}`, { y: 0 }); track.lost.forEach((x, j) => { if (j === 0) { if (x.total > 0) rollCues(L, { a: 0, b: x.total, t: 0, dur: INSTANT, wheels, wh: parts.wh }); return; } const prev = track.lost[j - 1].total; if (x.total > prev + 1e-9) rollCues(L, { a: prev, b: x.total, t: x.t, dur: INSTRUMENT_MOTION.roll, wheels, wh: parts.wh }); }); if (cfg.runs) blocks(L, track.lost, "rn"); if (cfg.net) blocks(L, track.net, "nt"); // THE UPDATE FLASH (update-flash.mjs): the card lights as the pounds lost go up, its runs or NET change. let flash = { html: "", css: "" }; if (flashOn(render, cfg.flash)) { const times = [...track.lost.slice(1), ...(cfg.net ? track.net.slice(1) : [])].map((x) => x.t); flashCues(L, "fl", flashTimes(times, { fps, away: deckAwaySpans(schedule, render) })); flash = { html: `
`, css: `\n ${flashCss("#rt > .fl", colors.accent, { radius: `${Math.round(10 * u * 100) / 100}px`, width: 2 })}` }; } const { init, cues } = L.build(); return pageHtml({ id: "odometer", W, H, fps, fonts, gsap: opts.gsap, data: { total: r4(schedule.total), window: windowOf(schedule, opts, "odometer"), init, cues }, css: `#rt { position: absolute; inset: 0; }${parts.css}${flash.css}`, body: `
${parts.html}${flash.html}
`, }); } // --------------------------------------------------------------------------- // The trail. // --------------------------------------------------------------------------- /** The trail's page for the whole cut (or a window of it). */ export function trailHtml(schedule, render, opts = {}) { const M = measureOf(schedule, "trail"); const cfg = resolveTrail(render) ?? resolveTrail({ chrome: { deck: { trail: true } } }); const geo = instrumentsGeometry(render).trail ?? instrumentsGeometry({ ...render, chrome: { ...render.chrome, deck: { ...render.chrome?.deck, trail: true } } }).trail; const W = geo.width, H = geo.height; const u = W / 600; const px = (v) => Math.round(v * u * 100) / 100; const fps = schedule.fps ?? render.fps ?? 30; const fonts = opts.fonts ?? {}; const colors = colorsOf(render); const track = measureTrack(M); const mark = Number.isFinite(cfg.mark) ? cfg.mark : null; // THE PLAN (trail-plan.mjs): a state per moment a weight is said -- stated, and remembered unless `remembered` is // off -- each laid out on axes that fit what is shown, the time axis broken across long empty stretches. const pts = trailPoints(M, { remembered: cfg.remembered !== false }); const box = { x0: px(54), x1: W - px(18), y0: px(38), y1: H - px(26), gapPx: px(22), yearPx: px(34) }; const states = trailStates(pts, box, { gap: cfg.gap ?? "auto", mark, bounds: cfg.bounds ?? "fit" }); const first = states[0]?.layout ?? trailLayout([], box, { mark }); const { y0, y1 } = box; const L = cueList(fps); withDeck(L, schedule, render, "rt"); const M2 = INSTRUMENT_MOTION; const RF = TRAIL_REFLOW; const parts = []; const moved = (a, b) => !a || !b || Math.abs(a.x - b.x) > 0.05 || Math.abs(a.y - b.y) > 0.05; // The axes: a label per year (a 1 January inside a cluster a short tick at the axis foot, never a rule over the plot), // a break per gap between clusters (a small "//" on the foot, no band over the plot), the bounds' two figures and the // mark line -- each shown, moved and hidden state by state; before the first weight, the first state's axes. const yearKeys = new Map(); const gapKeys = new Map(); const bounds = new Map(); states.forEach((st) => { for (const y of st.layout.years) if (!yearKeys.has(y.key)) yearKeys.set(y.key, y); for (const g of st.layout.gaps) if (!gapKeys.has(g.key)) gapKeys.set(g.key, g); for (const v of [`hi${st.layout.hi}`, `lo${st.layout.lo}`]) bounds.set(v, null); }); if (!states.length) for (const v of [`hi${first.hi}`, `lo${first.lo}`]) bounds.set(v, null); for (const [key, y] of yearKeys) { parts.push(`
${y.tick ? `
` : ""}
${y.text}
`); } for (const [key] of gapKeys) { parts.push(`
//
`); } for (const key of bounds.keys()) { parts.push(`
${key.slice(2)}
`); } if (mark !== null) parts.push(`
${mark}
`); const axisAt = (layout, at, prev) => { const vis = (list) => new Map(list.map((x) => [x.key, x])); const ys = vis(layout.years), gs = vis(layout.gaps); const pys = prev ? vis(prev.years) : new Map(), pgs = prev ? vis(prev.gaps) : new Map(); for (const [key] of yearKeys) { const now = ys.get(key), was = pys.get(key); if (!prev) { L.set(`y${key}`, { x: (now ?? yearKeys.get(key)).x ?? 0, autoAlpha: now ? 1 : 0 }); continue; } if (now && was) { if (Math.abs(now.x - was.x) > 0.05) L.add(`y${key}`, at, RF, { x: now.x }, "power2.inOut"); } else if (now) L.add(`y${key}`, at, RF, { x: now.x, autoAlpha: 1 }, "power2.out"); else if (was) L.add(`y${key}`, at, RF * 0.6, { autoAlpha: 0 }, "power1.in"); } for (const [key] of gapKeys) { const now = gs.get(key), was = pgs.get(key); if (!prev) { L.set(`g${key}`, { x: (now ?? gapKeys.get(key)).x, autoAlpha: now ? 1 : 0 }); continue; } if (now && was) { if (Math.abs(now.x - was.x) > 0.05) L.add(`g${key}`, at, RF, { x: now.x }, "power2.inOut"); } else if (now) L.add(`g${key}`, at, RF, { x: now.x, autoAlpha: 1 }, "power2.out"); else if (was) L.add(`g${key}`, at, RF * 0.6, { autoAlpha: 0 }, "power1.in"); } // A bound's figure gives way to the mark's when they would sit on each other. const clear = (lay, v) => mark === null || Math.abs(lay.Y(mark) - lay.Y(v)) >= px(14); const shows = (lay, key) => (key === `hi${lay.hi}` && clear(lay, lay.hi)) || (key === `lo${lay.lo}` && clear(lay, lay.lo)); for (const key of bounds.keys()) { const on = shows(layout, key); const was = prev ? shows(prev, key) : null; if (!prev) L.set(`b${key}`, { autoAlpha: on ? 1 : 0 }); else if (on !== was) L.add(`b${key}`, at, RF * 0.6, { autoAlpha: on ? 1 : 0 }, "power1.inOut"); } if (mark !== null) { const y = layout.Y(mark); if (!prev) { L.set("mk", { y }); L.set("ml", { y, yPercent: -50 }); } else if (Math.abs(prev.Y(mark) - y) > 0.05) { L.add("mk", at, RF, { y }, "power2.inOut"); L.add("ml", at, RF, { y }, "power2.inOut"); } } }; axisAt(first, 0, null); // The line, drawn under the points: ONE line through every weight shown, stated and remembered alike, in date order // (trail-plan.mjs trailLine: of several weights for one day, the one said last). A pair is drawn in when it first is // one, moved with the reflows while it lasts, gone the moment a weight said later lands between them (or takes its // day); across a break it is dotted, and with a remembered end it is quieter (the ghost colour, thinner). const pairFirst = new Map(); states.forEach((st, j) => { for (const pr of st.pairs) if (!pairFirst.has(pr.key)) pairFirst.set(pr.key, { ...pr, j }); }); const geomOf = (st, pr) => { const a = st.pos.get(pr.a), b = st.pos.get(pr.b); return { x: a.x, y: a.y, width: r4(Math.hypot(b.x - a.x, b.y - a.y)), rotation: r4((Math.atan2(b.y - a.y, b.x - a.x) * 180) / Math.PI) }; }; for (const [key, pr] of pairFirst) { parts.push(`
`); L.set(`s${key}`, { ...geomOf(states[pr.j], pr), scaleX: 0, autoAlpha: 1, transformOrigin: "0% 50%" }); L.add(`s${key}`, states[pr.j].at, M2.segment, { scaleX: 1 }, "power2.out"); } // The points, over the line: each pops in at its place in the state it is said in, then moves with every reflow after. // A remembered one is a hollow ring in the ghost colour, its border solid (a qualified one a size smaller). const firstState = new Map(); states.forEach((st, j) => { for (const n of st.shown) if (!firstState.has(n)) firstState.set(n, j); }); for (const p of pts) { const j = firstState.get(p.n); const at = states[j].pos.get(p.n); const cls = `pt${p.kind === "remembered" ? " rem" : ""}${p.qualifier ? " q" : ""}`; parts.push(`
`); L.set(`p${p.n}`, { x: at.x, y: at.y, autoAlpha: 0, scale: 0.3 }); L.add(`p${p.n}`, p.t, M2.point, { autoAlpha: 1, scale: 1 }, "back.out(2)"); } // The latest said, ringed in the needle's red: it travels to each as it lands, and with the reflows. if (pts.length) parts.push(`
`); states.forEach((st, j) => { const prev = j ? states[j - 1] : null; const latest = pts.filter((p) => p.t <= st.at + 1e-9).at(-1); if (!prev) { const at0 = st.pos.get(latest.n); L.set("pl", { x: at0.x, y: at0.y, autoAlpha: 0 }); L.add("pl", st.at, M2.point, { autoAlpha: 1 }, "power1.out"); return; } axisAt(st.layout, st.at, prev.layout); for (const n of prev.shown) { const a = prev.pos.get(n), b = st.pos.get(n); if (moved(a, b)) L.add(`p${n}`, st.at, RF, { x: b.x, y: b.y }, "power2.inOut"); } const was = new Map(prev.pairs.map((pr) => [pr.key, pr])); const now = new Map(st.pairs.map((pr) => [pr.key, pr])); for (const [key, pr] of was) { if (!now.has(key)) { L.add(`s${key}`, st.at, RF * 0.5, { autoAlpha: 0 }, "power1.in"); continue; } const g0 = geomOf(prev, pr), g1 = geomOf(st, pr); if (moved(g0, g1) || Math.abs(g0.width - g1.width) > 0.05 || Math.abs(g0.rotation - g1.rotation) > 0.05) L.add(`s${key}`, st.at, RF, g1, "power2.inOut"); } const ring = st.pos.get(latest.n); L.add("pl", st.at, RF, { x: ring.x, y: ring.y }, "power2.inOut"); }); // How many times he says he is under 300, counted as each lands. const counts = cfg.count && mark === 300 ? track.under.slice().sort((a, b) => a.t - b.t).map((x, n) => ({ t: x.t, n: n + 1 })) : []; counts.forEach((c) => parts.push(`
UNDER ${mark} · SAID ${c.n}×
`)); if (counts.length) blocks(L, counts, "uc"); // THE TRAIL YIELDS to the promise clock (measure-extras' `promise.slot: "column"`, the default beside the // instruments): faded out while the clock stands in its slot, back when it goes. for (const sp of trailYields(schedule, render)) { L.add("ty", sp.in, 0.4, { autoAlpha: 0 }, "power1.in"); if (sp.out < schedule.total - 0.05) L.add("ty", sp.out, 0.4, { autoAlpha: 1 }, "power1.out"); } L.set("ty", { autoAlpha: 1 }); // THE UPDATE FLASH (update-flash.mjs): the card lights as each weight lands on it. const flashing = flashOn(render, cfg.flash); if (flashing) { flashCues(L, "fl", flashTimes(states.map((st) => st.at), { fps, away: deckAwaySpans(schedule, render) })); parts.push(`
`); } const { init, cues } = L.build(); const css = ` #rt { position: absolute; inset: 0; } .ty { position: absolute; inset: 0; }${flashing ? `\n ${flashCss(".trail .fl", colors.accent, { radius: `${px(10)}px`, width: 2 })}` : ""} .trail { position: absolute; inset: 0; border-radius: ${px(10)}px; background: ${colors.card}; overflow: hidden; } .trail .lab { position: absolute; left: ${px(14)}px; top: ${px(10)}px; font-family: ${fontStack(fonts, "condensed")}; font-size: ${px(14)}px; letter-spacing: 0.12em; color: ${colors.muted}; white-space: nowrap; } .trail .cnt { position: absolute; right: ${px(16)}px; top: ${px(9)}px; font-family: ${fontStack(fonts, "bold")}; font-size: ${px(15)}px; letter-spacing: 0.06em; color: ${colors.accent}; white-space: nowrap; } .trail .yw { position: absolute; left: 0; top: 0; width: 0; height: 0; } .trail .yr { position: absolute; left: 0; transform: translateX(-50%); font-family: ${fontStack(fonts, "condensed")}; font-size: ${px(13)}px; color: ${colors.muted}; letter-spacing: 0.06em; white-space: nowrap; } .trail .ytick { position: absolute; left: 0; width: 1px; background: ${colors.muted}; opacity: 0.6; } .trail .gp { position: absolute; left: 0; width: ${px(12)}px; margin-left: -${px(6)}px; background: ${colors.card}; } .trail .gz { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-family: ${fontStack(fonts, "condensed")}; font-size: ${px(12)}px; line-height: 1; color: ${colors.muted}; letter-spacing: -0.1em; } .trail .mark { position: absolute; top: 0; height: 0; border-top: ${px(2)}px dashed ${rgba(colors.accent, 0.75)}; } .trail .marklab, .trail .lohi { position: absolute; transform: translateY(-50%); font-family: ${fontStack(fonts, "condensed")}; font-size: ${px(13)}px; color: ${colors.muted}; } .trail .marklab { top: 0; transform: none; color: ${colors.accent}; font-family: ${fontStack(fonts, "bold")}; } .trail .seg { position: absolute; left: 0; top: 0; height: ${px(2.6)}px; margin-top: -${px(1.3)}px; background: ${colors.accent}; border-radius: ${px(2)}px; } .trail .seg.rem { height: ${px(1.8)}px; margin-top: -${px(0.9)}px; background: ${rgba(colors.ghost, 0.5)}; } .trail .seg.gap { height: 0; margin-top: -${px(1)}px; background: none; border-top: ${px(2)}px dotted ${rgba(colors.accent, 0.55)}; border-radius: 0; } .trail .seg.gap.rem { margin-top: -${px(0.8)}px; border-top: ${px(1.6)}px dotted ${rgba(colors.ghost, 0.5)}; } .trail .pt { position: absolute; left: 0; top: 0; width: ${px(10)}px; height: ${px(10)}px; margin: -${px(5)}px 0 0 -${px(5)}px; border-radius: 50%; background: ${colors.accent}; border: ${px(2)}px solid ${colors.card}; } .trail .pt.q { background: ${colors.card}; border: ${px(2.4)}px solid ${colors.accent}; } .trail .pt.rem { background: ${colors.card}; border: ${px(2.4)}px solid ${colors.ghost}; } .trail .pt.rem.q { width: ${px(8)}px; height: ${px(8)}px; margin: -${px(4)}px 0 0 -${px(4)}px; border-width: ${px(2)}px; } .trail .ring { position: absolute; left: 0; top: 0; width: ${px(20)}px; height: ${px(20)}px; margin: -${px(10)}px 0 0 -${px(10)}px; border-radius: 50%; border: ${px(3)}px solid ${colors.needle}; }`; return pageHtml({ id: "trail", W, H, fps, fonts, gsap: opts.gsap, data: { total: r4(schedule.total), window: windowOf(schedule, opts, "trail"), init, cues }, css, body: `
${esc(cfg.label)}
${parts.join("")}
`, }); } /** When the promise clock stands in the trail's slot (its up spans, `promise.slot` "column"): the trail yields then. */ export function trailYields(schedule, render) { const cfg = resolveMeasureExtra("promise", render); if (!cfg || cfg.slot !== "column") return []; const states = promiseStates(schedule, render); return states.length ? upSpans(states.map((x) => x.at), { ...cfg, finale: "show" }, schedule) : []; } // --------------------------------------------------------------------------- // The dial's finale. // --------------------------------------------------------------------------- /** * Where the dial's finale stands (frame px): the finale's lower column * (finale.mjs finaleGeometry `column`), under its totals when it draws them -- * or null when that leaves no room (stats cards fill it, or under 260 px). */ export function dialFinaleGeometry(schedule, render) { if (!schedule?.finale) return null; // THE STACKED VERTICAL DECK (vertical-deck.mjs): the instrument column over the picture's room, its title where // the rail stands -- the landscape finale's page is not drawn there, so this one is opaque. if (stackedOn(render)) { const f = stackedGeometry(render).finale; return { x: f.title.x, y: f.title.y, width: f.column.width, height: 2 * Math.floor((f.column.y + f.column.height - f.title.y) / 2) }; } const g = finaleLayout(schedule, render).geo; if (g.stats) return null; const kh = g.H / 1080; const y = g.totals ? g.totals.y + g.totals.height + Math.round(28 * kh) : g.column.y; const h = g.column.y + g.column.height - y; if (h < 260 * kh || g.column.width < 520 * g.k) return null; return { x: g.column.x, y, width: even(g.column.width), height: even(h) }; } /** What the finale ends on: the last stated weight, the odometer's total, NET -- the whole record's (`totals`), else the cut's last. */ export function finaleNumbers(measure) { const track = measureTrack(measure); const T = measure?.totals ?? {}; const n = T.net ?? {}; const val = (x) => (typeof x === "number" ? x : x?.value); const lastCur = [...track.current].reverse().find((c) => Number.isFinite(c.value)) ?? null; const lastNet = track.net[track.net.length - 1]?.net ?? null; const from = Number.isFinite(val(n.from)) ? val(n.from) : val(lastNet?.from); const to = Number.isFinite(val(n.to)) ? val(n.to) : Number.isFinite(val(lastNet?.to)) ? val(lastNet.to) : lastCur?.value; const lost = Number.isFinite(T.lost) ? T.lost : track.lost[track.lost.length - 1]?.total ?? 0; const runs = Number.isFinite(T.runs) ? T.runs : track.lost[track.lost.length - 1]?.runs ?? 0; const peaks = (Array.isArray(T.peakDrift) ? T.peakDrift : []).concat(track.remembered.map((r) => r.value)).filter(Number.isFinite); return { weight: Number.isFinite(to) ? to : null, qualifier: lastCur && lastCur.value === to ? lastCur.qualifier : null, range: lastCur && lastCur.value === to && Array.isArray(lastCur.range) ? lastCur.range : null, lost, runs, from: Number.isFinite(from) ? from : null, peak: peaks.length ? Math.max(...peaks) : null, // The goal the finale ends on: the board's headline at the cut's end -- the CLOSEST goal in force (measure-goals.mjs). goal: goalsAt(goalBoard(measure), Infinity).headline ?? null, }; } /** The handoff to the promise clock: NET's beat (in at the grow + 3.2 s) held `hold` s, then a `fade`. */ export const FINALE_HANDOFF = Object.freeze({ net: 3.2, hold: 2.3, fade: 0.5, clock: 2.5 }); /** * When the dial's finale hands the finale's lower column to the promise clock * (cut seconds) -- `deck.dial.finaleEnd: "promise"` -- or null: it ends on the * odometer, or the finale is too short to hold NET first. The promise module * (measure-extras) reads it to come in as the instruments go. Whether a * promise module is on the cut is the caller's to say (the dial-finale * module's page asks the registry). */ export function dialFinaleHandoff(schedule, render) { const fin = schedule?.finale; const end = resolveDial(render)?.finaleEnd; // "auto": the promise clock's when a promise is on camera. const promised = (schedule?.measure?.events ?? []).some((e) => e?.kind === "promise" && Number.isFinite(e.t)); if (!fin || !(end === "promise" || (end === "auto" && promised))) return null; // On the cue grid, so the promise clock's cue and the instruments' land on the same frame. NET's hold shortens // in a short finale so the clock still has FINALE_HANDOFF.clock seconds (rev 9: a 7.2 s finale left it none), // but never before NET has come in. const fps = schedule.fps ?? render.fps ?? 30; const netIn = fin.from + FINALE_MOTION.grow + FINALE_HANDOFF.net + 0.5; const at = cueTime(Math.min(netIn + FINALE_HANDOFF.hold, fin.to - FINALE_HANDOFF.clock), fps); return at >= netIn - 1e-6 && at + FINALE_HANDOFF.fade < fin.to ? at : null; } /** * The dial's finale page over the finale's `window` (cut seconds; the * finale's own, finale.mjs): the dial large, its needle dropping from his * highest remembered weight to his last stated one; the odometer rolling up * to the record's total; NET holding beside it. In over the finale's grow, * out through its dissolve. */ export function dialFinaleHtml(schedule, render, window, opts = {}) { const M = measureOf(schedule, "dial-finale"); const geo = dialFinaleGeometry(schedule, render); if (!geo) throw new Error("dial-finale: the finale's lower column has no room (its stats cards fill it)"); const cfg = resolveDial(render) ?? resolveDial({ chrome: { deck: { dial: true } } }); const ocfg = resolveOdometer(render) ?? resolveOdometer({ chrome: { deck: { odometer: true } } }); const W = geo.width, H = geo.height; const fps = schedule.fps ?? render.fps ?? 30; const fonts = opts.fonts ?? {}; const colors = colorsOf(render, cfg); const from = r4(Number(window.from)); const dur = r4(Number(window.to) - from); if (!(dur > 0)) throw new Error("dial-finale: the window is empty"); const nums = finaleNumbers(M); const full = measureTrack(M); // The dial's track in the finale: every ghost already there, one state of the needle, the latest goal. const A = from + FINALE_MOTION.grow; // The ghosts in the order the cut told them, so the long ghost and its words stand on the LATEST remembered row -- // the one the cut's last state shows ("≈390 AS OF FEB 2025"), never an earlier telling of the same number. const rem = full.remembered.map((r, n) => ({ ...r, t: A, n })); const track = { ...full, current: [{ t: from, value: null }, { t: A + 0.4, value: nums.weight, qualifier: nums.qualifier, date: null, ...(nums.range ? { range: nums.range } : {}) }], remembered: rem, }; // The goals in force at the cut's end, all at once as the needle drops (the miss beats were the cut's). const end = goalsAt(goalBoard(M), Infinity); const board = [{ t: from, active: [], headline: null, missed: [] }, { t: A + 0.4, active: end.active, headline: end.headline, missed: [] }]; const marks = goalMarks(board, M.scale); const lines = goalLines(board); // The claim ghosts STAY: the finale is the summary, and the residue of every number he gave is the point of it -- // each tick at its count at the cut's end, in with the finale's grow under the needle's drop, no pulses. const ghosts = ghostsOf(M, render, colors); // Portrait (the stacked vertical deck): its title on top, the dial large in a card under it, the odometer and // NET under that, all on an opaque ground (no landscape finale page under it). Landscape: the dial beside the wheels. const portrait = stackedOn(render); const u = W / 912; const titleH = portrait ? Math.round(64 * u) : 0; const cardH = portrait ? even(Math.round(H * 0.46)) : 0; const size = portrait ? even(Math.min(W * 0.62, cardH - Math.round(36 * u))) : even(Math.min(H, Math.round(W * 0.56))); const k = size / 524; const dial = dialParts({ size, ox: portrait ? Math.floor((W - size) / 2) : 0, oy: portrait ? titleH + Math.round(18 * u) + Math.floor((cardH - size) / 2) : Math.floor((H - size) / 2), scale: M.scale, cfg, colors, fonts, track, marks, lines, ghosts, prefix: "f", preState: false, heaviest: heaviestOf(M), }); const rw = portrait ? W - Math.round(48 * u) : W - size - Math.round(40 * k); const top = Math.max(Number(M.totals?.lost) || 0, nums.lost); const wheels = wheelCount(top); const ob = portrait ? { x: Math.round(24 * u), y: titleH + Math.round(18 * u) + cardH + Math.round(34 * u), width: rw } : { x: size + Math.round(40 * k), y: Math.floor((H - size) / 2) + Math.round(24 * k), width: rw }; const odo = odometerParts({ W: rw, H: H - ob.y, u: Math.min(1, rw / 420), cfg: { ...ocfg, runs: true }, colors, fonts, track: { lost: [{ t: from, total: 0, runs: 0 }, { t: A + 0.6, total: nums.lost, runs: nums.runs }] }, wheels, netList: [{ t: from, net: null }, { t: A + 3.2, net: nums.from !== null && nums.weight !== null ? { from: nums.from, to: nums.weight } : null }], prefix: "o", big: true, }); const L = cueList(fps); // In with the finale itself, over its grow, as the column's instruments go under it (withDeck): a crossfade, no // empty frame between them (rev 9: 0.8 s of the finale's ground alone at 779.3 s). L.set("rt", { autoAlpha: 0 }); L.add("rt", from, FINALE_MOTION.grow, { autoAlpha: 1 }, "power1.inOut"); const D = Number(schedule.transition) || 0; // The last beat: the promise clock's (deck.dial.finaleEnd "promise", a promise module on the cut) -- // the instruments go at the handoff and leave it the column -- else theirs, out through the dissolve. const handoff = opts.promise ? dialFinaleHandoff(schedule, render) : null; if (handoff !== null) L.add("rt", handoff, FINALE_HANDOFF.fade, { autoAlpha: 0 }, "power1.in"); else if (D > 0 && from + dur - D > A + 0.4) L.add("rt", from + dur - D, D, { autoAlpha: 0 }, "power1.in"); // The needle starts at his highest remembered weight (the scale's top without one) and drops. const start = Number.isFinite(nums.peak) ? nums.peak : M.scale.max; dialCues(L, { track, scale: M.scale, cfg, marks, lines, ghosts, prefix: "f", finale: true, at: A }); L.set("fnd", { rotation: dialAngle(start, M.scale) }); if (Number.isFinite(nums.weight)) L.add("fnd", A + 0.4, 1.8, { rotation: dialAngle(nums.weight, M.scale) }, needleEase(cfg, "back.out(1.4)")); for (let i = 0; i <= wheels; i += 1) L.set(`ow${i}`, { y: 0 }); rollCues(L, { a: 0, b: nums.lost, t: A + 0.6, dur: 2.6, wheels, wh: odo.wh, prefix: "o", ease: "power3.out" }); blocks(L, [{ t: from, runs: 0 }, { t: A + 0.6 + 2.6, runs: nums.runs }], "orn", { fade: 0.3, shown: (x) => x.runs > 0 }); blocks(L, [{ t: from }, { t: A + 3.2 }], "ont", { fade: 0.5, shown: (x) => x.t > from }); // NET comes in whole, its word with its number. L.set("onet", { autoAlpha: 0 }); L.add("onet", A + 3.2, 0.5, { autoAlpha: 1 }, "power1.out"); const { init, cues } = L.build(); const ground = portrait ? ` .fg { position: absolute; inset: 0; background: ${colors.bg}; } .ftitle { position: absolute; left: 0; top: 0; height: ${titleH}px; line-height: ${titleH}px; font-family: ${fontStack(fonts, "display")}; font-size: ${Math.round(40 * u)}px; letter-spacing: 0.06em; color: ${colors.accent}; white-space: nowrap; } .fcard { position: absolute; left: 0; top: ${titleH + Math.round(18 * u)}px; width: ${W}px; height: ${cardH}px; border-radius: ${Math.round(24 * u)}px; background: ${colors.card}; box-shadow: inset 0 0 0 1px ${colors.rule}; }` : ""; const groundHtml = portrait ? `
${esc(opts.title ?? "THE RECORD SO FAR")}
` : ""; return pageHtml({ id: "dial-finale", W, H, fps, fonts, gsap: opts.gsap, data: { from, dur, init, cues }, css: `#rt { position: absolute; inset: 0; }${ground}${dial.css} .ob { position: absolute; left: ${ob.x}px; top: ${ob.y}px; width: ${ob.width}px; height: ${H - ob.y}px; }${odo.css}`, body: `
${groundHtml}${dial.html}
${odo.html}
`, }); } export { railGap };