commit d3c7a01baa54384419feaeb9a9762068df29fe45 parent 333785d02676ed2318bbf85930b196de310c1106 Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st> Date: Fri, 6 Nov 2026 02:41:05 -0500 Merge lane/rev9-fixes (A-K): instruments on with a measure slice; the dial's "no weight stated yet" pre-state, range wedges and goal bands, loss goals never below the scale's foot, the told-N ghost label, crossfade into the dial finale; finale railLabels sections|none and a wrapped source line; the promise clock in the instruments column during posts (slot auto|column|footage); extras along the foot in column mode, peak off beside the dial, dodges avoid the face-cam corner (operator, 5 Nov: "all modules", "Make variants for me to judge") Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Diffstat:
23 files changed, 695 insertions(+), 123 deletions(-)
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -1802,7 +1802,7 @@ A bathroom-scale face at the top of the instruments' column (the right of the fr | Knob | Range · default | From a terminal | |---|---|---| -| `deck.dial` | `true` · an object of the knobs below · absent or `false` off | `umtool look <p> deck.dial=true` | +| `deck.dial` | `true` · an object of the knobs below · `false` off · absent: ON when the cut draws a measure (`deck.measure` set), else off | `umtool look <p> deck.dial=false` | | `deck.dial.mark` | a weight, or `null` · default `300` (its tick and label in the accent) | `umtool look <p> deck.dial.mark=300` | | `deck.dial.ghosts`, `.goal` | bool · default `true` each | `umtool look <p> deck.dial.ghosts=false` | | `deck.dial.needle` | a #hex · default `#ff5a4e` | `umtool look <p> deck.dial.needle='"#ff5a4e"'` | @@ -1812,7 +1812,7 @@ A bathroom-scale face at the top of the instruments' column (the right of the fr | `deck.dial.size` | 200–540 px at 1920 wide · default `340` (the corner dial only) | `umtool look <p> deck.dial.size=300` | | `deck.dial.corner` | `bottom-right` `bottom-left` `top-right` `top-left` · default `bottom-right` (the corner only): the dial in that corner, the odometer and the trail up the same side. The measure extras stand at their own anchors in the footage (goals bottom-right, peak top-right, promise top-centre, diet bottom-left, streak bottom-centre): a corner instrument over one that is on is REFUSED by the build, naming it -- move one (`deck.goals.position`, …) or the corner; `top-left` is clear of all five | `umtool look <p> deck.dial.corner=top-left` | | `deck.dial.motion` | `spring` `ease` · default `spring`. A VARIANT: the needle's `back.out` overshoot and settle, or a plain `power2.inOut` (the finale's drop too) | `umtool look <p> deck.dial.motion=ease` | -| `deck.dial.finaleEnd` | `odometer` `promise` · default `odometer`. A VARIANT: `promise` hands the finale's last beat to the promise clock (module `promise`) -- the instruments fade out once NET has held (`dialFinaleHandoff`); with no promise module on the cut it ends on the odometer | `umtool look <p> deck.dial.finaleEnd=promise` | +| `deck.dial.finaleEnd` | `auto` `odometer` `promise` · default `auto` (`promise` when a promise is on camera, else `odometer`): `promise` hands the finale's last beat to the promise clock (module `promise`) -- the instruments fade out once NET has held (`dialFinaleHandoff`) and the clock takes their place in the finale's lower column, clear of the rail; with no promise module on the cut it ends on the odometer | `umtool look <p> deck.dial.finaleEnd=promise` | ### Lost odometer @@ -1820,7 +1820,7 @@ Under the dial: the measure's `state.lost.total` (the highest real-time loss cla | Knob | Range · default | From a terminal | |---|---|---| -| `deck.odometer` | `true` · an object of the knobs below · absent or `false` off | `umtool look <p> deck.odometer=true` | +| `deck.odometer` | `true` · an object of the knobs below · `false` off · absent: ON when the cut draws a measure (`deck.measure` set), else off | `umtool look <p> deck.odometer=false` | | `deck.odometer.label` | words over the wheels, ≤ 40 · default `POUNDS HE SAYS HE'S LOST` | `umtool look <p> deck.odometer.label='"…"'` | | `deck.odometer.net`, `.runs` | bool · default `true` each | `umtool look <p> deck.odometer.net=false` | @@ -1830,7 +1830,7 @@ At the foot of the instruments' column: every STATED weight the cut shows, place | Knob | Range · default | From a terminal | |---|---|---| -| `deck.trail` | `true` · an object of the knobs below · absent or `false` off | `umtool look <p> deck.trail=true` | +| `deck.trail` | `true` · an object of the knobs below · `false` off · absent: ON when the cut draws a measure (`deck.measure` set), else off | `umtool look <p> deck.trail=false` | | `deck.trail.mark` | a weight, or `null` · default `300` | `umtool look <p> deck.trail.mark=300` | | `deck.trail.count` | bool · default `true` | `umtool look <p> deck.trail.count=false` | | `deck.trail.label` | its title, ≤ 40 · default `WHAT HE SAYS HE WEIGHS, BY DATE` | `umtool look <p> deck.trail.label='"…"'` | diff --git a/umtool/e2e/instruments.spec.ts b/umtool/e2e/instruments.spec.ts @@ -111,9 +111,9 @@ test("the dial's page posts dial:ready and is seeked in the cut's seconds: the n const h = await harness(page, dial.src!, baseURL!); await expect.poll(h.messages, { timeout: 30_000 }).toContain("dial:ready"); - // Before any stated weight: the dash, the needle at rest on the scale's foot (220 lb: -135°). + // Before any stated weight: the pre-state in words (rev 9), the needle at rest on the scale's foot (220 lb: -135°). await h.seek(0.2); - await expect.poll(() => visibleReadout(h.frame)).toEqual(["—"]); + await expect.poll(() => visibleReadout(h.frame)).toEqual(["NO WEIGHTSTATED YET"]); await expect.poll(() => needleDeg(h.frame)).toBe(-135); // After "over 240" has settled (and the ≈390 is said): its weight, the needle at 240 (-105°), its wedge up. const settled = tOf("w21", 0.9); @@ -179,10 +179,10 @@ test("Play the cut draws the dial, the odometer and the trail from the estimate' const dial = page.frameLocator('[data-testid="play-layer-dial-iframe"]'); await expect.poll(() => visibleReadout(dial), { timeout: 15_000 }).toEqual(["291.5LB"]); await page.screenshot({ path: test.info().outputPath("instruments-play-c04.png") }); - // Back to c01, before the weight is said: the dash. + // Back to c01, before the weight is said: the pre-state. await page.locator('[data-play-row="c01"]').press("Enter"); await expect(root).toHaveAttribute("data-play-item", "c01"); - await expect.poll(() => visibleReadout(dial), { timeout: 15_000 }).toEqual(["—"]); + await expect.poll(() => visibleReadout(dial), { timeout: 15_000 }).toEqual(["NO WEIGHTSTATED YET"]); }); test("the module panel lists the instruments and previews the dial alone, seeked by its scrubber", async ({ page }) => { diff --git a/umtool/e2e/play-measure.spec.ts b/umtool/e2e/play-measure.spec.ts @@ -19,7 +19,9 @@ import * as urls from "./urls"; // --------------------------------------------------------------------------- const PROJECT = "reports/play-measure-fixture"; -const IDS = ["streak", "diet", "peak", "goals", "promise"] as const; +// The fixture draws a measure, so the instruments are on (rev 9): the moving start is off beside the dial, and the +// promise clock stands in the column's trail slot. +const IDS = ["streak", "diet", "goals", "promise"] as const; const root = (page: Page) => page.locator("[data-play-cut]"); const layer = (page: Page, id: string) => page.locator(`[data-play-layer="${id}"]`); @@ -60,8 +62,11 @@ test("the measure extras play in Play the cut, each page seeked to the playhead' await page.goto(urls.playHref(PROJECT, { clip: "c04", at: 1 })); await ready(page); await expect(root(page)).toHaveAttribute("data-play-item", "c04"); - // Laid in the build's z order: the streak (65), diet (66), peak (67), goals (68), the promise clock (95, over the finale). - expect(await page.locator("[data-play-layer]").evaluateAll((els) => els.map((e) => e.getAttribute("data-play-layer")))).toEqual([...IDS]); + // Laid in the build's z order: the streak (65), diet (66), goals (68), the promise clock (95, over the finale). + const laid = await page.locator("[data-play-layer]").evaluateAll((els) => els.map((e) => e.getAttribute("data-play-layer"))); + expect(laid.filter((id) => (IDS as readonly string[]).includes(id ?? ""))).toEqual([...IDS]); + expect(laid).toContain("dial"); + expect(laid).not.toContain("peak"); await expect.poll(() => shown(page, "goals"), { timeout: 10_000 }).toContain("LOSE 65"); const goals = await shown(page, "goals"); @@ -69,12 +74,8 @@ test("the measure extras play in Play the cut, each page seeked to the playhead' expect(goals).toContain("needs 226.5"); expect(goals).toContain("×2"); expect(goals).toContain("3 goals set"); - const peak = await shown(page, "peak"); - expect(peak).toContain("≈390"); - expect(peak).toContain("365.7"); - expect(peak).toContain("+24.3 lb"); const promise = await shown(page, "promise"); - expect(promise).toContain("scale video offered 23 Oct"); + expect(promise).toContain("scale video · offered 23 Oct"); expect(promise).toContain("11 days"); expect(promise).toContain("None posted"); // Her claim (SYNTHETIC in the fixture): the counterparty under the header. @@ -98,7 +99,6 @@ test("the measure extras play in Play the cut, each page seeked to the playhead' expect(await shown(page, "diet")).toContain("Keto"); expect(await shown(page, "diet")).toContain("Diet #1"); expect(await shown(page, "streak")).toContain("Keto"); - await expect.poll(() => shown(page, "peak"), { timeout: 10_000 }).toContain("365.7"); expect(await shown(page, "promise")).toBeNull(); await page.screenshot({ path: test.info().outputPath("play-measure-c02.png") }); }); diff --git a/umtool/report-to-video/chrome-finale.mjs b/umtool/report-to-video/chrome-finale.mjs @@ -120,7 +120,8 @@ export function finaleLayout(schedule, render) { }, text: { ...lay.text, titleY: deckY + lay.text.titleY, subtitleY: deckY + lay.text.subtitleY, ruleY: deckY + lay.text.ruleY }, }, - pips, labels, marks, totals, stats, captions, panel, + // `sections` / `none`: no pip's label or date on the rail. + pips, labels: f.railLabels === "sections" || f.railLabels === "none" ? { ...labels, groups: [], lead: 0 } : labels, marks, totals, stats, captions, panel, ...(claims ? { claims } : {}), statsTitle: f.statsTitle, railLabels: f.railLabels, @@ -223,7 +224,7 @@ export function finaleCues(schedule, render, L = finaleLayout(schedule, render)) }); L.marks.forEach((mk, j) => { travel(`mk${j}`, { x: r2(mk.foot.x - mk.x), y: r2(ft.y - bt.y), scale: 0.4 }, "finale marker"); - if (L.railLabels === "all") reveal(`ml${j}`, R + j * m.stagger, "finale marker label"); + if (L.railLabels === "all" || L.railLabels === "sections") reveal(`ml${j}`, R + j * m.stagger, "finale marker label"); }); // The claim checks, once the rail is in place: all at once, or ("rotate") // each in its slot, crossfading into the next at the slot's edge. @@ -304,6 +305,17 @@ export function finaleCues(schedule, render, L = finaleLayout(schedule, render)) * `window.from`). `fonts` = `{ regular, bold }`, `qrSrcs` = `{ [segmentId]: * "assets/qrNN.png" }`, `gsap` = the vendored script's asset path. */ +/** + * The clip card's source line with the source's TITLE last ("TheQuartering (Rumble) · Nov 3, 2026 · 13:48 · + * Democrats PANIC …"): wrapped to two lines, only the title's end is ever clamped -- never the date or the clock + * (rev 9: "Democrats PANIC … · N… · 13:48"). + */ +export function titleLast(subtitle) { + const parts = String(subtitle ?? "").split(" · "); + if (parts.length < 3) return String(subtitle ?? ""); + return [parts[0], ...parts.slice(2), parts[1]].join(" · "); +} + export function finaleHtml(schedule, render, window, opts = {}) { const L = finaleLayout(schedule, render); const { init, cues } = finaleCues(schedule, render, L); @@ -406,7 +418,7 @@ export function finaleHtml(schedule, render, window, opts = {}) { .map((mk, j) => { const top = rowTop[mk.row] ?? rowTop[0]; const stick = Y - top - 2; - const label = L.railLabels === "all" + const label = L.railLabels === "all" || L.railLabels === "sections" ? `<div class="ml" data-k="ml${j}" style="top:${top - Y}px; ${mk.side === "right" ? "left:18px" : "right:18px"}; max-width:${mk.max}px">${esc(mk.label)}</div>` : ""; return ( @@ -443,7 +455,7 @@ export function finaleHtml(schedule, render, window, opts = {}) { return ( `<div class="cap" data-k="cap${i}" data-seg="${esc(c.id)}" style="left:${cap.x}px; top:${cap.y}px; width:${cap.width}px">` + (c.title ? `<div class="ct">${esc(c.title)}</div>` : "") + - `<div class="cs">${subtitleMarkup(c.subtitle)}</div></div>` + + `<div class="cs">${subtitleMarkup(titleLast(c.subtitle))}</div></div>` + `<div class="cqr" data-k="qr${i}" style="left:${q.x}px; top:${q.y}px; width:${q.size}px; height:${q.size}px">` + (src ? `<img src="${esc(src)}" width="${q.size}" height="${q.size}" alt="">` : "") + `</div>` @@ -550,10 +562,13 @@ export function finaleHtml(schedule, render, window, opts = {}) { .cap { position: absolute; } .ct { font-family: 'DeckSansBold', sans-serif; font-size: ${cap.titleSize}px; line-height: ${Math.round(cap.titleSize * 1.2)}px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } - .cs { display: flex; white-space: nowrap; overflow: hidden; font-size: ${cap.subSize}px; line-height: ${Math.round(cap.subSize * 1.3)}px; color: ${pal.muted}; } - .cs .part { flex: none; } - .cs .part:not(:first-child):not(:last-child), .cs .part:first-child:nth-last-child(-n+3) { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; } - .cs .sep { flex: none; color: ${pal.accent}; padding: 0 0.42em; font-family: 'DeckSansBold', sans-serif; } + /* The source line wraps to two lines at word boundaries (rev 9: "Democrats PANIC … · N… · 13:48" cut both the + title and the date mid-word); past two, the second line ends in an ellipsis. A date or clock never breaks. */ + .cs { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; overflow: hidden; + font-size: ${cap.subSize}px; line-height: ${Math.round(cap.subSize * 1.3)}px; color: ${pal.muted}; } + .cs .part { display: inline; } + .cs .part:not(:last-child) { white-space: nowrap; } + .cs .sep { display: inline; color: ${pal.accent}; padding: 0 0.42em; font-family: 'DeckSansBold', sans-serif; } .cqr { position: absolute; transform-origin: 0 0; } .cqr img { display: block; width: 100%; height: 100%; border-radius: 6px; image-rendering: pixelated; box-shadow: 0 0 0 1px ${rgba(pal.fg, 0.25)}, 0 6px 18px rgba(0, 0, 0, 0.35); } diff --git a/umtool/report-to-video/chrome-instruments.mjs b/umtool/report-to-video/chrome-instruments.mjs @@ -18,9 +18,11 @@ 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 { promiseStates, upSpans } from "./measure-extras.mjs"; +import { resolveMeasureExtra } from "./modules/measure-extras-settings.mjs"; import { cueList, dayNumber, dialAngle, dialFaceSvg, DIAL_SWEEP, esc, fmtDate, fmtSigned, fmtWeight, INSTANT, measureTrack, - pageHtml, polar, qualifierMark, r4, sectorPath, wedgeRange, wheelCount, wheelRoll, wheelStrip, + 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. */ @@ -77,9 +79,13 @@ function windowOf(schedule, opts, what) { /** 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; for (const v of deckChoreography(schedule, render).visibility) { const [a, b] = v.at; - L.add(k, a, Math.max(INSTANT, b - a), { autoAlpha: v.hide ? 0 : 1 }, v.hide ? "power1.in" : "power2.out"); + // 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); + L.add(k, a, dur, { autoAlpha: v.hide ? 0 : 1 }, v.hide ? "power1.in" : "power2.out"); } } @@ -99,13 +105,16 @@ function blocks(L, list, key, { fade = INSTANT, shown = (x) => true } = {}) { }); } -const goalWords = (g) => { +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". - const what = Number.isFinite(g.value) - ? `GOAL ${fmtWeight(g.value)}${loss !== null && g.base ? ` · LOSE ${fmtWeight(loss)}` : ""}` - : loss !== null ? `GOAL: LOSE ${fmtWeight(loss)}` : "GOAL"; + // 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; }; @@ -120,7 +129,7 @@ const goalWords = (g) => { * 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, prefix = "" }) { +function dialParts({ size, ox, oy, scale, cfg, colors, fonts, track, prefix = "", preState = true }) { 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; @@ -132,17 +141,34 @@ function dialParts({ size, ox, oy, scale, cfg, colors, fonts, track, prefix = "" if (cfg.ghosts) { track.remembered.forEach((g, j) => { parts.push(layer(`g${j}`, `<line x1="${C}" y1="${C - Rf + 6 * u}" x2="${C}" y2="${C - Rf + 46 * u}" stroke="${colors.ghost}" stroke-width="${px(3.5)}" stroke-linecap="round"/>`)); + // 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(`<div class="ly" data-k="${prefix}gb${j}"><svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}"><path d="${sectorPath(C, C, Rf - 46 * u, Rf - 6 * u, b0, b1)}" fill="${colors.ghost}" fill-opacity="0.35" stroke="${colors.ghost}" stroke-width="${px(1.5)}"/></svg></div>`); + } }); } track.current.forEach((c, j) => { - const w = Number.isFinite(c.value) ? wedgeRange(c.value, c.qualifier) : null; + 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; - parts.push(layer(`q${j}`, `<path d="${sectorPath(C, C, Rf - 38 * u, Rf - 4 * u, a0, a1)}" fill="${colors.accent}" fill-opacity="0.5" stroke="${colors.accent}" stroke-width="${px(1.5)}"/>`)); + // 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}`, `<path d="${sectorPath(C, C, Rf - 48 * u, Rf - 2 * u, a0, a1)}" fill="${colors.accent}" fill-opacity="0.78" stroke="${colors.face}" stroke-width="${px(4)}"/>` + + `<path d="${sectorPath(C, C, Rf - 48 * u, Rf - 2 * u, a0, a1)}" fill="none" stroke="${colors.accent}" stroke-width="${px(2)}"/>`)); + const [lx, ly] = polar(C, C, Rf - 108 * u, (a0 + a1) / 2); + parts.push(`<div class="qlab" data-k="${prefix}ql${j}" style="left:${lx}px; top:${ly}px">${esc(weightWords(c))}</div>`); }); if (cfg.goal) { parts.push(layer("gl", `<polygon points="${C - 11 * u},${C - R - 2 * u} ${C + 11 * u},${C - R - 2 * u} ${C},${C - Rf + 16 * u}" fill="${colors.amber}" stroke="${colors.bg}" stroke-width="${px(2)}"/>`)); + // A goal he gave as a range: the tick spans it, an amber band on the bezel. + track.goals.forEach((g, j) => { + const r = g.goal?.range; + if (!Array.isArray(r)) return; + const b0 = dialAngle(r[0], scale), b1 = dialAngle(r[1], scale); + if (b1 > b0) parts.push(`<div class="ly" data-k="${prefix}gr${j}"><svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}"><path d="${sectorPath(C, C, Rf + 2 * u, R + 4 * u, b0, b1)}" fill="${colors.amber}" fill-opacity="0.9"/></svg></div>`); + }); } if (cfg.ghosts && track.remembered.length) { parts.push(layer("gn", `<line x1="${C}" y1="${C + 22 * u}" x2="${C}" y2="${C - Rf + 66 * u}" stroke="${colors.ghost}" stroke-width="${px(5)}" stroke-linecap="round"/>`)); @@ -159,7 +185,9 @@ function dialParts({ size, ox, oy, scale, cfg, colors, fonts, track, prefix = "" // Along its ghost, but never down into the readout's words under the hub. const [x, y0] = polar(C, C, Rf * 0.52, a); const y = Math.min(y0, Math.round((C + 30 * u) * 100) / 100); - parts.push(`<div class="asof" data-k="${prefix}ga${j}" style="left:${x}px; top:${y}px"><b>${esc(qualifierMark(g.qualifier))}${esc(fmtWeight(g.value))}</b><span>${g.asOf ? `AS OF ${esc(fmtDate(g.asOf))}` : "REMEMBERED"}</span></div>`); + // 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}×` : ""; + parts.push(`<div class="asof" data-k="${prefix}ga${j}" style="left:${x}px; top:${y}px"><b>${esc(weightWords(g))}</b><span>${g.asOf ? `AS OF ${esc(fmtDate(g.asOf))}` : "REMEMBERED"}${told}</span></div>`); }); } // The readout under the hub: the words, the weight, the weighing's date, the goal. @@ -167,7 +195,9 @@ function dialParts({ size, ox, oy, scale, cfg, colors, fonts, track, prefix = "" parts.push(`<div class="rlab" style="top:${C + 72 * u}px">${esc(cfg.label)}</div>`); track.current.forEach((c, j) => { const has = Number.isFinite(c.value); - parts.push(`<div class="read" data-k="${prefix}cv${j}" style="top:${C + 86 * u}px"><div class="big">${has ? `${esc(qualifierMark(c.qualifier))}${esc(fmtWeight(c.value))}<i>LB</i>` : "—"}</div>${has && c.date ? `<div class="when" style="top:${78 * u}px">${esc(fmtDate(c.date))}</div>` : ""}</div>`); + // 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(`<div class="read${pre ? " pre" : ""}" data-k="${prefix}cv${j}" style="top:${C + 86 * u}px"><div class="big">${has ? `${esc(weightWords(c))}<i>LB</i>` : pre ? "NO WEIGHT<br>STATED YET" : "—"}</div>${has && c.date ? `<div class="when" style="top:${78 * u}px">${esc(fmtDate(c.date))}</div>` : ""}</div>`); }); if (cfg.goal) { track.goals.forEach((g, j) => { @@ -192,6 +222,9 @@ function dialParts({ size, ox, oy, scale, cfg, colors, fonts, track, prefix = "" 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; }`; return { html: `<div class="dial">${parts.join("\n ")}</div>`, css, face }; @@ -206,16 +239,25 @@ function dialCues(L, { track, scale, cfg, prefix = "", finale = false }) { const a0 = DIAL_SWEEP.a0; const k = (s) => `${prefix}${s}`; // The finale drives its own needle (dialFinaleHtml). - if (!finale) L.set(k("nd"), { rotation: a0 }); + // 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) L.add(k("nd"), c.t, M.needle, { rotation: Number.isFinite(c.value) ? dialAngle(c.value, scale) : a0 }, needleEase(cfg)); - // The wedge once the needle is all but there, gone with its state. - const w = Number.isFinite(c.value) ? wedgeRange(c.value, c.qualifier) : null; + 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)) { - L.set(k(`q${j}`), { autoAlpha: 0 }); - L.add(k(`q${j}`), c.t + M.needle * 0.6, M.fade, { autoAlpha: 1 }, "power1.out"); - const next = track.current[j + 1]; - if (next) L.add(k(`q${j}`), next.t, M.fade * 0.6, { autoAlpha: 0 }, "power1.in"); + 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")); @@ -223,6 +265,10 @@ function dialCues(L, { track, scale, cfg, prefix = "", finale = false }) { 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 (track.remembered.length && finale) { // All at once: the long ghost and its words on the last (the finale puts his highest there). @@ -262,6 +308,15 @@ function dialCues(L, { track, scale, cfg, prefix = "", finale = false }) { } } blocks(L, track.goals, k("gw"), { shown: (g) => !!g.goal }); + // A range goal's band, up while it is the latest goal. + track.goals.forEach((g, j) => { + const r = g.goal?.range; + if (!Array.isArray(r) || !(dialAngle(r[1], scale) > dialAngle(r[0], scale))) return; + L.set(k(`gr${j}`), { autoAlpha: 0 }); + L.add(k(`gr${j}`), g.t, M.fade, { autoAlpha: 1 }, "power1.out"); + const next = track.goals[j + 1]; + if (next) L.add(k(`gr${j}`), next.t, M.fade, { autoAlpha: 0 }, "power1.in"); + }); } } @@ -465,9 +520,17 @@ export function trailHtml(schedule, render, opts = {}) { 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(`<div class="cnt" data-k="uc${c.n - 1}">UNDER ${mark} · SAID ${c.n}×</div>`)); 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 }); const { init, cues } = L.build(); const css = ` #rt { position: absolute; inset: 0; } + .ty { position: absolute; inset: 0; } .trail { position: absolute; inset: 0; border-radius: ${px(10)}px; background: ${colors.card}; } .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; } @@ -490,10 +553,18 @@ export function trailHtml(schedule, render, opts = {}) { id: "trail", W, H, fps, fonts, gsap: opts.gsap, data: { total: r4(schedule.total), window: windowOf(schedule, opts, "trail"), init, cues }, css, - body: `<div id="rt" data-k="rt"><div class="trail"><div class="lab">${esc(cfg.label)}</div>${parts.join("")}</div></div>`, + body: `<div id="rt" data-k="rt"><div class="ty" data-k="ty"><div class="trail"><div class="lab">${esc(cfg.label)}</div>${parts.join("")}</div></div></div>`, }); } +/** 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. // --------------------------------------------------------------------------- @@ -530,6 +601,7 @@ export function finaleNumbers(measure) { 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, goal: [...track.goals].reverse().find((g) => g.goal)?.goal ?? null, @@ -537,7 +609,7 @@ export function finaleNumbers(measure) { } /** 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 }); +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 @@ -549,10 +621,17 @@ export const FINALE_HANDOFF = Object.freeze({ net: 3.2, hold: 2.3, fade: 0.5 }); */ export function dialFinaleHandoff(schedule, render) { const fin = schedule?.finale; - if (!fin || resolveDial(render)?.finaleEnd !== "promise") return null; - // On the cue grid, so the promise clock's cue and the instruments' land on the same frame. - const at = cueTime(fin.from + FINALE_MOTION.grow + FINALE_HANDOFF.net + 0.5 + FINALE_HANDOFF.hold, schedule.fps ?? render.fps ?? 30); - return at + FINALE_HANDOFF.fade < fin.to ? at : null; + 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; } /** @@ -579,18 +658,18 @@ export function dialFinaleHtml(schedule, render, window, opts = {}) { 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; - // His highest remembered weight last, so the long ghost stands on it. + // 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 peakAt = rem.reduce((b, r, n) => (r.value > rem[b].value ? n : b), 0); const track = { ...full, - current: [{ t: from, value: null }, { t: A + 0.4, value: nums.weight, qualifier: nums.qualifier, date: null }], - remembered: rem.length ? [...rem.filter((_, n) => n !== peakAt), rem[peakAt]] : [], + current: [{ t: from, value: null }, { t: A + 0.4, value: nums.weight, qualifier: nums.qualifier, date: null, ...(nums.range ? { range: nums.range } : {}) }], + remembered: rem, goals: nums.goal ? [{ t: from, goal: null }, { t: A + 0.4, goal: nums.goal }] : [{ t: from, goal: null }], }; const size = even(Math.min(H, Math.round(W * 0.56))); const k = size / 524; - const dial = dialParts({ size, ox: 0, oy: Math.floor((H - size) / 2), scale: M.scale, cfg, colors, fonts, track, prefix: "f" }); + const dial = dialParts({ size, ox: 0, oy: Math.floor((H - size) / 2), scale: M.scale, cfg, colors, fonts, track, prefix: "f", preState: false }); const rw = W - size - Math.round(40 * k); const top = Math.max(Number(M.totals?.lost) || 0, nums.lost); const wheels = wheelCount(top); @@ -602,8 +681,10 @@ export function dialFinaleHtml(schedule, render, window, opts = {}) { 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", A, 0.4, { autoAlpha: 1 }, "power2.out"); + 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. diff --git a/umtool/report-to-video/chrome-measure-extras.mjs b/umtool/report-to-video/chrome-measure-extras.mjs @@ -15,10 +15,11 @@ import { rgba } from "./chrome-deck.mjs"; import { compileCues, cuePageHtml, esc, INSTANT, joinSpans, r4, spanEvents } from "./chrome-cues.mjs"; import { - daysBetween, daysLeftText, daysText, dietStates, goalStates, measureExtraGeometry, measureOf, MEASURE_BOXES, + daysBetween, daysLeftText, daysText, dietStates, goalStates, measureBox, measureExtraGeometry, measureOf, MEASURE_BOXES, promiseStripRect, MEASURE_DODGE_MOVE, measurePlacements, monthYear, peakStates, promiseStates, shortDate, streakStates, upSpans, weightText, } from "./measure-extras.mjs"; import { MEASURE_RED, resolveMeasureExtra } from "./modules/measure-extras-settings.mjs"; +import { dialFinaleGeometry, dialFinaleHandoff } from "./chrome-instruments.mjs"; /** How each module's panel comes in and goes out, s. */ export const MEASURE_FADE = Object.freeze({ in: 0.35, out: 0.4 }); @@ -28,7 +29,7 @@ const feedOf = (schedule) => schedule?.layout === "feed"; /** The page's frame: its region, its pixel scale against its design box, its fps. */ function frameOf(id, schedule, render) { const geo = measureExtraGeometry(id, render, { feed: feedOf(schedule) }); - const k = geo.width / MEASURE_BOXES[id].width; + const k = geo.width / measureBox(id, render).width; const px = (v) => Math.max(1, Math.round(v * k)); return { geo, k, px, fps: schedule.fps ?? render.fps ?? 30 }; } @@ -123,15 +124,49 @@ export function moverCues(place) { * A module's page: its box drawn in its region (its home, and every slot it * moves clear to), inside the mover `mv`. */ -const page = (id, schedule, opts, { fps }, css, body, init, cues, ids, render) => { - const place = measurePlacements(schedule, render)[id]; +/** + * Where the promise clock goes in the finale: the dial's finale hands its lower + * column to it (instruments.mjs `finaleEnd`, default "auto": when a promise is + * on camera) -- `{ at, rect, size }`, its box fitted into that column, or null + * (no dial finale, or no handoff). + */ +export function promiseFinaleSlot(schedule, render) { + if (!schedule?.finale || !resolveMeasureExtra("promise", render)) return null; + let at = null; + let geo = null; + try { + at = dialFinaleHandoff(schedule, render); + geo = at !== null ? dialFinaleGeometry(schedule, render) : null; + } catch { + return null; + } + if (at === null || !geo) return null; + const box = measureBox("promise", render); + const k0 = (render?.width ?? 1920) / 1920; + const size = Math.min(1.6, geo.width / (box.width * k0), geo.height / (box.height * k0)); + const home = measureExtraGeometry("promise", render); + const w = Math.round(home.width * size); + const h = Math.round(home.height * size); + return { at, size: r4(size), rect: { x: geo.x + Math.round((geo.width - w) / 2), y: geo.y + Math.round((geo.height - h) / 2), width: w, height: h } }; +} + +/** Every module's placement as its page and its region read it (the promise clock's finale slot included). */ +export const placementsFor = (schedule, render) => measurePlacements(schedule, render, { finaleSlot: promiseFinaleSlot(schedule, render) }); + +/** + * A module's page: its box drawn in its region (its home, and every slot it + * moves clear to), inside the mover `mv`; `outside` is drawn beside the mover + * (the promise clock's strip), its cues in `extra`. + */ +const page = (id, schedule, opts, { fps }, css, body, init, cues, ids, render, { outside = "", extra = null } = {}) => { + const place = placementsFor(schedule, render)[id]; const { home, region } = place; const mover = moverCues(place); return cuePageHtml({ id, W: region.width, H: region.height, fps, fonts: opts.fonts, gsapSrc: opts.gsap, css: `${displayFace(opts.fonts)}\n #mv { position: absolute; left: ${home.x - region.x}px; top: ${home.y - region.y}px; width: ${home.width}px; height: ${home.height}px; transform-origin: 0 0; }\n ${css}`, - body: `<div id="mv" data-k="mv">\n ${body}\n </div>`, - init: { ...init, ...mover.init }, cues: [...cues, ...mover.cues], + body: `<div id="mv" data-k="mv">\n ${body}\n </div>${outside}`, + init: { ...init, ...mover.init, ...(extra?.init ?? {}) }, cues: [...cues, ...mover.cues, ...(extra?.cues ?? [])], whole: { total: schedule.total, from: opts.from, duration: opts.duration, ids }, primeWindow: true, }); }; @@ -366,6 +401,39 @@ export function peakHtml(schedule, render, opts = {}) { /** A speaker's handle as the clock writes it: `promise.speakers[k].handle`, the manifest's postAvatars key, else the key. */ const handleOf = (speaker, cfg, opts) => String(cfg.speakers?.[speaker]?.handle ?? opts.handles?.[speaker] ?? speaker ?? "").replace(/^@/, ""); +/** + * The promise clock's STRIP (footage slot): while a post item is up, one line + * in the post box's top margin over the card -- "SCALE VIDEO OFFERED 23 OCT · + * PAID 23 OCT BY @MADAMSAVVY · 14 DAYS · NONE POSTED" -- each state's its own + * line `t<j>` (an item), shown with its state. Returns `{ html, cues, rect }`. + */ +function promiseStrip(states, place, cfg, render, opts, items) { + const rect = promiseStripRect(render); + const reg = place.region; + const ev = []; + const init = { ps: { autoAlpha: 0 } }; + for (const sp of place.strips) ev.push(...spanEvents("ps", sp.from, sp.to, { fadeIn: 0.3, fadeOut: 0.3 })); + const lines = states.map((st, j) => { + const k = `t${j}`; + init[k] = { autoAlpha: 0 }; + ev.push({ k, at: st.at, dur: INSTANT, to: { autoAlpha: 1 }, ease: "none" }); + if (states[j + 1]) ev.push({ k, at: states[j + 1].at, dur: INSTANT, to: { autoAlpha: 0 }, ease: "none" }); + const r = st.rows[0]; + const days = r.days === 0 ? "today" : `${r.days} day${r.days === 1 ? "" : "s"}`; + const claim = r.claim ? `<span class="sp">·</span><span>${esc(cfg.claimVerb)} ${esc(shortDate(r.claim.paidOn ?? r.claim.date))} by @${esc(handleOf(r.claim.speaker, cfg, opts))}</span>` : ""; + const o = r.outcome; + const status = o && o.kind !== "kept" + ? `<span class="no">${o.kind === "refunded" ? "refunded" : "withdrawn"} · no video</span>` + : r.kept ? `<span class="ok">${esc(cfg.kept)}</span>` : `<span class="no">${esc(cfg.broken)}</span>`; + const html = `<div class="sl" data-k="${k}"><span>${esc(r.what)} ${esc(cfg.verb)} ${esc(shortDate(r.said))}</span>${claim}<span class="sp">·</span><b>${esc(days)}</b><span class="sp">·</span>${status}</div>`; + items.push({ key: k, gate: [k, "autoAlpha"], html }); + return html; + }); + const compiled = compileCues(init, ev); + const html = `<div id="ps" data-k="ps" style="left:${rect.x - reg.x}px; top:${rect.y - reg.y}px; width:${rect.width}px; height:${rect.height}px">${lines.join("")}</div>`; + return { html, cues: compiled, rect }; +} + /** The promise clock's page: `{ html, items }`. `opts.avatars` = `{ <speaker>: "assets/…" }`, `opts.handles` = `{ <speaker>: handle }`. */ export function promiseHtml(schedule, render, opts = {}) { const cfg = resolveMeasureExtra("promise", render); @@ -381,6 +449,11 @@ export function promiseHtml(schedule, render, opts = {}) { const bottom = cfg.position.startsWith("bottom") && !(Number.isFinite(cfg.x) && Number.isFinite(cfg.y)); const spans = upSpans(states.map((s) => s.at), cfg, schedule); const items = []; + // In the instruments' column the compact form; in the footage box a strip over each post item's card. + const compact = cfg.slot === "column"; + const place = placementsFor(schedule, render).promise; + const sk = (render?.width ?? 1920) / 1920; + const strip = !compact && place.strips.length ? promiseStrip(states, place, cfg, render, opts, items) : null; const { init, cues } = stateCues(states, spans, { own: (st, j, init) => { const ev = []; @@ -439,6 +512,14 @@ export function promiseHtml(schedule, render, opts = {}) { const who = hers ? `<b class="who" style="color:${esc(ink)}">@${esc(handleOf(r.word.speaker, cfg, opts))}</b>${r.word.outcome ? " reads" : ""} ` : ""; q = `<div class="ck" data-k="${k}q"><div class="cf" data-k="${k}f" style="background:${rgba(ink, 0.5)}"></div>${who}<span class="qm" style="color:${esc(ink)}">“</span>${esc(r.word.text.replace(/^["“”]+|["“”]+$/g, ""))}<span class="qm" style="color:${esc(ink)}">”</span>${r.word.date ? ` <span class="cd">· ${esc(shortDate(r.word.date))}</span>` : ""}</div>`; } else q = `<div class="ck none">no word on it since</div>`; + if (compact) { + // The column's compact form (600×138): the promise and her claim on one line, the days and the status on + // the next, the latest words under them on one. + const cl = r.claim + ? ` · <span class="clc" data-k="${k}c">${esc(cfg.claimVerb)}${(r.claim.paidOn ?? r.claim.date) ? ` ${esc(shortDate(r.claim.paidOn ?? r.claim.date))}` : ""} by <b style="color:${esc(inkOf(r.claim.speaker))}">@${esc(handleOf(r.claim.speaker, cfg, opts))}</b></span>` + : ""; + return `<div class="row"><div class="hd">${esc(r.what)} · ${esc(cfg.verb)} ${esc(shortDate(r.said))}${cl}</div><div class="mid"><div class="dy" data-k="${k}d">${esc(days)}</div><div class="to">as of ${esc(shortDate(r.to))}</div>${status}</div>${q}</div>`; + } return `<div class="row"><div class="hd">${esc(r.what)} ${esc(cfg.verb)} ${esc(shortDate(r.said))}</div>${claim}<div class="mid"><div class="dy" data-k="${k}d">${esc(days)}</div><div class="to">as of<br>${esc(shortDate(r.to))}</div>${status}</div>${q}</div>`; }).join(""); const r0 = st.rows[0]; @@ -447,6 +528,19 @@ export function promiseHtml(schedule, render, opts = {}) { items.push({ key: `s${j}`, gate: [`s${j}`, "autoAlpha"], html }); return html; }); + const compactCss = !compact ? "" : ` + .st { top: 0; bottom: 0; padding: ${px(10)}px ${px(16)}px ${px(8)}px ${px(16)}px; border-left-width: ${px(5)}px; } + .row { gap: ${px(2)}px; } + .hd { font-size: ${px(16)}px; line-height: ${px(20)}px; letter-spacing: 0.08em; } + .hd b { letter-spacing: 0.02em; text-transform: none; } + .mid { height: ${px(54)}px; gap: ${px(12)}px; } + .dy { font-size: ${px(50)}px; line-height: ${px(54)}px; } + .to { flex: 1 1 auto; align-self: center; padding-bottom: 0; font-size: ${px(14)}px; } + .pill { height: ${px(32)}px; line-height: ${px(32)}px; font-size: ${px(17)}px; padding: 0 ${px(12)}px; } + .stamp { padding: ${px(1)}px ${px(10)}px ${px(2)}px; border-width: ${px(3)}px; transform: rotate(-3deg); } + .sw { font-size: ${px(24)}px; line-height: ${px(26)}px; } + .ss { font-size: ${px(12)}px; line-height: ${px(14)}px; } + .ck { font-size: ${px(16)}px; line-height: ${px(21)}px; -webkit-line-clamp: 1; display: block; white-space: nowrap; text-overflow: ellipsis; }`; const css = ` #pn { position: absolute; inset: 0; visibility: hidden; opacity: 0; } /* The card is as tall as what it says, hung from its anchor's edge. */ @@ -484,11 +578,19 @@ export function promiseHtml(schedule, render, opts = {}) { .ck { isolation: isolate; } .who { font-family: 'DeckSansBold', sans-serif; } .qm { font-family: 'DeckSansBold', sans-serif; } - .cd { color: ${pal.muted}; white-space: nowrap; }`; + .cd { color: ${pal.muted}; white-space: nowrap; }${compactCss} + #ps { position: absolute; visibility: hidden; opacity: 0; } + .sl { position: absolute; inset: 0; visibility: hidden; opacity: 0; display: flex; align-items: center; justify-content: center; + gap: ${Math.round(sk * 10)}px; white-space: nowrap; overflow: hidden; font-family: 'DeckSansBold', sans-serif; + font-size: ${Math.round(strip ? strip.rect.height * 0.62 : 12)}px; letter-spacing: 0.08em; text-transform: uppercase; color: ${pal.muted}; } + .sl b { color: ${pal.fg}; font-family: ${DISPLAY}; font-weight: 400; letter-spacing: 0.04em; } + .sl .no { color: ${red}; } + .sl .ok { color: ${green}; } + .sl .sp { color: ${pal.muted}; opacity: 0.6; }`; const body = `<div id="pn" data-k="pn"> ${blocks.join("\n ")} </div>`; - return { html: page("promise", schedule, opts, F, css, body, init, cues, states.map((_, j) => `s${j}`), render), items }; + return { html: page("promise", schedule, opts, F, css, body, init, cues, states.map((_, j) => `s${j}`), render, strip ? { outside: strip.html, extra: strip.cues } : {}), items }; } // --------------------------------------------------------------------------- diff --git a/umtool/report-to-video/deck-claims.test.mjs b/umtool/report-to-video/deck-claims.test.mjs @@ -339,7 +339,9 @@ const BEFORE = { // eases and durations, every time within 4 ms. (Was 4966f5f6904d7c91e8c3bd64b16763b8.) deck: "d56d6f45c667dea15c0fec5675dbcc95", // Likewise the finale's (its 181 cues on the Huck cut: times within 2 ms, - // its window's start on the grid). Was e4cb165d4e3b816c0d648240cac91eb1. - finale: "afc1b75858e0c19a73e3d9549bc1f474", + // its window's start on the grid). Was e4cb165d4e3b816c0d648240cac91eb1; then afc1b758… until rev 9 (6 Nov) + // wrapped the clip card's source line to two lines with the title last (chrome-finale.mjs titleLast): the + // page's css and that line, nothing else. + finale: "ff1dd61a2a1de8a38b1fbf12a420b71d", built: "c6a44e98fce846811cbf87d449e6b40d", }; diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs @@ -1851,7 +1851,9 @@ function finaleRailAt(schedule, render, railBottom, textScale) { // The pips across the rail, then their labels -- and when the labels turn, // the track starts far enough in that the first one reads whole. - const info = pipped.map((s) => ({ label: s.title || fin.dates?.[s.id] || "", date: fin.dates?.[s.id] ?? "" })); + // `sections` / `none`: no pip carries words (the section markers' labels alone, or nothing at all). + const pipWords = f.railLabels === "all" || f.railLabels === "nodes"; + const info = pipped.map((s) => (pipWords ? { label: s.title || fin.dates?.[s.id] || "", date: fin.dates?.[s.id] ?? "" } : { label: "", date: "" })); const dates = f.railLabels === "all"; const labelsAt = (xs, geo) => railLabelLayout(xs.map((x, k) => ({ x, ...info[k] })), geo, { dates }); let x0 = rail.x0; @@ -1890,7 +1892,7 @@ function finaleRailAt(schedule, render, railBottom, textScale) { ? { ...finaleClaims(fcl, { toBig, bigX: (k) => r2(xs[k]), size: rail.markerSize, ringSize: bigSize + 14, pips, marks, - markerLabels: f.railLabels === "all", W: base.W, margin: base.margin, mode: slots.mode, + markerLabels: f.railLabels === "all" || f.railLabels === "sections", W: base.W, margin: base.margin, mode: slots.mode, }), slots: slots.slots, } diff --git a/umtool/report-to-video/finale.mjs b/umtool/report-to-video/finale.mjs @@ -8,8 +8,9 @@ // "totals": true, the tally's final counts, large // "stats": [{ "label", "value", "note"?, "color"? }], up to 8, the author's words // "statsTitle": "…", over the stats (optional) -// "railLabels": "all" | "nodes" every label and date and the markers' labels, -// or each pip's label alone (default "all") +// "railLabels": "all" | "nodes" | "sections" | "none" every label and date and the markers' labels, +// each pip's label alone, the section markers' labels +// alone, or no words (default "all") // "timelineShare": "auto" | 0.38–0.6 how much of the frame's height the timeline takes: // "auto" (the default) the height its rows need, from // the share it always had up to FINALE_SHARE.auto; @@ -47,7 +48,9 @@ export const FINALE_VIDEOS = Object.freeze(["side", "corner", "hidden"]); export const FINALE_MOTIONS = Object.freeze(["grow", "cut"]); /** What the large rail labels: everything (labels, dates, markers) or the pips' labels only. */ -export const FINALE_RAIL_LABELS = Object.freeze(["all", "nodes"]); +// "sections": the section markers' labels alone (no pip's label or date); "none": no words on the rail at all +// (rev 9, 6 Nov: the promise clock over the finale met the turned dates at the rail's left). +export const FINALE_RAIL_LABELS = Object.freeze(["all", "nodes", "sections", "none"]); /** How the claim checks stand on the large rail: one at a time in turn, or all at once. */ export const FINALE_CLAIM_MODES = Object.freeze(["rotate", "all"]); diff --git a/umtool/report-to-video/finale.test.mjs b/umtool/report-to-video/finale.test.mjs @@ -58,7 +58,7 @@ test("deck.finale: every key validated, unknown keys refused, the defaults", () for (const want of [ 'render.chrome.deck.finale.video must be "side", "corner", "hidden"', 'render.chrome.deck.finale.motion must be "grow", "cut"', - 'render.chrome.deck.finale.railLabels must be "all", "nodes"', + 'render.chrome.deck.finale.railLabels must be "all", "nodes", "sections", "none"', "render.chrome.deck.finale.totals must be true or false", "render.chrome.deck.finale.statsTitle is 41 characters (at most 40)", "render.chrome.deck.finale.stats[0].label must not be empty", diff --git a/umtool/report-to-video/instruments.mjs b/umtool/report-to-video/instruments.mjs @@ -13,8 +13,9 @@ // up to the playhead, the 300 lb line, a count // of the times he says he is under it // -// Each is `true` (its defaults), an object of its settings, or absent/false -// (off). With any of them on the frame changes: the footage box moves to the +// Each is `true` (its defaults), an object of its settings, or `false` (off); +// absent, it is ON when the cut draws a measure (`deck.measure` set) and off +// when it does not. With any of them on the frame changes: the footage box moves to the // left edge and the column takes the right (deck.mjs deckGeometry, // instrumentsGeometry); the posts stay in the footage box (`posts.shift` does // not apply) and the side panel (threads, flips) and the feed are refused. @@ -59,13 +60,15 @@ export const DIAL_DEFAULTS = Object.freeze({ // "promise" -- the instruments hand off to the promise clock (module `promise`): // they fade out at the handoff (dialFinaleHandoff) and the clock takes the column. // With no promise module on the cut it ends as "odometer". - finaleEnd: "odometer", + // "auto" (the default): "promise" when a promise is on camera, else "odometer" -- + // the contract's finale: the dial drops, the odometer rolls, NET holds, THEN the promise clock. + finaleEnd: "auto", }); export const DIAL_PLACEMENTS = Object.freeze(["column", "corner"]); export const DIAL_CORNERS = Object.freeze(["bottom-right", "bottom-left", "top-right", "top-left"]); export const DIAL_MOTIONS = Object.freeze(["spring", "ease"]); -export const DIAL_FINALE_ENDS = Object.freeze(["odometer", "promise"]); +export const DIAL_FINALE_ENDS = Object.freeze(["auto", "odometer", "promise"]); /** A corner dial's size bounds, px at 1920 wide. */ export const DIAL_SIZE = Object.freeze([200, 540]); @@ -92,16 +95,25 @@ const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v); const HEX_RE = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/; const numIn = (v, lo, hi) => typeof v === "number" && Number.isFinite(v) && v >= lo && v <= hi; -/** An instrument's settings, its defaults filled, or null when it is off. */ -function resolveOne(v, defaults) { - if (v === true) return { ...defaults }; +/** + * Does the cut draw a measure (`render.chrome.deck.measure` set -- the build + * writes the measure slice only then)? With one, every instrument is ON unless + * it says otherwise -- as the measure extras are (rev 9, 6 Nov: the contract's + * "on by default"); without one, an instrument is on only when it is named. + */ +export const measureAsked = (render) => isObj(render?.chrome?.deck?.measure); + +/** An instrument's settings, its defaults filled, or null when it is off (`false`; absent without a measure). */ +function resolveOne(v, defaults, render) { + if (v === false) return null; + if (v === true || (v === undefined && measureAsked(render))) return { ...defaults }; if (!isObj(v)) return null; return { ...defaults, ...v }; } -export const resolveDial = (render) => resolveOne(render?.chrome?.deck?.dial, DIAL_DEFAULTS); -export const resolveOdometer = (render) => resolveOne(render?.chrome?.deck?.odometer, ODOMETER_DEFAULTS); -export const resolveTrail = (render) => resolveOne(render?.chrome?.deck?.trail, TRAIL_DEFAULTS); +export const resolveDial = (render) => resolveOne(render?.chrome?.deck?.dial, DIAL_DEFAULTS, render); +export const resolveOdometer = (render) => resolveOne(render?.chrome?.deck?.odometer, ODOMETER_DEFAULTS, render); +export const resolveTrail = (render) => resolveOne(render?.chrome?.deck?.trail, TRAIL_DEFAULTS, render); /** Which instruments the render block asks for, in the column's order (top first). */ export function instrumentsWanted(render) { diff --git a/umtool/report-to-video/instruments.test.mjs b/umtool/report-to-video/instruments.test.mjs @@ -107,12 +107,12 @@ test("the instruments' settings: true, an object of known keys, or off; the side const side = validateChrome({ ...chromeWith({ trail: true }), threads: { list: [{ id: "a", label: "A" }] } }, {}); assert.ok(side.some((e) => /render\.chrome\.threads and render\.chrome\.deck\.trail both need the frame/.test(e)), side.join("\n")); assert.deepEqual(resolveDial(RENDER), { - mark: 300, ghosts: true, goal: true, needle: "#ff5a4e", finale: true, label: "HE SAYS HE WEIGHS", placement: "column", size: 340, corner: "bottom-right", motion: "spring", finaleEnd: "odometer", + mark: 300, ghosts: true, goal: true, needle: "#ff5a4e", finale: true, label: "HE SAYS HE WEIGHS", placement: "column", size: 340, corner: "bottom-right", motion: "spring", finaleEnd: "auto", }); assert.match(validateDial({ placement: "left" })[0], /placement must be "column" or "corner"/); assert.match(validateDial({ size: 100 })[0], /size must be a whole number of pixels from 200 to 540/); assert.match(validateDial({ motion: "bounce" })[0], /motion must be "spring" or "ease"/); - assert.match(validateDial({ finaleEnd: "net" })[0], /finaleEnd must be "odometer" or "promise"/); + assert.match(validateDial({ finaleEnd: "net" })[0], /finaleEnd must be "auto" or "odometer" or "promise"/); assert.equal(resolveDial({ chrome: chromeWith({ dial: false }) }), null); assert.deepEqual(moduleProblems({ render: { ...RENDER, chrome: chromeWith({ dial: { ghost: true } }) } }).dial, ["render.chrome.deck.dial.ghost is not a setting of it (mark, ghosts, goal, needle, finale, label, placement, size, corner, motion, finaleEnd)"]); }); diff --git a/umtool/report-to-video/measure-draw.mjs b/umtool/report-to-video/measure-draw.mjs @@ -107,6 +107,11 @@ export function fmtSigned(v) { /** The qualifier as the dial prints it before the digits. */ export const qualifierMark = (q) => (q === "≈" ? "≈" : q === ">" ? ">" : q === "<" ? "<" : ""); +/** A weight as the dial writes it: a range "330–340" (never its middle alone), else its qualifier and number. */ +export const weightWords = (x) => (Array.isArray(x?.range) && x.range.length === 2 + ? `${fmtWeight(x.range[0])}–${fmtWeight(x.range[1])}` + : `${qualifierMark(x?.qualifier)}${fmtWeight(x?.value)}`); + /** A day number for an ISO date (for spacing by date). */ export const dayNumber = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso ?? "")); @@ -162,13 +167,17 @@ export function measureTrack(measure) { if (!i || !sameCurrent(prev.current, s.current)) { const c = s.current ?? null; const ev = c ? byRow.get(c.row) : null; - current.push({ t, value: c?.value ?? null, qualifier: c?.qualifier ?? null, row: c?.row ?? null, date: ev?.asOf ?? c?.date ?? null }); + const range = Array.isArray(c?.range) ? c.range : Array.isArray(ev?.range) ? ev.range : null; + current.push({ t, value: c?.value ?? null, qualifier: c?.qualifier ?? null, row: c?.row ?? null, date: ev?.asOf ?? c?.date ?? null, ...(range ? { range } : {}) }); } const rem = Array.isArray(s.remembered) ? s.remembered : []; const had = prev && Array.isArray(prev.remembered) ? prev.remembered.length : 0; for (let j = had; j < rem.length; j += 1) { const ev = byRow.get(rem[j].row); - remembered.push({ t, value: rem[j].value, asOf: rem[j].asOf ?? null, row: rem[j].row, qualifier: ev?.qualifier ?? null }); + const range = Array.isArray(rem[j].range) ? rem[j].range : Array.isArray(ev?.range) ? ev.range : null; + // How many times he has told this start so far (the moving start's count, on the dial's ghost: "told 5×"). + const told = remembered.filter((r) => Math.abs(r.value - rem[j].value) < 0.05).length + 1; + remembered.push({ t, value: rem[j].value, asOf: rem[j].asOf ?? null, row: rem[j].row, qualifier: ev?.qualifier ?? rem[j].qualifier ?? null, told, ...(range ? { range } : {}) }); } if (!i || !sameGoal(prev.goal, s.goal)) goals.push({ t, goal: s.goal ?? null }); const total = Number(s.lost?.total) || 0; @@ -214,8 +223,12 @@ export function sectorPath(cx, cy, r0, r1, a0, a1) { return `M${p} A${r1},${r1} 0 ${lg} 1 ${q} L${s} A${r0},${r0} 0 ${lg} 0 ${t}Z`; } -/** A qualifier's wedge, in pounds: "≈" 3 under to 1 over, ">" 10 up, "<" 10 down. */ -export function wedgeRange(value, q) { +/** + * A weight's wedge, in pounds: a RANGE he gave, the range itself ("330-340"); + * else a qualifier's -- "≈" 3 under to 1 over, ">" 10 up, "<" 10 down. + */ +export function wedgeRange(value, q, range = null) { + if (Array.isArray(range) && range.length === 2 && range[1] > range[0]) return [range[0], range[1]]; if (q === "≈") return [value - 3, value + 1]; if (q === ">") return [value, value + 10]; if (q === "<") return [value - 10, value]; diff --git a/umtool/report-to-video/measure-extras.mjs b/umtool/report-to-video/measure-extras.mjs @@ -25,7 +25,7 @@ // - DIET: the state's diet, re-stamped at each change of regime or diet // number; a null diet after one is "NO DIET" (the producer has applied the // off-scope rule: this only draws state.diet). -import { deckGeometry, feedGeometry } from "./deck.mjs"; +import { deckGeometry, feedGeometry, instrumentsGeometry } from "./deck.mjs"; import { chapterCover, chapterWindows } from "./chrome-story.mjs"; import { MEASURE_EXTRAS, MEASURE_POSITIONS, resolveMeasureExtra } from "./modules/measure-extras-settings.mjs"; @@ -664,8 +664,39 @@ export const MEASURE_BOXES = Object.freeze({ promise: Object.freeze({ width: 640, height: 260 }), diet: Object.freeze({ width: 440, height: 200 }), streak: Object.freeze({ width: 620, height: 150 }), + // The promise clock in the instruments' column (`promise.slot`): the trail's slot, its compact form. + promiseColumn: Object.freeze({ width: 600, height: 138 }), }); +/** A module's design box: the promise clock's compact one in the column. */ +export function measureBox(id, render) { + if (id === "promise" && resolveMeasureExtra("promise", render)?.slot === "column") return MEASURE_BOXES.promiseColumn; + return MEASURE_BOXES[id]; +} + +/** + * The promise clock's slot in the instruments' column: the trail's (it yields + * while the clock is up), else the column's foot as tall as the trail would be. + */ +export function promiseColumnRect(render) { + const g = instrumentsGeometry(render); + if (g.trail) return { ...g.trail }; + const k = (render?.width ?? 1920) / 1920; + const h = Math.round(138 * k); + return { x: g.column.x, y: g.column.y + g.column.height - h, width: g.column.width, height: h }; +} + +/** + * The strip a promise clock in the FOOTAGE box draws while a post item is up: + * one line in the post box's top margin, over the card (the post's pad, as + * postLayout lays it: 36 design px of the box's height). + */ +export function promiseStripRect(render, { feed = false } = {}) { + const f = feed ? feedGeometry(render).footage : deckGeometry(render).footage; + const pad = Math.round(36 * (f.height / 1080)); + return { x: f.x + pad, y: f.y + 2, width: f.width - 2 * pad, height: Math.max(18, pad - 4) }; +} + /** * A module's region in the frame: its box (MEASURE_BOXES × `scale`, scaled * with the frame) at its anchor in the footage box (the feed's for a feed @@ -676,6 +707,7 @@ export const MEASURE_BOXES = Object.freeze({ */ export function measureExtraGeometry(id, render, { feed = false } = {}) { const cfg = resolveMeasureExtra(id, render) ?? resolveMeasureExtra(id, { chrome: { deck: {} } }); + if (id === "promise" && cfg.slot === "column") return promiseColumnRect(render); const g = deckGeometry(render); const f = feed ? feedGeometry(render).footage : g.footage; const k = (g.W / 1920) * (cfg.scale ?? 1); @@ -786,7 +818,7 @@ export function measureCovers(schedule, render) { * (`rect` null), `region` the box its frames are drawn in (home and every * slot it moves to). A module with nothing to move clear of: its home alone. */ -export function measurePlacements(schedule, render) { +export function measurePlacements(schedule, render, { finaleSlot = null } = {}) { const feed = schedule?.layout === "feed"; const covers = schedule ? measureCovers(schedule, render) : []; const out = {}; @@ -794,6 +826,21 @@ export function measurePlacements(schedule, render) { const home = measureExtraGeometry(id, render, { feed }); out[id] = { home, region: home, moves: [], up: covers.length && schedule && resolveMeasureExtra(id, render) ? upOf(id, schedule, render) : [] }; } + // THE PROMISE CLOCK stays on screen through the post items (rev 9, 6 Nov): in + // the instruments' column it stands in the trail's slot and nothing in the + // footage moves it; in the footage box, while a post item is up, it gives way + // to a one-line strip in the post's top margin (`strips`, promiseStripRect). + const pcfg = resolveMeasureExtra("promise", render); + const inColumn = pcfg?.slot === "column"; + out.promise.strips = []; + if (pcfg && !inColumn && schedule) { + const up = out.promise.up.length ? out.promise.up : upOf("promise", schedule, render); + for (const c of covers) { + if (c.kind !== "post" || pcfg.onPosts === "show" || !overlapsSpan(up, c.from, c.to)) continue; + out.promise.moves.push({ from: c.from, to: c.to, rect: null, size: 1 }); + if (pcfg.onPosts === "dodge") out.promise.strips.push({ from: c.from, to: c.to }); + } + } // Two extras whose homes overlap (the clip box is smaller beside the // instruments' column) while both are up: the later in DODGE_ORDER moves // clear of the earlier, as of a cover of its own. @@ -802,6 +849,7 @@ export function measurePlacements(schedule, render) { DODGE_ORDER.forEach((a, i) => { for (const b of DODGE_ORDER.slice(i + 1)) { if (!resolveMeasureExtra(a, render) || !resolveMeasureExtra(b, render) || !intersects(out[a].home, out[b].home)) continue; + if ((a === "promise" || b === "promise") && inColumn) continue; for (const sa of out[a].up) for (const sb of out[b].up) { const from = Math.max(sa.in, sb.in); const to = Math.min(sa.out, sb.out); @@ -813,7 +861,10 @@ export function measurePlacements(schedule, render) { } for (const c of covers) { const hit = (r) => c.rects.some((b) => intersects(r, b)); - const active = DODGE_ORDER.filter((id) => resolveMeasureExtra(id, render) && overlapsSpan(out[id].up, c.from, c.to) && (!c.only || c.only === id)); + // (The promise clock is not moved by a post card here: in the column nothing in the footage meets it, and in + // the footage box it becomes the strip above.) + const skip = (id) => id === "promise" && (inColumn || c.kind === "post"); + const active = DODGE_ORDER.filter((id) => !skip(id) && resolveMeasureExtra(id, render) && overlapsSpan(out[id].up, c.from, c.to) && (!c.only || c.only === id)); // The modules that stay where they are take their homes first. const taken = []; const toMove = []; @@ -825,7 +876,7 @@ export function measurePlacements(schedule, render) { } // Every other extra up in the span keeps its place: no slot onto it. for (const id of DODGE_ORDER) { - if (active.includes(id) || !resolveMeasureExtra(id, render) || !overlapsSpan(out[id].up, c.from, c.to)) continue; + if (active.includes(id) || (id === "promise" && inColumn) || !resolveMeasureExtra(id, render) || !overlapsSpan(out[id].up, c.from, c.to)) continue; taken.push(out[id].home); } const footage = feed ? feedGeometry(render).footage : deckGeometry(render).footage; @@ -833,7 +884,9 @@ export function measurePlacements(schedule, render) { let move = null; if (mode === "dodge") { const pinned = Number.isFinite(cfg.x) && Number.isFinite(cfg.y); - const anchors = anchorsFor(pinned ? "top-left" : cfg.position); + // Never into an anchor the module avoids (`avoid`, default the top-left: the streams' face cam). + const avoid = Array.isArray(cfg.avoid) ? cfg.avoid : []; + const anchors = anchorsFor(pinned ? "top-left" : cfg.position).filter((a) => !avoid.includes(a) || a === cfg.position); search: for (const size of MEASURE_DODGE_SCALES) { for (const a of anchors) { const r = anchorRect(id, render, a, size, { feed }); @@ -848,6 +901,16 @@ export function measurePlacements(schedule, render) { out[id].moves.push(move); } } + // THE FINALE: the promise clock waits out the dial's finale and takes its place at the handoff + // (`finaleSlot`: chrome-measure-extras.mjs promiseFinaleSlot -- the finale's lower column, clear of the rail); + // in the column with no such slot it is hidden over the finale (the column is under the finale's page). + const fin = schedule?.finale && Number.isFinite(schedule.finale.from) ? schedule.finale : null; + if (pcfg && fin) { + if (finaleSlot) { + out.promise.moves.push({ from: fin.from, to: finaleSlot.at, rect: null, size: 1 }); + out.promise.moves.push({ from: finaleSlot.at, to: Number(schedule.total) || fin.to, rect: finaleSlot.rect, size: finaleSlot.size }); + } else if (inColumn) out.promise.moves.push({ from: fin.from, to: Number(schedule.total) || fin.to, rect: null, size: 1 }); + } for (const id of MEASURE_EXTRAS) { const p = out[id]; // Two moves that meet, to the same place: one. @@ -859,7 +922,7 @@ export function measurePlacements(schedule, render) { else merged.push({ ...m }); } p.moves = merged; - const rects = [p.home, ...merged.map((m) => m.rect).filter(Boolean)]; + const rects = [p.home, ...merged.map((m) => m.rect).filter(Boolean), ...(p.strips?.length ? [promiseStripRect(render, { feed })] : [])]; const x0 = Math.min(...rects.map((r) => r.x)); const y0 = Math.min(...rects.map((r) => r.y)); const x1 = Math.max(...rects.map((r) => r.x + r.width)); diff --git a/umtool/report-to-video/measure-extras.test.mjs b/umtool/report-to-video/measure-extras.test.mjs @@ -347,8 +347,16 @@ test("measurePlacements: over a post card a module moves to a free slot (a size const chap = withDeck({}); chap.chrome = { ...chap.chrome, chapter: { style: "lower", seconds: 3, list: [{ at: "a", title: "Part one" }] } }; const cp = measurePlacements(schedule(MEASURE, { segments: [{ id: "a", start: 700, duration: 40, end: 740 }] }), chap); - const band = cp.diet.moves.find((m) => m.from === 700); + const band = cp.goals.moves.find((m) => m.from === 700); assert.ok(band?.rect && band.rect.y + band.rect.height <= f.y + f.height - Math.round(220), JSON.stringify(band)); + // Never into the top-left (the face cam) by default: the diet badge, with every other slot taken, hides. + const d2 = cp.diet.moves.find((m) => m.from === 700); + assert.ok(!d2.rect || d2.rect.x > f.x + f.width / 3, JSON.stringify(d2)); + // `avoid: []` lets it go there. + const free2 = withDeck({ diet: { avoid: [] } }); + free2.chrome = { ...free2.chrome, chapter: chap.chrome.chapter }; + const d3 = measurePlacements(schedule(MEASURE, { segments: [{ id: "a", start: 700, duration: 40, end: 740 }] }), free2).diet.moves.find((m) => m.from === 700); + assert.deepEqual([d3.rect?.x, d3.rect?.y], [f.x + 24, f.y + 24], "top-left when allowed"); // Nothing to move clear of: home alone. assert.deepEqual(measurePlacements(schedule(), RENDER).diet.region, measureExtraGeometry("diet", RENDER)); }); @@ -366,17 +374,32 @@ test("moverSteps: overlapping moves (two post items crossfading, a band inside a assert.deepEqual(cues.find((c) => c.to.x === 10).to, { x: 10, y: 10, scale: 0.6 }); }); -test("measurePlacements beside the instruments' column (the clip box 1248×702): extras whose homes overlap move clear of each other while both are up", () => { +test("beside the instruments' column (the clip box 1248×702): the extras' own anchors keep them apart; the peak is off (the dial's ghosts carry it)", async () => { const r = withDeck({ dial: true }); - const p = measurePlacements(schedule(), r); const homes = Object.fromEntries(IDS.map((id) => [id, measureExtraGeometry(id, r)])); const box = { x: 24, y: 94, width: 1248, height: 702 }; - for (const id of IDS) assert.ok(homes[id].x >= box.x && homes[id].x + homes[id].width <= box.x + box.width, `${id} inside the clip box`); - // diet and streak overlap at home: the streak (later in the order) moves, the diet stays. + const hit = (a, b) => a.x < b.x + b.width && b.x < a.x + a.width && a.y < b.y + b.height && b.y < a.y + a.height; + for (const id of IDS.filter((x) => x !== "promise")) assert.ok(homes[id].x >= box.x && homes[id].x + homes[id].width <= box.x + box.width, `${id} inside the clip box`); + // The promise clock stands in the trail's slot of the column. + const { instrumentsGeometry } = await import("./deck.mjs"); + assert.deepEqual(measureExtraGeometry("promise", withDeck({ dial: true, trail: true })), instrumentsGeometry(withDeck({ dial: true, trail: true })).trail); + // With no trail: the column's foot, as tall as the trail would be. + assert.deepEqual(homes.promise, { x: 1296, y: 728, width: 600, height: 138 }); + assert.equal(hit(homes.diet, homes.streak), false, "the diet badge never on the streak strip"); + assert.equal(hit(homes.diet, homes.goals), false); + assert.equal(hit(homes.streak, homes.goals), false); + assert.equal(resolveMeasureExtra("diet", r).position, "bottom-left"); + assert.equal(resolveMeasureExtra("diet", r).scale, 0.7); + for (const id of ["diet", "streak", "goals"]) assert.ok(homes[id].y > box.y + box.height / 3, `${id} along the foot, the top (the face cam) clear`); + assert.equal(resolveMeasureExtra("peak", r), null, "the moving start is off with the dial on"); + assert.equal(resolveMeasureExtra("peak", withDeck({ dial: true, peak: true })).position, "top-center", "named, it is on"); + assert.equal(resolveMeasureExtra("diet", withDeck({ dial: true, diet: { position: "bottom-left" } })).position, "bottom-left", "a named anchor wins"); + assert.equal(resolveMeasureExtra("promise", r).slot, "column"); + assert.equal(resolveMeasureExtra("promise", RENDER).slot, "footage"); + // Extras whose homes still overlap (named onto one another) move clear while both are up. + const both = withDeck({ dial: true, diet: { position: "bottom-left" }, streak: { position: "bottom-left" } }); + const p = measurePlacements(schedule(), both); assert.equal(p.diet.moves.length, 0); assert.ok(p.streak.moves.length > 0); - for (const m of p.streak.moves.filter((x) => x.rect)) { - assert.ok(!(m.rect.x < homes.diet.x + homes.diet.width && homes.diet.x < m.rect.x + m.rect.width && m.rect.y < homes.diet.y + homes.diet.height && homes.diet.y < m.rect.y + m.rect.height), "never onto the diet badge"); - assert.ok(m.rect.x >= box.x && m.rect.x + m.rect.width <= box.x + box.width, "inside the clip box"); - } }); + diff --git a/umtool/report-to-video/measure-slice.mjs b/umtool/report-to-video/measure-slice.mjs @@ -201,12 +201,28 @@ const rowSource = (row) => (/(^|\/\/)(x|twitter)\.com\//.test(String(row?.citeUr /** An entry's source kind: a clip, a post, or a card (anything else). */ const entrySource = (entry) => (entry?.type === "clip" ? "clip" : entry?.type === "post" ? "post" : "card"); +/** + * A RANGE he gave ("330-340 lb", "220–240"): `[lo, hi]` read off the row's + * display, or null. The row's `value` is the range's middle (what a single + * number is drawn at); the range is what he said, and the instruments draw it + * as a range -- a wedge, "330–340" -- never the middle alone. + */ +export function rangeOf(row) { + const m = /(\d+(?:\.\d+)?)\s*[-–]\s*(\d+(?:\.\d+)?)/.exec(String(row?.display ?? "")); + if (!m) return null; + const lo = Number(m[1]); + const hi = Number(m[2]); + return Number.isFinite(lo) && Number.isFinite(hi) && hi > lo ? [lo, hi] : null; +} + function eventOf(row, schema, runOf) { const s = measureSchema(schema); const kind = kindOf(row, s); const role = s.tracks.find((t) => t.key === row.scope)?.role ?? null; const n = Number(row.value); + const range = role === "regime" ? null : rangeOf(row); return { + ...(range ? { range } : {}), row: row.id, scope: row.scope, date: row.date ?? null, @@ -449,6 +465,11 @@ export function measureSlice(manifest, schedule, opts = {}) { if (after && Math.round(daysBetween(d, after.date)) <= s.bandGapDays) return runById.get(after.run) ?? null; return null; }; + // A loss goal's base (rev 9, 6 Nov): the run's start when the record names one; + // else the latest weight he gave by the goal's date -- stated or remembered, + // by the day it was his weight (a remembered one's asOf); else none. A target + // below the scale's foot is no target (a stale base: "lose 100" from 240 is + // not 140 lb): his words stay the goal -- "LOSE 100", no weight, no tick. const goalBase = (row) => { const d = row.date; const run = runAt(d); @@ -458,14 +479,22 @@ export function measureSlice(manifest, schedule, opts = {}) { const last = starts[starts.length - 1]; if (last) return { value: Number(last.value), row: last.id, from: "runStart" }; } - const stated = readings.filter((r) => r.population === "current" && dateKey(r.date) <= dateKey(d)); - const last = stated[stated.length - 1]; - return last ? { value: Number(last.value), row: last.id, from: "stated" } : null; + const known = readings + .filter((r) => dateKey(r.date) <= dateKey(d)) + .sort((a, b) => dateKey(plotDate(a)).localeCompare(dateKey(plotDate(b))) || dateKey(a.date).localeCompare(dateKey(b.date))); + const last = known[known.length - 1]; + return last ? { value: Number(last.value), row: last.id, from: last.population === "past" ? "remembered" : "stated" } : null; }; + const scaleMin = Number.isFinite(settings.scale?.min) ? settings.scale.min : -Infinity; const goalOf = (row) => { - const base = row.population === "goal_loss" ? goalBase(row) : null; - const cell = goalCell(row, base, s); - return { value: cell.value, loss: cell.loss, deadline: cell.deadline, due: isIso(row.due) ? row.due : null, row: row.id, display: cell.display, base }; + let base = row.population === "goal_loss" ? goalBase(row) : null; + let cell = goalCell(row, base, s); + if (base && Number.isFinite(cell.value) && cell.value < scaleMin) { + base = null; + cell = goalCell(row, null, s); + } + const range = row.population === "goal" ? rangeOf(row) : null; + return { value: cell.value, loss: cell.loss, deadline: cell.deadline, due: isIso(row.due) ? row.due : null, row: row.id, display: cell.display, base, ...(range ? { range } : {}) }; }; /** A promise_claim as a promise carries it: who, when said, the day she says she paid, his-or-her words. */ @@ -506,8 +535,8 @@ export function measureSlice(manifest, schedule, opts = {}) { const row = byId.get(ev.row); // Another speaker's row feeds the promises and nothing else. if (ev.speaker !== null && ev.kind !== "promiseClaim" && ev.kind !== "promiseOutcome") { state.push(snapshot(ev.t)); continue; } - if (ev.kind === "stated" && ev.value !== null) current = { value: ev.value, qualifier: ev.qualifier, row: ev.row, date: ev.date, asOf: ev.asOf }; - else if (ev.kind === "remembered" && ev.value !== null) remembered.push({ value: ev.value, asOf: ev.asOf, row: ev.row, date: ev.date }); + if (ev.kind === "stated" && ev.value !== null) current = { value: ev.value, qualifier: ev.qualifier, row: ev.row, date: ev.date, asOf: ev.asOf, ...(ev.range ? { range: [...ev.range] } : {}) }; + else if (ev.kind === "remembered" && ev.value !== null) remembered.push({ value: ev.value, asOf: ev.asOf, row: ev.row, date: ev.date, ...(ev.qualifier ? { qualifier: ev.qualifier } : {}), ...(ev.range ? { range: [...ev.range] } : {}) }); else if (ev.kind === "goal" || ev.kind === "goalLoss") { goal = goalOf(row); goals.push(ev.row); } else if (ev.kind === "lost" && ev.run !== null) { const v = Math.abs(ev.value); diff --git a/umtool/report-to-video/modules/dial.mjs b/umtool/report-to-video/modules/dial.mjs @@ -36,13 +36,13 @@ export default defineModule({ { key: "size", type: "number", min: 200, max: 540, step: 10, label: "The corner dial's size (px at 1920)", default: 340 }, { key: "corner", type: "enum", options: ["bottom-right", "bottom-left", "top-right", "top-left"], label: "The corner", default: "bottom-right" }, { key: "motion", type: "enum", options: ["spring", "ease"], label: "The needle's move", default: "spring" }, - { key: "finaleEnd", type: "enum", options: ["odometer", "promise"], label: "The finale's last beat", default: "odometer" }, + { key: "finaleEnd", type: "enum", options: ["auto", "odometer", "promise"], label: "The finale's last beat", default: "auto" }, ], docs: { heading: "Scale dial", intro: "A bathroom-scale face at the top of the instruments' column (the right of the frame; the clip moves to the left -- `instrumentsGeometry`, 1248×702 footage beside a 600 px column at 1920×1080). It reads the schedule's `measure` (the measure ledger's slice): the red needle swings to each STATED weight at its event's `t` (the spoken word) with a spring (`back.out`, 0.9 s) and rests there -- a frame at rest is reused, not captured again; a qualifier draws a wedge in pounds (≈ 3 under to 1 over, `>` 10 up, `<` 10 down); every REMEMBERED weight is a grey tick, the latest a long ghost needle with its as-of date; the latest goal is an amber tick on the bezel and its words under the digits. It comes and goes with the deck (a card, the finale). With any instrument on, the posts stay in the footage box (`posts.shift` does not apply), and the side panel (`threads`, `flips`) and the posts feed are refused.", rows: [ - ["`deck.dial`", "`true` · an object of the knobs below · absent or `false` off", "`umtool look <p> deck.dial=true`"], + ["`deck.dial`", "`true` · an object of the knobs below · `false` off · absent: ON when the cut draws a measure (`deck.measure` set), else off", "`umtool look <p> deck.dial=false`"], ["`deck.dial.mark`", "a weight, or `null` · default `300` (its tick and label in the accent)", "`umtool look <p> deck.dial.mark=300`"], ["`deck.dial.ghosts`, `.goal`", "bool · default `true` each", "`umtool look <p> deck.dial.ghosts=false`"], ["`deck.dial.needle`", "a #hex · default `#ff5a4e`", "`umtool look <p> deck.dial.needle='\"#ff5a4e\"'`"], @@ -52,7 +52,7 @@ export default defineModule({ ["`deck.dial.size`", "200–540 px at 1920 wide · default `340` (the corner dial only)", "`umtool look <p> deck.dial.size=300`"], ["`deck.dial.corner`", "`bottom-right` `bottom-left` `top-right` `top-left` · default `bottom-right` (the corner only): the dial in that corner, the odometer and the trail up the same side. The measure extras stand at their own anchors in the footage (goals bottom-right, peak top-right, promise top-centre, diet bottom-left, streak bottom-centre): a corner instrument over one that is on is REFUSED by the build, naming it -- move one (`deck.goals.position`, …) or the corner; `top-left` is clear of all five", "`umtool look <p> deck.dial.corner=top-left`"], ["`deck.dial.motion`", "`spring` `ease` · default `spring`. A VARIANT: the needle's `back.out` overshoot and settle, or a plain `power2.inOut` (the finale's drop too)", "`umtool look <p> deck.dial.motion=ease`"], - ["`deck.dial.finaleEnd`", "`odometer` `promise` · default `odometer`. A VARIANT: `promise` hands the finale's last beat to the promise clock (module `promise`) -- the instruments fade out once NET has held (`dialFinaleHandoff`); with no promise module on the cut it ends on the odometer", "`umtool look <p> deck.dial.finaleEnd=promise`"], + ["`deck.dial.finaleEnd`", "`auto` `odometer` `promise` · default `auto` (`promise` when a promise is on camera, else `odometer`): `promise` hands the finale's last beat to the promise clock (module `promise`) -- the instruments fade out once NET has held (`dialFinaleHandoff`) and the clock takes their place in the finale's lower column, clear of the rail; with no promise module on the cut it ends on the odometer", "`umtool look <p> deck.dial.finaleEnd=promise`"], ], }, region: "dial", diff --git a/umtool/report-to-video/modules/finale.mjs b/umtool/report-to-video/modules/finale.mjs @@ -32,7 +32,7 @@ export default defineModule({ { key: "totals", type: "boolean", label: "Totals", default: true }, { key: "statsTitle", type: "text", label: "Stats title" }, { key: "stats", type: "stats", label: "Stats cards", max: 8 }, - { key: "railLabels", type: "enum", options: ["all", "nodes"], label: "Rail labels", default: "all" }, + { key: "railLabels", type: "enum", options: ["all", "nodes", "sections", "none"], label: "Rail labels", default: "all" }, { key: "pips", type: "boolean", label: "The finale's clips on the rail", default: true }, { key: "timelineShare", type: "number", min: 0.38, max: 0.6, step: 0.01, label: "Timeline share (auto when unset)" }, { key: "claims", type: "enum", options: ["rotate", "all"], label: "Claim checks", default: "rotate" }, diff --git a/umtool/report-to-video/modules/measure-extras-module.mjs b/umtool/report-to-video/modules/measure-extras-module.mjs @@ -7,7 +7,8 @@ // file says only what is its own. import path from "node:path"; -import { measureExtraGeometry, measureOf, measurePlacements } from "../measure-extras.mjs"; +import { measureExtraGeometry, measureOf } from "../measure-extras.mjs"; +import { placementsFor } from "../chrome-measure-extras.mjs"; import { assertRegion, defineModule } from "./contract.mjs"; import { MEASURE_AVOID, MEASURE_DEFAULTS, MEASURE_FINALE, MEASURE_LIMITS, MEASURE_POSITIONS, resolveMeasureExtra, @@ -80,7 +81,7 @@ export function measureExtraModule(spec) { return [assertRegion({ name: id, frames: frames ?? path.join(outDir, "chrome", `${id}-frames`), // Its home, and every slot it moves clear to (a post card, a chapter band: measurePlacements). - ...measurePlacements(schedule, render)[id].region, + ...placementsFor(schedule, render)[id].region, })]; }, preview: (_slice, { render }) => ({ region: id, geometry: measureExtraGeometry(id, render) }), diff --git a/umtool/report-to-video/modules/measure-extras-settings.mjs b/umtool/report-to-video/modules/measure-extras-settings.mjs @@ -3,7 +3,8 @@ // dial -- the goal stack (`goals`), the moving start (`peak`), the promise // clock (`promise`) and the diet badge (`diet`). Their defaults and validators, // the one copy. A LEAF like settings.mjs (deck.mjs imports it through -// SETTINGS), so it imports nothing. +// SETTINGS), so it imports only instruments.mjs (a leaf too: whether the +// instruments' column is on decides two defaults here). // // render.chrome.deck.goals { show, position, x, y, scale, hold, finale, max, color, countdown } // render.chrome.deck.peak { show, position, x, y, scale, hold, finale, title, color, values } @@ -28,6 +29,8 @@ // put its top-left corner anywhere -- inside the panel column, say -- and // `scale` sizes it. +import { instrumentsOn, resolveDial } from "../instruments.mjs"; + /** The anchors in the footage box a module may sit at (`position`). */ export const MEASURE_POSITIONS = Object.freeze(["top-left", "top-right", "bottom-left", "bottom-right", "top-center", "bottom-center"]); @@ -79,7 +82,8 @@ export const MEASURE_LIMITS = Object.freeze({ quote: 160, }); -const COMMON = Object.freeze({ show: true, position: "top-left", x: null, y: null, scale: 1, hold: null, finale: "hide", onPosts: "dodge", onChapters: "dodge" }); +// `avoid`: the anchors a dodge never moves into (the streams' face cam is most often top-left). +const COMMON = Object.freeze({ show: true, position: "top-left", x: null, y: null, scale: 1, hold: null, finale: "hide", onPosts: "dodge", onChapters: "dodge", avoid: Object.freeze(["top-left"]) }); /** Each module's settings and their defaults. */ export const MEASURE_DEFAULTS = Object.freeze({ @@ -95,7 +99,7 @@ export const MEASURE_DEFAULTS = Object.freeze({ // handle also finding her picture in the manifest's postAvatars (else a // monogram); `claimVerb` is what her claim says she did; `claimColor` her ink. promise: Object.freeze({ ...COMMON, position: "top-center", finale: "show", label: null, verb: "offered", kept: "Posted", broken: "None posted", checks: "label", - speakers: Object.freeze({}), claimVerb: "paid", claimColor: "#E37AB8" }), + speakers: Object.freeze({}), claimVerb: "paid", claimColor: "#E37AB8", slot: "auto" }), // The diet badge: up from the first diet on, re-stamped at every change. diet: Object.freeze({ ...COMMON, position: "bottom-left", colors: Object.freeze({}), labels: Object.freeze({}) }), // The streak chain: bottom-centre, between the diet badge and the goal @@ -103,6 +107,16 @@ export const MEASURE_DEFAULTS = Object.freeze({ streak: Object.freeze({ ...COMMON, position: "bottom-center", source: "diet", axis: "date", title: null, color: null, colors: Object.freeze({}), labels: Object.freeze({}) }), }); +/** Each extra's anchor beside the instruments' column (resolveMeasureExtra), when its own is not named. */ +// All along the foot, a size down, so the top of the clip -- where the streams' face cam is -- stays clear: +// diet 308 px at the left, the streak 446 in the middle, the goals 320 at the right (48–356, 425–871, 928–1248). +export const COLUMN_POSITIONS = Object.freeze({ diet: "bottom-left", streak: "bottom-center", goals: "bottom-right", peak: "top-center", promise: "top-center" }); +/** Each extra's size beside the column, when its own `scale` is not named. */ +export const COLUMN_SCALES = Object.freeze({ diet: 0.7, streak: 0.72, goals: 0.8 }); + +/** Where the promise clock stands (`promise.slot`): the instruments' column (the trail's slot), the footage box, or the column when the instruments are on. */ +export const PROMISE_SLOTS = Object.freeze(["auto", "column", "footage"]); + /** The four ids, in the order they are drawn. */ export const MEASURE_EXTRAS = Object.freeze(["diet", "peak", "goals", "promise", "streak"]); @@ -121,8 +135,20 @@ export function resolveMeasureExtra(id, render) { const base = MEASURE_DEFAULTS[id]; const v = render?.chrome?.deck?.[id]; if (v === false) return null; + // With the dial on, the moving start repeats its ghosts: off unless it is named + // (its count rides on the dial's ghost label, "told 5×"). + if (id === "peak" && v === undefined && resolveDial(render)) return null; const own = isObj(v) ? v : {}; const out = { ...base, ...own }; + // Beside the instruments' column the clip box is 1248×702: the anchors and sizes + // that keep them clear of each other there (the diet badge beside the streak + // strip, not on it) -- unless a position is named. + if (instrumentsOn(render) && own.position === undefined && own.x === undefined && COLUMN_POSITIONS[id]) { + out.position = COLUMN_POSITIONS[id]; + if (own.scale === undefined && COLUMN_SCALES[id]) out.scale = COLUMN_SCALES[id]; + } + // Where the promise clock stands: the column's trail slot when the instruments are on ("auto"). + if (id === "promise") out.slot = out.slot === "auto" ? (instrumentsOn(render) ? "column" : "footage") : out.slot; if (id === "diet" || id === "streak") { out.colors = { ...DIET_COLORS, ...(isObj(own.colors) ? own.colors : {}) }; out.labels = { ...DIET_LABELS, ...(isObj(own.labels) ? own.labels : {}) }; @@ -173,6 +199,9 @@ export function validateMeasureExtra(id, v, where = `render.chrome.deck.${id}`) errors.push(`${where}.hold must be 0 (up from its first event on) or from ${L.hold[0]} to ${L.hold[1]} seconds`); } if (v.finale !== undefined && !MEASURE_FINALE.includes(v.finale)) errors.push(`${where}.finale must be "hide" or "show"`); + if (v.avoid !== undefined && !(Array.isArray(v.avoid) && v.avoid.every((a) => MEASURE_POSITIONS.includes(a)))) { + errors.push(`${where}.avoid must be a list of anchors (${MEASURE_POSITIONS.join(", ")})`); + } for (const k of ["onPosts", "onChapters"]) { if (v[k] !== undefined && !MEASURE_AVOID.includes(v[k])) errors.push(`${where}.${k} must be "dodge", "hide" or "show"`); } @@ -191,6 +220,7 @@ export function validateMeasureExtra(id, v, where = `render.chrome.deck.${id}`) if (id === "promise") { for (const k of ["label", "verb", "kept", "broken"]) text(v[k], L.text, `${where}.${k}`, errors, { nullable: k === "label" }); if (v.checks !== undefined && !PROMISE_CHECKS.includes(v.checks)) errors.push(`${where}.checks must be "label" or "quote"`); + if (v.slot !== undefined && !PROMISE_SLOTS.includes(v.slot)) errors.push(`${where}.slot must be "auto", "column" or "footage"`); text(v.claimVerb, L.text, `${where}.claimVerb`, errors, { nullable: false }); color(v.claimColor, `${where}.claimColor`, errors); if (v.speakers !== undefined) { diff --git a/umtool/report-to-video/modules/odometer.mjs b/umtool/report-to-video/modules/odometer.mjs @@ -34,7 +34,7 @@ export default defineModule({ heading: "Lost odometer", intro: "Under the dial: the measure's `state.lost.total` (the highest real-time loss claim in each run, summed) on mechanical wheels to a tenth, rolling forward at each claim that raises it (1.3 s) and never back -- a lower total is held at the highest so far. NET (`state.net`: the first stated weight of the record to the latest) in plain digits beside it, `−76.5 · 368 → 291.5`; `ACROSS 8 RUNS` under the wheels.", rows: [ - ["`deck.odometer`", "`true` · an object of the knobs below · absent or `false` off", "`umtool look <p> deck.odometer=true`"], + ["`deck.odometer`", "`true` · an object of the knobs below · `false` off · absent: ON when the cut draws a measure (`deck.measure` set), else off", "`umtool look <p> deck.odometer=false`"], ["`deck.odometer.label`", "words over the wheels, ≤ 40 · default `POUNDS HE SAYS HE'S LOST`", "`umtool look <p> deck.odometer.label='\"…\"'`"], ["`deck.odometer.net`, `.runs`", "bool · default `true` each", "`umtool look <p> deck.odometer.net=false`"], ], diff --git a/umtool/report-to-video/modules/trail.mjs b/umtool/report-to-video/modules/trail.mjs @@ -33,7 +33,7 @@ export default defineModule({ heading: "Weight trail", intro: "At the foot of the instruments' column: every STATED weight the cut shows, placed by the date he was weighed (its `asOf`, else its date) across the span of them, a dot appearing at its event's `t` and the line between two neighbours drawn once both are said; a red ring on the latest said. The `mark` line (300) dashed across; with `count` and the mark at 300, `UNDER 300 · SAID n×` counts the measure's `totals.under300` rows as the cut reaches each.", rows: [ - ["`deck.trail`", "`true` · an object of the knobs below · absent or `false` off", "`umtool look <p> deck.trail=true`"], + ["`deck.trail`", "`true` · an object of the knobs below · `false` off · absent: ON when the cut draws a measure (`deck.measure` set), else off", "`umtool look <p> deck.trail=false`"], ["`deck.trail.mark`", "a weight, or `null` · default `300`", "`umtool look <p> deck.trail.mark=300`"], ["`deck.trail.count`", "bool · default `true`", "`umtool look <p> deck.trail.count=false`"], ["`deck.trail.label`", "its title, ≤ 40 · default `WHAT HE SAYS HE WEIGHS, BY DATE`", "`umtool look <p> deck.trail.label='\"…\"'`"], diff --git a/umtool/report-to-video/rev9-panel.test.mjs b/umtool/report-to-video/rev9-panel.test.mjs @@ -0,0 +1,196 @@ +// The rev 9 integration fixes on the measure's instruments and extras (6 Nov; the rev9-panel preview's +// list A–K): instruments on by default with a measure, the dial's pre-state, a loss goal's base, ranges kept +// as ranges, the finale's ghost, the finale rail's labels, the finale's crossfade and caption line, the promise +// clock in the column's trail slot (and its strip over a post card in the footage box), and the wedge. +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import path from "node:path"; +import test from "node:test"; +import { fileURLToPath } from "node:url"; + +import { estimateSchedule, validateChrome } from "./deck.mjs"; +import { dialFinaleHandoff, dialFinaleHtml, dialHtml, goalWords, trailHtml, trailYields } from "./chrome-instruments.mjs"; +import { titleLast } from "./chrome-finale.mjs"; +import { instrumentsOn, resolveDial, resolveOdometer, resolveTrail } from "./instruments.mjs"; +import { measureTrack, wedgeRange, weightWords } from "./measure-draw.mjs"; +import { measureSlice, rangeOf } from "./measure-slice.mjs"; +import { measureExtraGeometry, measurePlacements, promiseStripRect } from "./measure-extras.mjs"; +import { placementsFor, promiseFinaleSlot, promiseHtml } from "./chrome-measure-extras.mjs"; +import { validateFinaleSettings } from "./finale.mjs"; + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const DIAL = JSON.parse(readFileSync(path.join(HERE, "fixtures", "measure-dial", "measure.json"), "utf8")); +const EXTRAS = JSON.parse(readFileSync(path.join(HERE, "fixtures", "measure-extras", "measure.json"), "utf8")); +const PAL = { bg: "#0F1312", fg: "#EDF0EC", muted: "#98A29B", accent: "#22AB83", amber: "#E8A33F" }; +const render = (deck = {}) => ({ width: 1920, height: 1080, fps: 30, transition: 0.4, palette: PAL, chrome: { engine: "hyperframes", layout: "deck", deck } }); +const clone = (v) => JSON.parse(JSON.stringify(v)); + +/** A deck cut of nine clips (the last the finale) with `measure` in its schedule. */ +function cut(r, measure = DIAL) { + const timeline = Array.from({ length: 9 }, (_, i) => ({ + type: "clip", id: `c${i + 1}`, video: "vidx", start: 10 * i, end: 10 * i + (i === 8 ? 14 : 8), cite: 1, section: 0, + quote: "q", onscreen: { title: `Clip ${i + 1}` }, ...(i === 8 ? { layout: "finale" } : {}), + })); + const manifest = { slug: "m", title: "M", provenance: {}, render: r, timeline }; + return { manifest, schedule: { ...estimateSchedule(manifest), measure } }; +} + +test("A: with a measure the instruments are ON unless they say otherwise; without one, only when named", () => { + const withMeasure = render({ measure: { scopes: ["weight"] } }); + assert.ok(resolveDial(withMeasure) && resolveOdometer(withMeasure) && resolveTrail(withMeasure)); + assert.equal(instrumentsOn(withMeasure), true, "the column is on"); + assert.equal(resolveDial(render({ measure: { scopes: ["weight"] }, dial: false })), null, "false is off"); + assert.equal(resolveDial(render({})), null, "no measure, not named: off (a cut without them is the cut it was)"); + assert.ok(resolveDial(render({ dial: true }))); + assert.deepEqual(validateChrome(withMeasure.chrome, withMeasure), []); +}); + +test("B: before he states a weight the dial says so in words, its needle parked at the foot, dimmed -- never a number", () => { + const r = render({ dial: true }); + const { schedule } = cut(r); + const html = dialHtml(schedule, r, { fonts: {} }); + assert.match(html, /NO WEIGHT<br>STATED YET/); + const data = JSON.parse(/<script id="dial-data" type="application\/json">([^<]*)<\/script>/.exec(html)[1]); + assert.equal(data.init.nd.opacity, 0.3, "the needle dimmed until the first stated weight"); + assert.ok(data.cues.some((c) => c.k === "nd" && c.to.opacity === 1), "and brought up with it"); + // The ghosts still draw before it (w21 ≈390 is remembered before any stated in the dial fixture? its ghost layer is there). + assert.match(html, /data-k="g0"/); +}); + +test("C: a loss goal resolves against the run's start, else the latest weight he gave; below the scale's foot it is his words alone", () => { + const schema = { + kind: "measure", unit: "lb", yMin: 220, yMax: 400, bandGapDays: 60, + tracks: [{ key: "weight", role: "value", label: "Weight" }], + forms: ["current", "past", "delta", "goal", "goal_loss"], + }; + const row = (o) => ({ scope: "weight", scopeBasis: "his words", scopeConfidence: "read", valueKind: "uttered", flags: [], asOf: null, ...o }); + const ledger = [ + row({ id: "w07", date: "2022-06-15", population: "current", value: 240, display: "240 lb", entryId: "c1" }), + row({ id: "w16", date: "2023-06-07", population: "goal_loss", value: -75, display: "lose 75", entryId: "c2" }), + row({ id: "w21", date: "2023-09-29", asOf: "2023-07-01", population: "past", value: 390, display: "≈390 lb", entryId: "c3" }), + row({ id: "w22", date: "2023-10-12", population: "goal_loss", value: -100, display: "lose 100", entryId: "c4" }), + row({ id: "w32", date: "2024-01-30", population: "goal", value: 230, display: "220-240", entryId: "c5" }), + ]; + const r = render({ measure: { scopes: ["weight"], scale: { min: 220, max: 400 }, asOf: "2026-11-06" } }); + const { manifest } = cut(r); + const doc = estimateSchedule(manifest); + const m = measureSlice({ ledgerSchema: schema, ledger, render: r, timeline: manifest.timeline }, doc, {}); + const goalAfter = (row) => m.state[m.events.findIndex((e) => e.row === row) + 1].goal; + // 240 - 75 = 165, below the scale's foot (220): no target -- "LOSE 75", no tick. + assert.deepEqual([goalAfter("w16").value, goalAfter("w16").base], [null, null]); + assert.equal(goalWords(goalAfter("w16")), "LOSE 75"); + // The latest weight he gave by then is the remembered ≈390 (by the day it was his weight): 390 - 100 = 290. + assert.deepEqual([goalAfter("w22").value, goalAfter("w22").base.row, goalAfter("w22").base.from], [290, "w21", "remembered"]); + // D: a goal he gave as a range keeps it. + assert.deepEqual(goalAfter("w32").range, [220, 240]); + assert.equal(goalWords(goalAfter("w32")), "GOAL 220–240"); +}); + +test("D: a range stays a range -- on the events and the state, the dial's wedge, its words", () => { + assert.deepEqual(rangeOf({ display: "330-340 lb" }), [330, 340]); + assert.deepEqual(rangeOf({ display: "230–240" }), [230, 240]); + assert.equal(rangeOf({ display: "≈390 lb" }), null); + assert.deepEqual(wedgeRange(335, null, [330, 340]), [330, 340]); + assert.equal(weightWords({ value: 335, range: [330, 340] }), "330–340"); + assert.equal(weightWords({ value: 300, qualifier: ">" }), ">300"); + // A remembered range in the state is drawn as one: the ghost's band and words. + const m = clone(DIAL); + const i = m.events.findIndex((e) => e.kind === "remembered"); + m.events[i].range = [380, 390]; + for (const s of m.state) for (const r of s.remembered ?? []) if (r.row === m.events[i].row) r.range = [380, 390]; + const t = measureTrack(m); + assert.deepEqual(t.remembered[0].range, [380, 390]); + const r = render({ dial: true }); + const html = dialHtml({ ...cut(r).schedule, measure: m }, r, { fonts: {} }); + assert.match(html, /data-k="gb0"/); + assert.match(html, /<b>380–390<\/b>/); +}); + +test("the wedge reads at a glance: a strong fill with an outline, and its words beside it (\">300\")", () => { + const r = render({ dial: true }); + const html = dialHtml(cut(r).schedule, r, { fonts: {} }); + assert.match(html, /fill-opacity="0\.78"/); + assert.match(html, /class="qlab" data-k="ql\d+"[^>]*>>300</); +}); + +test("E: the finale's long ghost stands on the LATEST remembered row (the last state's), never an earlier telling", () => { + const r = render({ dial: true, odometer: true, finale: { video: "side", totals: false } }); + const { schedule } = cut(r); + const html = dialFinaleHtml(schedule, r, { from: schedule.finale.from, to: schedule.finale.to }, { fonts: {} }); + const track = measureTrack(DIAL); + const last = track.remembered[track.remembered.length - 1]; + const n = track.remembered.length - 1; + // Its as-of label is the one shown. + const data = JSON.parse(/<script id="dial-finale-data" type="application\/json">([^<]*)<\/script>/.exec(html)[1]); + assert.ok(data.cues.some((c) => c.k === `fga${n}` && c.to.autoAlpha === 1), "the last ghost's words come up"); + assert.ok(!data.cues.some((c) => /^fga\d+$/.test(c.k) && c.k !== `fga${n}` && c.to.autoAlpha === 1)); + assert.ok(last.asOf); +}); + +test("G (count): the dial's ghost label carries how many times he told that start", () => { + const t = measureTrack(DIAL); + const n390 = t.remembered.filter((x) => Math.abs(x.value - 390) < 0.05); + assert.deepEqual(n390.map((x) => x.told), n390.map((_, i) => i + 1)); + const r = render({ dial: true }); + assert.match(dialHtml(cut(r).schedule, r, { fonts: {} }), /TOLD 2×/); +}); + +test("H: the finale rail's labels may be the section markers' alone, or none", () => { + assert.deepEqual(validateFinaleSettings({ railLabels: "sections" }), []); + assert.deepEqual(validateFinaleSettings({ railLabels: "none" }), []); + assert.match(validateFinaleSettings({ railLabels: "dates" }).join(), /railLabels must be/); +}); + +test("I: the dial's finale comes in with the finale (over its grow), as the column goes under it -- no empty frame", () => { + const r = render({ dial: true, odometer: true, finale: { video: "side", totals: false } }); + const { schedule } = cut(r); + const html = dialFinaleHtml(schedule, r, { from: schedule.finale.from, to: schedule.finale.to }, { fonts: {} }); + const data = JSON.parse(/<script id="dial-finale-data" type="application\/json">([^<]*)<\/script>/.exec(html)[1]); + const inCue = data.cues.find((c) => c.k === "rt" && c.to.autoAlpha === 1); + assert.ok(Math.abs(inCue.at - schedule.finale.from) < 0.05, `in at the finale's start (${inCue.at} vs ${schedule.finale.from})`); + const col = JSON.parse(/<script id="dial-data" type="application\/json">([^<]*)<\/script>/.exec(dialHtml(schedule, r, { fonts: {} }))[1]); + const out = col.cues.find((c) => c.k === "rt" && c.to.autoAlpha === 0 && Math.abs(c.at - schedule.finale.from) < 0.6); + assert.ok(out && out.dur >= 0.79, "the column goes over the finale's grow"); +}); + +test("J: the finale clip's source line puts the title last, so only its end is ever clamped", () => { + assert.equal(titleLast("TheQuartering (Rumble) · Democrats PANIC Over Red Wave · Nov 3, 2026 · 13:48"), "TheQuartering (Rumble) · Nov 3, 2026 · 13:48 · Democrats PANIC Over Red Wave"); + assert.equal(titleLast("A · B"), "A · B"); +}); + +test("K: beside the instruments the promise clock stands in the trail's slot (compact), the trail yields; in the footage box it becomes a strip over a post card; in the finale it takes the dial's lower column", () => { + const r = render({ dial: true, odometer: true, trail: true, measure: { scopes: ["weight"] }, promise: { label: "scale video" }, finale: { video: "side", totals: false } }); + const sched = { kind: "deck", fps: 30, total: 740, transition: 0.4, segments: [{ id: "a", start: 0, duration: 740, end: 740 }], measure: EXTRAS }; + const home = measureExtraGeometry("promise", r); + assert.equal(home.width, 600); + assert.equal(home.height, 138); + const html = promiseHtml(sched, r, { fonts: {} }).html; + assert.match(html, /scale video · offered 23 Oct · <span class="clc"/); + // The trail fades from the promise's first state on. + const yields = trailYields(sched, r); + assert.equal(yields[0].in, 712.18); + const t = JSON.parse(/<script id="trail-data" type="application\/json">([^<]*)<\/script>/.exec(trailHtml({ ...sched, measure: DIAL }, r, { fonts: {} }))[1]); + void t; + // In the column, a post card in the footage moves nothing. + const covered = { ...sched, covers: [{ segment: "p", from: 715, to: 725, rects: [{ x: 300, y: 100, width: 700, height: 600 }] }] }; + assert.equal(measurePlacements(covered, r).promise.moves.length, 0); + // In the footage box (no instruments): hidden over the card, and a strip in its top margin instead. + const f = render({ promise: { label: "scale video" } }); + const p = measurePlacements(covered, f).promise; + assert.deepEqual(p.moves, [{ from: 715, to: 725, rect: null, size: 1 }]); + assert.deepEqual(p.strips, [{ from: 715, to: 725 }]); + const strip = promiseStripRect(f); + assert.ok(p.region.y <= strip.y && p.region.x <= strip.x); + assert.match(promiseHtml(covered, f, { fonts: {} }).html, /<div id="ps" data-k="ps"[^>]*>.*class="sl" data-k="t0"/s); + // `slot: "footage"` beside the instruments keeps it in the footage box. + assert.equal(measureExtraGeometry("promise", render({ dial: true, promise: { slot: "footage" } })).width, 640); + // The finale: the dial's finale hands its lower column to it ("auto": a promise is on camera). + const { schedule } = cut(r, EXTRAS); + const at = dialFinaleHandoff(schedule, r); + assert.ok(at !== null, "a handoff in a short finale too"); + const slot = promiseFinaleSlot(schedule, r); + assert.equal(slot.at, at); + const moves = placementsFor(schedule, r).promise.moves; + assert.ok(moves.some((m) => m.rect && Math.abs(m.from - at) < 1e-6)); + assert.ok(moves.some((m) => !m.rect && Math.abs(m.from - schedule.finale.from) < 1e-6 && Math.abs(m.to - at) < 1e-6), "hidden over the rail until then"); +});