Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit b84a902a2e130767ff757d0cc3d04347086b4f36
parent 552dc00028cf373a0e2015e675b90e80b48b1c36
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 29 Oct 2026 18:04:44 -0400

umtool deck rail: sections by colour, unlabelled markers, rail.labels; two-line subtitle no longer repeats the title

- deck.pip.color "section": every pip (dim until lit), the fuse (a bar per
  section, each burning its share of the one fuse's time) and the marker's
  ring take the colour of the section they stand in -- marker to marker, in
  the marker's color; deck.pip.sectionColor0 (hex or palette key, default the
  accent) before the first. Colours under 3:1 on the deck are lifted.
- A marker's label is optional: none (or "") draws a tick at the boundary,
  no words; the crowded-label layout ignores it, and with no labelled marker
  the track takes no band. deck.rail.labels: false makes every marker a tick.
- subtitle.lines 2: a clip's onscreen.title equal to its source title (trim,
  case-insensitive) is not drawn over the two-line block that already shows it.
- Rail module descriptors, umtool look, the Markers editor, knobs.md (generated)
  and report-video.md/README accept and document the keys. Decks without
  them compose byte-identical pages.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/components/projects/MarkersEditor.tsx | 10++++++----
Mumtool/components/projects/OnscreenSection.tsx | 2+-
Mumtool/docs/knobs.md | 5++++-
Mumtool/docs/report-video.md | 12+++++++++---
Mumtool/lib/report/knobsCli.mjs | 4+++-
Mumtool/lib/report/manifest.mjs | 10++++++----
Mumtool/report-to-video/README.md | 23+++++++++++++++++++++--
Mumtool/report-to-video/chrome-deck.mjs | 138+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
Mumtool/report-to-video/deck-counts.test.mjs | 8++++++--
Mumtool/report-to-video/deck.mjs | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
Mumtool/report-to-video/modules/rail.mjs | 21++++++++++++++++++---
Mumtool/report-to-video/modules/settings.mjs | 34++++++++++++++++++++++++++--------
Aumtool/report-to-video/rail-sections.test.mjs | 183+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13 files changed, 470 insertions(+), 52 deletions(-)

diff --git a/umtool/components/projects/MarkersEditor.tsx b/umtool/components/projects/MarkersEditor.tsx @@ -12,7 +12,9 @@ import { buttonVariants } from "@/components/ui/button"; // else of the deck (PUT /api/report/chrome { markers, markerLayout }), the // writer `umtool look deck.markers=…` uses. -export type Marker = { after: string; label: string; color?: string; align?: string }; +// `label` is optional: a marker without one is a tick at its boundary (and, +// with `pip.color: "section"`, where the rail's colour changes). +export type Marker = { after: string; label?: string; color?: string; align?: string }; type Row = { after: string; label: string; color: string; align: string }; export const MARKER_MAX = 12; @@ -22,10 +24,10 @@ const PALETTE = ["amber", "accent", "fg", "muted", "dim"]; const input = "rounded border border-[var(--color-line)] bg-[var(--color-ink)] px-1.5 py-0.5 text-[11px] text-[var(--color-text)] outline-none focus:border-[var(--color-sel)]"; -const rowOf = (m: Marker): Row => ({ after: m.after, label: m.label, color: m.color ?? "", align: m.align ?? "auto" }); +const rowOf = (m: Marker): Row => ({ after: m.after, label: m.label ?? "", color: m.color ?? "", align: m.align ?? "auto" }); const markerOf = (r: Row): Marker => ({ after: r.after, - label: r.label.trim(), + ...(r.label.trim() ? { label: r.label.trim() } : {}), ...(r.color.trim() ? { color: r.color.trim() } : {}), ...(r.align && r.align !== "auto" ? { align: r.align } : {}), }); @@ -141,7 +143,7 @@ export default function MarkersEditor({ <input data-testid={`marker-label-${i}`} value={r.label} - placeholder="label" + placeholder="label (blank: a tick)" onChange={(e) => put(i, { label: e.target.value })} className={`${input} w-44`} /> diff --git a/umtool/components/projects/OnscreenSection.tsx b/umtool/components/projects/OnscreenSection.tsx @@ -573,7 +573,7 @@ type DeckSettings = { qr: boolean; }; /** Flags on the pip track (`deck.markers`): the Markers editor's; carried through every settings save. */ - markers?: { after: string; label: string; color?: string; align?: string }[]; + markers?: { after: string; label?: string; color?: string; align?: string }[]; /** What the deck does when marker labels crowd (`deck.markerLayout`): the Markers editor's. */ markerLayout?: string; }; diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -457,7 +457,10 @@ The pip track along the top of the deck; the markers' flags stand over it ([mark | `deck.pip.spacing` | `even` · `time` (each pip at its clip's middle) · `pitch` (each `pip.pitch` px after the last, from the left; the pips not yet reached are not drawn, so an insert keeps the frames before it) · default `even` | `umtool look <p> deck.pip='{"spacing":"pitch","pitch":24}'` | | `deck.pip.pitch` | 8–200 px · default 28 (only with `spacing: "pitch"`; a cut with more pips than the track holds at it is laid at the pitch that fits) | same | | `deck.pip.size`, `deck.pip.activeSize` | 2–24 · 2–40 px, the marker at least the pip · default 6, 12 | `umtool look <p> deck.pip='{"size":8}'` | -| `deck.pip.color` | `accent` · `verdict` (a counted clip's pip takes its series' colour and shape) · default `accent` | `umtool look <p> deck.pip='{"color":"verdict"}'` | +| `deck.pip.color` | `accent` · `verdict` (a counted clip's pip takes its series' colour and shape) · `section` (every pip, the fuse and the marker's ring in the colour of the section it stands in: from one marker to the next, in that marker's `color`; fitted to 3:1 on the deck) · default `accent` | `umtool look <p> deck.pip='{"color":"verdict"}'` | +| `deck.pip.sectionColor0` | the section before the first marker, with `color: "section"`: a `#hex` or a palette key (`fg`, `muted`, `accent`, `amber`, `dim`) · default the accent | `umtool look <p> deck.pip='{"color":"section","sectionColor0":"#5fa8d3"}'` | +| `deck.markers[].label` | optional: a marker with none (or `""`) draws a tick at its boundary, no words, and takes no band over the track | `umtool look <p> deck.markers='[{"after":"c04","color":"#e07a9a"}]'` | +| `deck.rail.labels` | `false` draws every marker as a tick, no words, and no band over the track · default `true` | `umtool look <p> deck.rail='{"labels":false}'` | ### Counter diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -387,14 +387,18 @@ without touching anything else under `render`. The structural writers run until the marker goes. The On-screen settings form edits every `render.chrome.deck` key it lists, -among them **colour** under timeline (`pip.color`: `accent`, or `verdict` — a -claimed clip's pip lit in its claim's verdict colour and shape) and **qr +among them **colour** under timeline (`pip.color`: `accent`, `verdict` — a +claimed clip's pip lit in its claim's verdict colour and shape — or `section`: +every pip, the fuse and the marker's ring in the colour of the section it stands +in, from one marker to the next in that marker's `color`, `pip.sectionColor0` +before the first, fitted to 3:1 on the deck) and **qr codes** under posts (`posts.qr`: off draws no QR on any post card, popup or feed). The fact-check form beside the structure editors has **stamp effect** (`factcheck.stamp.show`: off draws no stamp over the footage; the tally still counts) and, per verdict, **pop in** (`factcheck.tally.showAt`: the tally's cell hidden until its first count lands, then popped in; every verdict ticked writes -`"first"`, some `{ <VERDICT>: "first" }`, none removes the key). `deck.markers` — flags on the pip track, `[{ after, label, color? }]` +`"first"`, some `{ <VERDICT>: "first" }`, none removes the key). `deck.markers` — flags on the pip track, `[{ after, label?, color? }]` +(no `label`: a tick at the boundary, no words and no band over the track; `deck.rail.labels: false` makes every marker one) ([the pipeline's README](../report-to-video/README.md#deckmarkers--flags-on-the-pip-track)) — has no form: write them in the manifest. A settings save carries them through, with the fact-check block and the other regions (threads, flips, @@ -438,6 +442,8 @@ and default. | | `fadeIn`, `fadeOut` | 0–5 s · 0 | | | `render.chrome.deck.markers[]` | `align` | auto/left/right/center · auto | the label against its flag | | `render.chrome.deck` | `markerLayout` | stagger/truncate · stagger | crowded labels in two rows | +| `render.chrome.deck.pip` | `color`, `sectionColor0` | accent/verdict/section · accent; #hex or palette key · accent | the rail coloured by section, marker to marker | +| `render.chrome.deck.rail` | `labels` | true/false · true | false: every marker a tick, no words | | `render` | `variants` | a ladder · master, 1080p crf 22, 720p crf 23, fit24 ≤ 24 MiB | Make variants | Sections: [claim knobs](../report-to-video/README.md#a-claims-own-knobs), diff --git a/umtool/lib/report/knobsCli.mjs b/umtool/lib/report/knobsCli.mjs @@ -80,6 +80,8 @@ export const LOOK_USAGE = [ " deck.markers='[{\"after\":\"c01\",\"label\":\"Arrival\",\"align\":\"left\"}]' deck.markerLayout=stagger|truncate", " deck.<key>=<json>: any of the deck's own keys (deck.finale='{…}', deck.pip='{…}', …), checked by the build's rules;", " deck.<key>.<field>=… sets one field and keeps the rest (deck.subtitle.lines=2: the source's title on a line of its own)", + " deck.pip.color=section: the rail coloured by section (marker to marker, each marker's color; deck.pip.sectionColor0 before", + " the first); a marker's label is optional (none: a tick); deck.rail.labels=false draws no marker's words", " pair=<json> | pair.<key>=…, chapter=<json> | chapter.<key>=…, status=<json> | status.<key>=…: the story modules", " (render.chrome.pair / .chapter / .status, docs/knobs.md \"Modules\"), checked by the build's rules", " variants='[{\"name\":\"master\"},{\"name\":\"720p\",\"height\":720,\"crf\":23},{\"name\":\"fit24\",\"maxMiB\":24}]'", @@ -525,7 +527,7 @@ export function knobsLines(manifest) { } if (Object.keys(k.stamp).length) lines.push(` stamp ${Object.entries(k.stamp).map(([a, b]) => `${a}=${b}`).join(" ")}`); if (Object.keys(k.stampLabels).length) lines.push(` stamp word ${Object.entries(k.stampLabels).map(([a, b]) => `${a}=${b}`).join(" ")}`); - if (k.markers.length) lines.push(` markers ${k.markers.map((m) => `${m.after}:"${m.label}"${m.align ? `(${m.align})` : ""}`).join(" ")}${k.markerLayout ? ` · layout ${k.markerLayout}` : ""}`); + if (k.markers.length) lines.push(` markers ${k.markers.map((m) => `${m.after}:${m.label ? `"${m.label}"` : "(tick)"}${m.color ? `[${m.color}]` : ""}${m.align ? `(${m.align})` : ""}`).join(" ")}${k.markerLayout ? ` · layout ${k.markerLayout}` : ""}`); for (const c of k.claims) { if (!isObj(c)) continue; if (c.kind === "count") { diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -2353,16 +2353,18 @@ function normalizeMarksInput(list, render) { /** * Normalise a list of deck markers as the editor sends them: each `{ after, - * label, color?, align? }`, the label trimmed, an empty colour and `align: + * label?, color?, align? }`, the label trimmed (an empty one left out: a tick), an empty colour and `align: * "auto"` (the default) left out. * * @param {unknown} markers */ export function normalizeMarkers(markers) { - if (!Array.isArray(markers)) throw new Error("markers must be a list of { after, label, color?, align? }"); + if (!Array.isArray(markers)) throw new Error("markers must be a list of { after, label?, color?, align? }"); return markers.map((m, i) => { - if (!isObj(m)) throw new Error(`markers[${i}] must be { after, label, color?, align? }`); - const out = { after: String(m.after ?? "").trim(), label: String(m.label ?? "").trim() }; + if (!isObj(m)) throw new Error(`markers[${i}] must be { after, label?, color?, align? }`); + // An empty label is no label (a tick at the boundary): left out. + const label = String(m.label ?? "").trim(); + const out = { after: String(m.after ?? "").trim(), ...(label ? { label } : {}) }; const color = typeof m.color === "string" ? m.color.trim() : ""; if (color) out.color = color; if (m.align !== undefined && m.align !== null && m.align !== "" && m.align !== "auto") out.align = m.align; diff --git a/umtool/report-to-video/README.md b/umtool/report-to-video/README.md @@ -545,8 +545,27 @@ timeline itself: setting; "truncate" always keeps one row. `deckLayout(render, { schedule })` is what knows the band's height — the deck page and `compose-chrome` (for the QR's size) pass the schedule. -- **Refused.** `after` must name a CLIP in the timeline, the label must be - non-empty and ≤ 24 characters, at most 12 markers, a colour a hex or a +- **Unlabelled.** A marker with no `label` (or `""`) draws a short tick across + the track at its boundary in its colour — no flag head, no words — and the + crowded-label layout ignores it; when no marker has words the track takes no + band and stands where a deck without markers has it. `deck.rail.labels: + false` draws every marker that way. +- **Sections** (`deck.pip.color: "section"`, `railSections`). The rail is cut + at the markers: the stretch before the first is `pip.sectionColor0` (a hex + or a palette key; default the accent), each after it its marker's colour. + Every pip (dim until lit), the fuse (a bar per section, each burning its + share of the one fuse's time) and the marker's ring take the colour of the + section they stand in; a marker's own pip closes the section before it. + A colour under 3:1 on the deck's ground is lifted toward white until it + reads (`fitSectionColor`). + + ```jsonc + "deck": { "pip": { "color": "section", "sectionColor0": "#c8752a" }, + "rail": { "labels": false }, + "markers": [{ "after": "q01", "color": "#e07a9a" }, { "after": "d01", "color": "#5fa8d3" }] } + ``` +- **Refused.** `after` must name a CLIP in the timeline, a label (when given) + one line of ≤ 24 characters, at most 12 markers, a colour a hex or a palette key, `align` one of the four, `markerLayout` one of the two, and unknown keys are refused. `validateChrome` checks the shape; `validateDeckMarkers(manifest)` (`deck.mjs`) checks the shape and diff --git a/umtool/report-to-video/chrome-deck.mjs b/umtool/report-to-video/chrome-deck.mjs @@ -38,8 +38,9 @@ import { fileURLToPath } from "node:url"; import { - claimsLayout, cueTime, cueTimeAfter, PIP_PITCH_DEFAULT, stampsOnFrames, deckChoreography, deckLayout, deckMarkers, MARKER_LABEL_SIZE, MARKER_ROW, pageDuration, pipSegments, pipXs, resolveDeck, + claimsLayout, cueTime, cueTimeAfter, PIP_PITCH_DEFAULT, stampsOnFrames, deckChoreography, deckLayout, deckMarkers, MARKER_LABEL_SIZE, MARKER_ROW, pageDuration, pipSegments, pipXs, railSections, resolveDeck, } from "./deck.mjs"; +import { contrast } from "./chrome-intro.mjs"; import { claimsCues, claimsMarkup } from "./chrome-claims.mjs"; import { resolveFactcheck, tallyCues, tallyFinals, tallyKey, tallyLabelOf, tallyOf, tallyPopIns } from "./factcheck.mjs"; import { resolveCounter } from "./counter.mjs"; @@ -184,12 +185,24 @@ export function deckCues(schedule, render) { // in its colour and shape once lit). Only then, so the pips are as they // always were otherwise. const byVerdict = deck.pip.color === "verdict"; - const pips = pipped.map((s, k) => ({ id: s.id, x: r4(xs[k]), ...(byVerdict && s.claim?.verdict ? { verdict: s.claim.verdict } : {}) })); + // `pip.color: "section"` (deck.mjs railSections): every pip, the fuse and + // the marker's ring in the colour of the section it stands in -- from one + // marker's boundary to the next. Only then, likewise. + const placedMarkers = deckMarkers(schedule, render, xs, pipped, lay); + const sections = deck.pip.color === "section" ? railSections(placedMarkers, pipped.length, deck, render?.palette ?? {}) : null; + const pips = pipped.map((s, k) => ({ + id: s.id, x: r4(xs[k]), + ...(byVerdict && s.claim?.verdict ? { verdict: s.claim.verdict } : {}), + ...(sections ? { section: sections.pipSection[k] } : {}), + })); const pipOf = new Map(pipped.map((s, k) => [s.id, k])); const fuseX0 = xs[0] ?? 0; // At a fixed pitch the fuse is measured against the whole track, so its // progress to a pip does not depend on how many come after it. const fuseW = xs.length > 1 ? (pitched ? lay.pipTrack.x1 - xs[0] : xs[xs.length - 1] - xs[0]) : 0; + // In sections the fuse is one bar per section, each burning across its own + // stretch (`fuseParts`); otherwise the one bar it always was. + const fuseParts = sections && fuseW > 0 ? sectionFuses(sections, fuseX0, fuseX0 + fuseW) : null; const frac = (k) => (fuseW > 0 ? r4((xs[k] - fuseX0) / fuseW) : 0); const lift = Math.round(lay.text.titleSize * 0.16); const slideY = lay.height + 12; @@ -200,7 +213,13 @@ export function deckCues(schedule, render) { const startsHidden = !!segs[0]?.hideDeck; put("panel", { y: startsHidden ? slideY : 0 }); put("marker", { x: r4(xs[0] ?? lay.pipTrack.x0) }); - if (fuseW > 0) put("fuse", { scaleX: 0, transformOrigin: "0% 50%" }); + if (fuseParts) for (const f of fuseParts) put(f.k, { scaleX: 0, transformOrigin: "0% 50%" }); + else if (fuseW > 0) put("fuse", { scaleX: 0, transformOrigin: "0% 50%" }); + // The marker's ring in its section's colour: one ring per section that has + // a pip, the first section's lit. + const rings = sections ? [...new Set(sections.pipSection)] : []; + for (const r of rings) put(`mr${r}`, { opacity: r === (sections.pipSection[0] ?? 0) ? 1 : 0 }); + const ringMoves = []; pips.forEach((_, k) => put(`pip${k}`, { opacity: 0 })); // At a fixed pitch a pip is not drawn until the fuse sets off toward it // (the marker reaches the pip before): the rail is the record so far, so a @@ -263,6 +282,7 @@ export function deckCues(schedule, render) { // A segment with no pip (finale.pips: false) leaves the marker where it is. if (pb !== undefined) { add("marker", h.pip[0], h.pip[1] - h.pip[0], { x: pips[pb].x }, "power3.inOut", `${why} pip`); + ringMoves.push({ at: (h.pip[0] + h.pip[1]) / 2, k: pb, why: `${why} pip` }); fillPipsBefore(pb, h.pip[0], Math.min(0.25, h.pip[1] - h.pip[0]), `${why} pip`); } if (pa !== undefined) depart.set(pa, h.pip[0]); @@ -291,6 +311,7 @@ export function deckCues(schedule, render) { const k = pipOf.get(segs[v.i].id); if (k !== undefined) { add("marker", v.at[0], INSTANT, { x: pips[k].x }, "none", why); + ringMoves.push({ at: v.at[0], k, why }); fillPipsBefore(k, v.at[0], INSTANT, why); arrive.set(k, v.at[0]); } @@ -316,8 +337,41 @@ export function deckCues(schedule, render) { } } + // The ring changes colour as the marker crosses into another section: + // half-way through its move, or as the deck rises on it. + if (sections) { + let cur = sections.pipSection[0] ?? 0; + for (const m of ringMoves.sort((x, y) => x.at - y.at)) { + const next = sections.pipSection[m.k]; + if (next === cur) continue; + add(`mr${cur}`, m.at, INSTANT, { opacity: 0 }, "none", `${m.why} section`); + add(`mr${next}`, m.at, INSTANT, { opacity: 1 }, "none", `${m.why} section`); + cur = next; + } + } + // The fuse: from pip k to pip k+1 over the time the marker rests on k. - if (fuseW > 0) { + if (fuseParts) { + // In sections: the burn from where the fuse stands to pip k+1, split + // where it crosses a section's ends -- each bar burns its share of the + // time, linearly, as the one bar would have. + let at = fuseX0; + for (let k = 0; k < pips.length - 1; k += 1) { + const a = arrive.get(k), b = depart.get(k); + if (a === undefined || b === undefined) continue; + const to = xs[k + 1]; + if (!(to > at)) continue; + const ta = cueTime(a, fps), tb = cueTime(b, fps); + const when = (x) => ta + ((tb - ta) * (x - at)) / (to - at); + for (const f of fuseParts) { + const lo = Math.max(at, f.x0), hi = Math.min(to, f.x1); + if (!(hi > lo)) continue; + const t0 = cueTime(when(lo), fps), t1 = hi >= to ? tb : cueTime(when(hi), fps); + add(f.k, t0, t1 - t0, { scaleX: r4((hi - f.x0) / (f.x1 - f.x0)), transformOrigin: "0% 50%" }, "none", `fuse ${pips[k].id}`); + } + at = to; + } + } else if (fuseW > 0) { for (let k = 0; k < pips.length - 1; k += 1) { const a = arrive.get(k), b = depart.get(k); if (a === undefined || b === undefined) continue; @@ -332,7 +386,7 @@ export function deckCues(schedule, render) { // -- it burns linearly from pip k to pip k+1 over the marker's rest on k -- // then a short pop, lit for the rest of the cut. A flag past the last pip // (it follows the last clip) pops in a second before that clip ends. - const markers = deckMarkers(schedule, render, xs, pipped, lay).map((mk, j) => { + const markers = placedMarkers.map((mk, j) => { const a = arrive.get(mk.k), b = depart.get(mk.k); let at; if (mk.k + 1 < xs.length && a !== undefined && b !== undefined && xs[mk.k + 1] > xs[mk.k]) { @@ -372,7 +426,46 @@ export function deckCues(schedule, render) { freeAt.set(e.k, at + dur); cues.push({ k: e.k, at, dur, from, to: e.to, ease: e.ease, why: e.why }); } - return { init, cues, pips, slideY, choreography: ch, ...(markers.length ? { markers } : {}), ...(claims ? { claims } : {}) }; + return { + init, cues, pips, slideY, choreography: ch, ...(markers.length ? { markers } : {}), ...(claims ? { claims } : {}), + ...(sections ? { sections: { ...sections, fuses: fuseParts ?? [], rings } } : {}), + }; +} + +/** The section an (unlabelled) marker opens: one past the markers before it. */ +function sectionOfMarker(sections, mk) { + return Math.min(sections.colors.length - 1, 1 + sections.bounds.filter((b) => b < mk.x).length); +} + +/** + * The section fuse's bars: one per section with any of the fuse's span + * (`x0`..`x1`, the one bar's), each `{ k: "fz<i>", section, x0, x1 }`. + */ +export function sectionFuses(sections, x0, x1) { + const out = []; + const n = sections.colors.length; + for (let i = 0; i < n; i += 1) { + const lo = Math.max(x0, i === 0 ? x0 : sections.bounds[i - 1]); + const hi = Math.min(x1, i === n - 1 ? x1 : sections.bounds[i]); + if (hi - lo > 0.5) out.push({ k: `fz${i}`, section: i, x0: r4(lo), x1: r4(hi) }); + } + return out; +} + +/** + * A section's colour fitted to the deck's ground: mixed toward white (a dark + * ground) or black, in 2 % steps, until it stands at 3:1 -- what a graphic + * (not words) needs to read. A colour that already does is unchanged. + */ +export function fitSectionColor(hex, ground, min = 3) { + const full = /^#[0-9a-fA-F]{3}$/.test(hex) ? `#${[...hex.slice(1)].map((c) => c + c).join("")}` : String(hex).slice(0, 7); + if (contrast(full, ground) >= min) return full.toLowerCase(); + const target = contrast("#ffffff", ground) >= contrast("#000000", ground) ? "#ffffff" : "#000000"; + for (let step = 2; step <= 100; step += 2) { + const out = mix(full, target, step / 100); + if (contrast(out, ground) >= min) return out; + } + return target; } /** A marker's pop as the fuse reaches it: from this scale, over these seconds. */ @@ -435,7 +528,7 @@ export function deckHtml(schedule, render, opts = {}) { if (!(dur > 0)) throw new Error(`deck: nothing to render from ${from}s of a ${total}s cut`); const windowed = from > 0 || Math.abs(dur - total) > 1e-6; - const { init, cues, pips, markers = [], claims = null } = deckCues(schedule, render); + const { init, cues, pips, markers = [], claims = null, sections = null } = deckCues(schedule, render); const t = lay.text; const tr = lay.pipTrack; const qr = lay.qr; @@ -468,6 +561,10 @@ export function deckHtml(schedule, render, opts = {}) { const u2Y = two ? Math.round(t.titleY + (t.subtitleY + (t.headBox ?? 0) + t.subtitleBox - t.titleY - u2Block - 14) / 2) : 0; const plateX = qr ? qr.x - 46 : W; const ink = panel ? mix(pal.bg, pal.fg, 0.085) : pal.bg; // what the marker's ring cuts back to + // In sections (`pip.color: "section"`): each section's colour fitted to the + // ground under the track, and the unlit pips a dim shade of it. + const secColors = sections ? sections.colors.map((c) => fitSectionColor(c, mix(top, bottom, tr.y / H))) : null; + const secDim = secColors ? secColors.map((c) => mix(bottom, c, 0.42)) : null; // The page's ITEMS (frame-keys.mjs): each segment's text, each pip -- the // markup a frame draws only while its gate is visible, collected when the @@ -510,10 +607,11 @@ export function deckHtml(schedule, render, opts = {}) { const vSize = Math.max(pip.size, Math.round((pip.size * 5) / 3)); const pipHtml = pips .map((p, k) => { - const base = `<div class="pip"${pitched && k > 0 ? ` data-k="pb${k}"` : ""} style="left:${r4(p.x - pip.size / 2)}px"></div>`; + const sec = secColors && p.section !== undefined ? p.section : null; + const base = `<div class="pip"${pitched && k > 0 ? ` data-k="pb${k}"` : ""} style="left:${r4(p.x - pip.size / 2)}px${sec !== null ? `; background:${secDim[sec]}` : ""}"></div>`; const color = p.verdict ? verdictColors[p.verdict]?.color ?? pal.accent : null; const lit = !p.verdict - ? `<div class="pip lit" data-k="pip${k}" style="left:${r4(p.x - pip.size / 2)}px"></div>` + ? `<div class="pip lit" data-k="pip${k}" style="left:${r4(p.x - pip.size / 2)}px${sec !== null ? `; background:${secColors[sec]}` : ""}"></div>` : `<div class="pip lit vpip" data-k="pip${k}" data-verdict="${esc(p.verdict)}" data-shape="${shapes[p.verdict]}" ` + `style="left:${r4(p.x - vSize / 2)}px; top:${r4(-vSize / 2)}px; width:${vSize}px; height:${vSize}px; ` + `${shapeCss(shapes[p.verdict], vSize, esc(color))}"></div>`; @@ -531,6 +629,8 @@ export function deckHtml(schedule, render, opts = {}) { // their labels, a row above row 0's. A label's `align` sets its text's side. const markerHtml = markers .map((mk, j) => { + // Unlabelled: a tick at the boundary, no flag, no words. + if (!mk.label) return `<div class="mflag bare" data-k="mk${j}" data-after="${esc(mk.after)}" style="left:${r4(mk.x)}px; --mc:${esc(secColors ? secColors[sectionOfMarker(sections, mk)] : mk.color)}"><div class="mtick"></div></div>`; const left = r4(mk.box[0] - mk.x); const side = mk.align === "left" || mk.align === "right" ? `; text-align:${mk.align}` : ""; return ( @@ -649,7 +749,13 @@ export function deckHtml(schedule, render, opts = {}) { .rail { position: absolute; left: ${tr.x0}px; top: -1px; width: ${tr.x1 - tr.x0}px; height: 2px; border-radius: 1px; background: ${rgba(pal.fg, 0.1)}; } .fuse { position: absolute; left: ${r4(fuseLeft)}px; top: -1px; width: ${r4(fuseWidth)}px; height: 2px; - border-radius: 1px; background: ${pal.accent}; } + border-radius: 1px; background: ${pal.accent}; }${secColors ? ` + /* In sections: the fuse is a bar per section, each in its colour; the + marker's ring is one per section, the one it stands in lit. */ + .fuse.fz { border-radius: 0; } + .marker.sec { box-shadow: none; } + .mring { position: absolute; inset: 0; border-radius: 50%; + box-shadow: 0 0 0 3px ${ink}, 0 0 0 5px var(--rc), 0 0 18px 4px var(--rg); }` : ""} .pip { position: absolute; top: ${-pip.size / 2}px; width: ${pip.size}px; height: ${pip.size}px; border-radius: 50%; background: ${mix(bottom, pal.fg, 0.32)}; } .pip.lit { background: ${pal.accent}; } @@ -734,7 +840,9 @@ export function deckHtml(schedule, render, opts = {}) { .mlabel { position: absolute; top: ${(band?.y ?? 3) + (staggered ? MARKER_ROW : 0) - tr.y}px; height: 20px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: 'DeckSansBold', sans-serif; font-size: ${MARKER_LABEL_SIZE}px; line-height: 20px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--mc); - text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }` : ""}${staggered ? ` + text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }` : ""}${markers.some((mk) => !mk.label) ? ` + /* An unlabelled marker: a short tick across the track, no words. */ + .mtick { position: absolute; left: -1px; top: -6px; width: 2px; height: 12px; border-radius: 1px; background: var(--mc); opacity: 0.85; }` : ""}${staggered ? ` /* Staggered labels: row 1 a row above, its flag's stick up to it. */ .mflag.up .mlabel { top: ${band.y - tr.y}px; } .mflag.up .mstick { top: ${band.y + 20 - tr.y}px; height: ${tr.y + 6 - (band.y + 20)}px; }` : ""}${claimMarkup ? claimMarkup.css : ""} @@ -753,9 +861,13 @@ export function deckHtml(schedule, render, opts = {}) { ${panel ? `<div class="edge"></div><div class="sheen"></div>` : ""} <div class="track"> <div class="rail"></div> - ${fuseWidth > 0 ? `<div class="fuse" data-k="fuse"></div>` : ""} + ${secColors && sections.fuses.length + ? sections.fuses.map((f) => `<div class="fuse fz" data-k="${f.k}" style="left:${f.x0}px; width:${r4(f.x1 - f.x0)}px; background:${secColors[f.section]}"></div>`).join("") + : fuseWidth > 0 ? `<div class="fuse" data-k="fuse"></div>` : ""} ${pipHtml}${markerHtml}${claimMarkup ? claimMarkup.track : ""} - <div class="marker" data-k="marker"></div> + ${secColors + ? `<div class="marker sec" data-k="marker">${sections.rings.map((r) => `<div class="mring" data-k="mr${r}" style="--rc:${rgba(secColors[r], 0.95)}; --rg:${rgba(secColors[r], 0.45)}"></div>`).join("")}</div>` + : `<div class="marker" data-k="marker"></div>`} </div> ${tallyHtml} ${segHtml}${claimMarkup ? claimMarkup.text : ""} diff --git a/umtool/report-to-video/deck-counts.test.mjs b/umtool/report-to-video/deck-counts.test.mjs @@ -205,7 +205,10 @@ test("markers: shape refused in sentences -- unknown keys, labels, colours, coun assert.match(bad("c2"), /markers must be a list/); assert.match(bad([{ after: "c2", label: "x", note: 1 }]), /markers\[0\]\.note is not a marker setting/); assert.match(bad([{ after: "", label: "x" }]), /markers\[0\]\.after must name a clip's id/); - assert.match(bad([{ after: "c2", label: " " }]), /markers\[0\]\.label must be a word or two/); + // No label (or a blank one) is a marker with no words: a tick. + assert.equal(bad([{ after: "c2", label: " " }]), ""); + assert.equal(bad([{ after: "c2" }]), ""); + assert.match(bad([{ after: "c2", label: 3 }]), /markers\[0\]\.label must be a word or two/); assert.match(bad([{ after: "c2", label: "x".repeat(MARKER_LIMITS.label + 1) }]), /is 25 characters \(at most 24\)/); assert.equal(bad([{ after: "c2", label: "x".repeat(MARKER_LIMITS.label) }]), ""); assert.match(bad([{ after: "c2", label: "a\nb" }]), /must be one line/); @@ -220,7 +223,8 @@ test("markers: `after` must name a clip in the timeline -- the build's, the lint assert.match(validateDeckMarkers(m([{ after: "zz", label: "x" }])).join(" "), /names zz, which is not in the timeline/); assert.match(validateDeckMarkers(m([{ after: "t1", label: "x" }])).join(" "), /names t1, a card: a marker follows a clip/); // The shape too, for the lint, which does not run validateChrome. - assert.match(validateDeckMarkers(m([{ after: "c2" }])).join(" "), /label must be a word or two/); + assert.match(validateDeckMarkers(m([{ after: "c2", label: ["x"] }])).join(" "), /label must be a word or two/); + assert.deepEqual(validateDeckMarkers(m([{ after: "c2" }])), []); assert.match(validatorErrors(m([{ after: "zz", label: "x" }])).join(" "), /not in the timeline/); // Without the deck, or without markers, nothing to say. assert.deepEqual(validateDeckMarkers({ timeline: ENTRIES, render: BASE }), []); diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs @@ -152,7 +152,8 @@ export function validateChrome(chrome, render = {}) { // absent, nothing about the deck changes. So are `claims` (claims.mjs: // his words against the record, drawn on the rail) and `counter` // (counter.mjs: the tally's named series). - unknownKeys(d, [...Object.keys(DECK_DEFAULTS), "finale", "claims", "counter"], w, errors); + // `rail` (rail.mjs: `{labels}`) likewise has no default to fill. + unknownKeys(d, [...Object.keys(DECK_DEFAULTS), "finale", "claims", "counter", "rail"], w, errors); deckChecked = true; } errors.push(...entry.validate(settingValue(chrome, entry), { render, chrome, deck: d, where: w })); @@ -442,8 +443,9 @@ export function deckLayout(render, { tally = null, schedule = null } = {}) { const padX = DECK_PAD_X; // The markers' labels (`deck.markers`) stand in a band above the track: the // track moves down by it, and only when there is a marker to label, so a - // deck without them lays out as it always did. - const marked = Array.isArray(d.markers) && d.markers.length > 0; + // deck without them lays out as it always did -- nor one whose markers are + // all unlabelled (or `rail.labels: false`): ticks need no band. + const marked = labelledMarkers(d).length > 0; const rows = marked && schedule ? markerRowsOf(schedule, render) : 1; const markerBand = marked ? MARKER_BAND + (rows > 1 ? MARKER_ROW : 0) : 0; // A goalpost's words (`deck.claims`, claims.mjs) stand in a row of their @@ -551,6 +553,15 @@ const hasGoalpost = (d) => Array.isArray(d.claims) && d.claims.some((c) => isObj /** How far the track moves down to make room for the markers' labels. */ export const MARKER_BAND = 22; +/** + * The resolved deck's markers that draw words: those with a label, none when + * `rail.labels` is false. An unlabelled marker is a tick at its boundary. + */ +export function labelledMarkers(d) { + if (!Array.isArray(d?.markers) || d.rail?.labels === false) return []; + return d.markers.filter((m) => String(m?.label ?? "").trim()); +} + /** How much taller the band is when the labels stagger into a second row. */ export const MARKER_ROW = 22; @@ -618,7 +629,7 @@ function labelBoxes(row, W, walls = []) { */ export function markerRowsOf(schedule, render) { const d = resolveDeck(render); - if (!Array.isArray(d.markers) || !d.markers.length) return 1; + if (!labelledMarkers(d).length) return 1; const lay = deckLayout(render); const pipped = pipSegments(schedule); const xs = pipXs( @@ -647,6 +658,10 @@ export function markerRowsOf(schedule, render) { * as in one row. `row` and `align` are on a marker only when they say * something (staggered; not "auto"). * + * An unlabelled marker (no `label`, or `rail.labels: false`) has `label` "" + * and the empty box `[x, x]`: the crowded-label layout ignores it, so it + * takes no room from a labelled neighbour. + * * `xs` are the pips' x (pipXs), `pipped` their segments (pipSegments). * * @returns {Array<{ after: string, label: string, color: string, k: number, x: number, box: [number, number], @@ -661,6 +676,7 @@ export function deckMarkers(schedule, render, xs, pipped, lay = deckLayout(rende const segs = schedule.segments ?? []; const D = schedule.transition ?? 0; const pipOf = new Map(pipped.map((s, k) => [s.id, k])); + const words = d.rail?.labels !== false; const placed = []; for (const m of markers) { const after = String(m?.after ?? "").trim(); @@ -678,17 +694,19 @@ export function deckMarkers(schedule, render, xs, pipped, lay = deckLayout(rende const key = m.color ?? MARKER_DEFAULT_COLOR; const color = HEX_RE.test(key) ? key : pal[key] ?? pal.fg ?? "#ffffff"; const align = MARKER_ALIGNS.includes(m.align) && m.align !== "auto" ? m.align : null; - placed.push({ after, label: String(m.label ?? "").trim(), color, k, x: Math.round(x * 100) / 100, ...(align ? { align } : {}) }); + placed.push({ after, label: words ? String(m.label ?? "").trim() : "", color, k, x: Math.round(x * 100) / 100, ...(align ? { align } : {}) }); } // The label boxes: each up to halfway to its neighbours, 360 px at most. - const order = placed.map((p, j) => j).sort((a, b) => placed[a].x - placed[b].x); + // The unlabelled are left out: an empty box at the flag. + const bare = (p) => ({ ...p, box: [Math.round(p.x), Math.round(p.x)] }); + const order = placed.map((p, j) => j).filter((j) => placed[j].label).sort((a, b) => placed[a].x - placed[b].x); const W = lay.width; const one = labelBoxes(order.map((j) => placed[j]), W); const boxOf = new Map(order.map((j, o) => [j, one[o]])); const need = placed.map((p) => markerLabelWidth(p.label)); const fits = (j, box) => need[j] <= box[1] - box[0]; if (d.markerLayout === "truncate" || order.every((j) => fits(j, boxOf.get(j)))) { - return placed.map((p, j) => ({ ...p, box: boxOf.get(j) })); + return placed.map((p, j) => (p.label ? { ...p, box: boxOf.get(j) } : bare(p))); } // Two rows: row 1's sticks reach up through row 0. Every split of the flags // between the rows is tried (there are at most MARKER_LIMITS.count) and the @@ -723,8 +741,33 @@ export function deckMarkers(schedule, render, xs, pipped, lay = deckLayout(rende } } // All in one row is no stagger: the one row as above. - if (best.ups === 0) return placed.map((p, j) => ({ ...p, box: boxOf.get(j) })); - return placed.map((p, j) => ({ ...p, ...best.at.get(j) })); + if (best.ups === 0) return placed.map((p, j) => (p.label ? { ...p, box: boxOf.get(j) } : bare(p))); + return placed.map((p, j) => (p.label ? { ...p, ...best.at.get(j) } : bare(p))); +} + +/** + * The rail's SECTIONS (`pip.color: "section"`): the stretch before the first + * marker, then one from each marker's boundary to the next. `placed` are + * deckMarkers' (each with the pip `k` it follows, its `x`, its resolved + * `color`); `n` the pips. Section 0 is `pip.sectionColor0` (a #hex or a + * palette key), else the accent; section i is its marker's colour. + * `pipSection[k]` is pip k's section -- the count of markers after a clip + * before it, so a marker's own pip closes the section before it -- and + * `bounds[i]` the x where section i+1 starts (non-decreasing). + * + * @returns {{ colors: string[], bounds: number[], pipSection: number[] }} + */ +export function railSections(placed, n, d, pal = {}) { + const key = d?.pip?.sectionColor0; + const first = typeof key === "string" && HEX_RE.test(key) ? key : (key && pal[key]) || pal.accent || "#ffffff"; + const ms = [...placed].sort((a, b) => a.k - b.k || a.x - b.x); + const bounds = []; + for (const m of ms) bounds.push(Math.max(m.x, bounds.at(-1) ?? -Infinity)); + return { + colors: [first, ...ms.map((m) => m.color)], + bounds, + pipSection: Array.from({ length: Math.max(0, n) }, (_, k) => ms.filter((m) => m.k < k).length), + }; } /** @@ -832,11 +875,16 @@ export function hidesDeck(entry, deck) { return deck.overCards === "hide" && CARD_TYPES.includes(entry.type); } +/** Two titles the same, but for case and the space around them. */ +const sameTitle = (a, b) => String(a ?? "").trim().toLowerCase() === String(b ?? "").trim().toLowerCase(); + /** * The deck's title and subtitle for one entry. Pure: the caller resolves `meta`. * With `subtitle.lines: 2`, a clip's or a still's automatic subtitle comes in * its two lines too (`subtitleLines`, deckSubtitleLines) -- never an entry's - * own `onscreen.subtitle`, which is the one line its author typed. + * own `onscreen.subtitle`, which is the one line its author typed. A clip's + * `onscreen.title` that only repeats its source's title (sameTitle) is + * dropped when the two lines show that title. */ export function deckText(entry, meta, provenance, deck, multiChannel) { const o = entry.onscreen ?? {}; @@ -849,6 +897,10 @@ export function deckText(entry, meta, provenance, deck, multiChannel) { const parts = attributionParts(entry, meta ?? {}, provenance); subtitle = deckSubtitle(parts, deck.subtitle, multiChannel); if (two) subtitleLines = deckSubtitleLines(parts, deck.subtitle, multiChannel); + // Two lines already name the source: an on-screen title that only + // repeats it is not drawn again over them (the block takes the + // title's band, as for a clip with none). A different one stands. + if (subtitleLines && title && sameTitle(title, parts.title) && subtitleLines.some((l) => l.includes(String(parts.title).trim()))) title = ""; } else if (entry.type === "teaser") { // The deck is never up over a teaser; its words are what a table of // the cut (umtool's On-screen rows, the schedule) names it by. diff --git a/umtool/report-to-video/modules/rail.mjs b/umtool/report-to-video/modules/rail.mjs @@ -13,6 +13,14 @@ // frame keys then reuse those frames). The pips the cut has not reached // are not drawn until the fuse sets off toward them. A cut with more pips // than the track holds at that pitch lays them at the pitch that fits. +// +// `pip.color: "section"`: the rail in SECTIONS -- from one marker's boundary +// to the next, in that marker's colour (before the first, `pip.sectionColor0`, +// else the accent). Every pip (dim until lit), the fuse (a bar per section) +// and the marker's ring take their section's colour, fitted to 3:1 on the +// deck's ground. A marker may have no label: a tick at its boundary, no +// words, and no band over the track for it; `rail.labels: false` drops every +// marker's words. import { DECK_DEFAULTS, MARKER_ALIGNS, MARKER_LAYOUTS, PIP_COLORS, PIP_PITCH, PIP_PITCH_DEFAULT, PIP_SPACINGS, settingsOf } from "./settings.mjs"; import { defineModule } from "./contract.mjs"; @@ -26,7 +34,7 @@ export default defineModule({ title: "Rail", summary: "The deck's pip track: a pip per clip, the marker, the fuse, and the markers' flags.", configKey: "render.chrome.deck.pip", - configKeys: ["render.chrome.deck.markers", "render.chrome.deck.markerLayout"], + configKeys: ["render.chrome.deck.markers", "render.chrome.deck.markerLayout", "render.chrome.deck.rail"], defaults: { pip: DECK_DEFAULTS.pip, markers: DECK_DEFAULTS.markers, markerLayout: DECK_DEFAULTS.markerLayout }, provides: ["rail.layout"], validate: settingsOf("rail").validate, @@ -37,6 +45,8 @@ export default defineModule({ pip: pip.spacing === "pitch" ? { ...pip, pitch: pip.pitch ?? PIP_PITCH_DEFAULT } : pip, markers: d.markers ?? DECK_DEFAULTS.markers, markerLayout: d.markerLayout ?? DECK_DEFAULTS.markerLayout, + // Only when set: a deck without it resolves as it did. + ...(d.rail !== undefined ? { rail: d.rail } : {}), }; }, ui: [ @@ -45,8 +55,10 @@ export default defineModule({ { key: "pip.size", type: "number", min: 2, max: 24, label: "Pip size", default: 6 }, { key: "pip.activeSize", type: "number", min: 2, max: 40, label: "Marker size", default: 12 }, { key: "pip.color", type: "enum", options: PIP_COLORS, label: "Lit pip colour", default: "accent" }, - { key: "markers", type: "markers", label: "Markers", align: MARKER_ALIGNS }, + { key: "pip.sectionColor0", type: "color", label: "First section's colour", default: "accent", when: { "pip.color": "section" } }, + { key: "markers", type: "markers", label: "Markers (label optional; colour = its section's)", align: MARKER_ALIGNS }, { key: "markerLayout", type: "enum", options: MARKER_LAYOUTS, label: "Crowded labels", default: "stagger" }, + { key: "rail.labels", type: "boolean", label: "Markers' words", default: true }, ], docs: { heading: "Rail", @@ -55,7 +67,10 @@ export default defineModule({ ["`deck.pip.spacing`", "`even` · `time` (each pip at its clip's middle) · `pitch` (each `pip.pitch` px after the last, from the left; the pips not yet reached are not drawn, so an insert keeps the frames before it) · default `even`", "`umtool look <p> deck.pip='{\"spacing\":\"pitch\",\"pitch\":24}'`"], ["`deck.pip.pitch`", `${PIP_PITCH[0]}–${PIP_PITCH[1]} px · default ${PIP_PITCH_DEFAULT} (only with \`spacing: "pitch"\`; a cut with more pips than the track holds at it is laid at the pitch that fits)`, "same"], ["`deck.pip.size`, `deck.pip.activeSize`", "2–24 · 2–40 px, the marker at least the pip · default 6, 12", "`umtool look <p> deck.pip='{\"size\":8}'`"], - ["`deck.pip.color`", "`accent` · `verdict` (a counted clip's pip takes its series' colour and shape) · default `accent`", "`umtool look <p> deck.pip='{\"color\":\"verdict\"}'`"], + ["`deck.pip.color`", "`accent` · `verdict` (a counted clip's pip takes its series' colour and shape) · `section` (every pip, the fuse and the marker's ring in the colour of the section it stands in: from one marker to the next, in that marker's `color`; fitted to 3:1 on the deck) · default `accent`", "`umtool look <p> deck.pip='{\"color\":\"verdict\"}'`"], + ["`deck.pip.sectionColor0`", "the section before the first marker, with `color: \"section\"`: a `#hex` or a palette key (`fg`, `muted`, `accent`, `amber`, `dim`) · default the accent", "`umtool look <p> deck.pip='{\"color\":\"section\",\"sectionColor0\":\"#5fa8d3\"}'`"], + ["`deck.markers[].label`", "optional: a marker with none (or `\"\"`) draws a tick at its boundary, no words, and takes no band over the track", "`umtool look <p> deck.markers='[{\"after\":\"c04\",\"color\":\"#e07a9a\"}]'`"], + ["`deck.rail.labels`", "`false` draws every marker as a tick, no words, and no band over the track · default `true`", "`umtool look <p> deck.rail='{\"labels\":false}'`"], ], }, }); diff --git a/umtool/report-to-video/modules/settings.mjs b/umtool/report-to-video/modules/settings.mjs @@ -70,7 +70,7 @@ export const DECK_DEFAULTS = Object.freeze({ // take the code's width. The clip's own deck QR (`qr`) is untouched. qr: true, }), - // Flags on the pip track: `[{ after, label, color?, align? }]`, each between + // Flags on the pip track: `[{ after, label?, color?, align? }]`, each between // the pip of the clip `after` names and the next, hidden until the fuse // reaches it (deckMarkers). An empty list is no flags, and the deck lays out // as it always did. @@ -82,8 +82,13 @@ export const DECK_DEFAULTS = Object.freeze({ markerLayout: "stagger", }); -/** The pip's colour when lit (`pip.color`): the deck's accent, or a claimed clip's verdict. */ -export const PIP_COLORS = Object.freeze(["accent", "verdict"]); +/** + * The pip's colour when lit (`pip.color`): the deck's accent, a claimed clip's + * verdict, or its SECTION's -- the stretch of the rail from one marker to the + * next, in that marker's colour (before the first, `pip.sectionColor0`, else + * the accent); the fuse and the marker's ring take it too (deck.mjs railSections). + */ +export const PIP_COLORS = Object.freeze(["accent", "verdict", "section"]); /** A marker's limits: how many, and a label's characters. */ export const MARKER_LIMITS = Object.freeze({ count: 12, label: 24 }); @@ -155,6 +160,9 @@ function sub(d, key, allowed, w, errors, check) { const HEX_RE = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/; +/** A marker's (or a section's) `color`: a #hex, or a palette key. */ +const isMarkerColor = (c) => typeof c === "string" && (HEX_RE.test(c) || MARKER_PALETTE_KEYS.includes(c)); + /** * Every reason a `deck.markers` list cannot be drawn, its shape alone (the * timeline is not in `render.chrome`: `validateDeckMarkers` checks `after` @@ -164,12 +172,12 @@ const HEX_RE = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/; */ export function markerShapeErrors(markers, where) { if (markers === undefined) return []; - if (!Array.isArray(markers)) return [`${where} must be a list of { after, label, color? }`]; + if (!Array.isArray(markers)) return [`${where} must be a list of { after, label?, color? }`]; const errors = []; if (markers.length > MARKER_LIMITS.count) errors.push(`${where} has ${markers.length} markers (at most ${MARKER_LIMITS.count})`); markers.forEach((m, i) => { const at = `${where}[${i}]`; - if (!isObj(m)) { errors.push(`${at} must be { after, label, color? }`); return; } + if (!isObj(m)) { errors.push(`${at} must be { after, label?, color? }`); return; } for (const k of Object.keys(m)) { if (!["after", "label", "color", "align"].includes(k)) errors.push(`${at}.${k} is not a marker setting (after, label, color, align)`); } @@ -177,13 +185,16 @@ export function markerShapeErrors(markers, where) { errors.push(`${at}.align must be ${MARKER_ALIGNS.map((a) => `"${a}"`).join(", ")}`); } if (typeof m.after !== "string" || !m.after.trim()) errors.push(`${at}.after must name a clip's id`); + // No label (absent, or "") is a marker with no words: a tick at the + // boundary, and with `pip.color: "section"` the colour that changes there. const label = typeof m.label === "string" ? m.label.trim() : ""; - if (!label) errors.push(`${at}.label must be a word or two`); + if (m.label !== undefined && typeof m.label !== "string") errors.push(`${at}.label must be a word or two (or "" for none)`); + else if (!label) { /* unlabelled */ } else if (/[\r\n]/.test(label)) errors.push(`${at}.label must be one line`); else if ([...label].length > MARKER_LIMITS.label) { errors.push(`${at}.label is ${[...label].length} characters (at most ${MARKER_LIMITS.label})`); } - if (m.color !== undefined && !(typeof m.color === "string" && (HEX_RE.test(m.color) || MARKER_PALETTE_KEYS.includes(m.color)))) { + if (m.color !== undefined && !isMarkerColor(m.color)) { errors.push(`${at}.color must be a #hex colour or one of ${MARKER_PALETTE_KEYS.join(", ")}`); } }); @@ -230,7 +241,7 @@ export function validateShellSettings(d, { where: w }) { /** The rail: the pips, the markers and how crowded labels lay. */ export function validateRailSettings(d, { where: w }) { const errors = []; - sub(d, "pip", ["spacing", "size", "activeSize", "color", "pitch"], w, errors, (p) => { + sub(d, "pip", ["spacing", "size", "activeSize", "color", "pitch", "sectionColor0"], w, errors, (p) => { if (p.spacing !== undefined && !PIP_SPACINGS.includes(p.spacing)) { errors.push(`${w}.pip.spacing must be "even", "time" or "pitch"`); } @@ -244,6 +255,9 @@ export function validateRailSettings(d, { where: w }) { if (p.pitch !== undefined && !numIn(p.pitch, PIP_PITCH[0], PIP_PITCH[1])) { errors.push(`${w}.pip.pitch must be from ${PIP_PITCH[0]} to ${PIP_PITCH[1]} pixels`); } + if (p.sectionColor0 !== undefined && !isMarkerColor(p.sectionColor0)) { + errors.push(`${w}.pip.sectionColor0 must be a #hex colour or one of ${MARKER_PALETTE_KEYS.join(", ")}`); + } const size = p.size ?? DECK_DEFAULTS.pip.size; const active = p.activeSize ?? DECK_DEFAULTS.pip.activeSize; if (numIn(size, 2, 24) && numIn(active, 2, 40) && active < size) { @@ -251,6 +265,10 @@ export function validateRailSettings(d, { where: w }) { } }); errors.push(...markerShapeErrors(d.markers, `${w}.markers`)); + // `rail.labels: false` draws no marker's words: the flags (or ticks) alone. + sub(d, "rail", ["labels"], w, errors, (r) => { + if (r.labels !== undefined && typeof r.labels !== "boolean") errors.push(`${w}.rail.labels must be true or false`); + }); if (d.markerLayout !== undefined && !MARKER_LAYOUTS.includes(d.markerLayout)) { errors.push(`${w}.markerLayout must be ${MARKER_LAYOUTS.map((l) => `"${l}"`).join(" or ")}`); } diff --git a/umtool/report-to-video/rail-sections.test.mjs b/umtool/report-to-video/rail-sections.test.mjs @@ -0,0 +1,183 @@ +// The rail in sections (`deck.pip.color: "section"`), unlabelled markers, +// `deck.rail.labels: false`, and the two-line subtitle's title dedupe. +// +// Run with: pnpm test:scripts +import assert from "node:assert/strict"; +import test from "node:test"; + +import { + deckLayout, deckMarkers, deckSchedule, deckText, labelledMarkers, markerRowsOf, pipSegments, pipXs, railSections, + resolveDeck, validateChrome, +} from "./deck.mjs"; +import { deckCues, deckHtml, fitSectionColor, sectionFuses } from "./chrome-deck.mjs"; +import { contrast } from "./chrome-intro.mjs"; +import rail from "./modules/rail.mjs"; + +const PALETTE = { bg: "#12100c", fg: "#f6f1e6", muted: "#a2957f", accent: "#c8752a", amber: "#ffc860" }; +const CHROME = { engine: "hyperframes", layout: "deck" }; +const BASE = { width: 1920, height: 1080, fps: 30, transition: 0.5, palette: PALETTE }; +const renderWith = (deck = {}) => ({ ...BASE, chrome: { ...CHROME, deck } }); +const PROV = { siteOrigin: "https://example.test", channelSlug: "chan" }; +const N = 8; +const ENTRIES = Array.from({ length: N }, (_, i) => ({ id: `c${i}`, type: "clip", video: `v${i}`, start: 0, end: 10 })); +const DURS = ENTRIES.map(() => 10); +const sched = (render) => deckSchedule({ entries: ENTRIES, durs: DURS, D: 0.5, render, provenance: PROV }); +const SECTIONED = (extra = {}) => renderWith({ + pip: { color: "section", ...extra }, + markers: [{ after: "c2", color: "#e07a9a" }, { after: "c5", color: "#5fa8d3" }], +}); + +test("settings: section colour, unlabelled markers and rail.labels validate; bad values refused in words", () => { + const ok = (deck) => validateChrome({ ...CHROME, deck }, BASE); + assert.deepEqual(ok({ pip: { color: "section", sectionColor0: "#9a8fd6" }, markers: [{ after: "c2" }, { after: "c4", label: "" }] }), []); + assert.deepEqual(ok({ pip: { color: "section", sectionColor0: "amber" } }), []); + assert.deepEqual(ok({ rail: { labels: false } }), []); + assert.match(ok({ pip: { sectionColor0: "pink" } }).join(" "), /pip\.sectionColor0 must be a #hex colour/); + assert.match(ok({ pip: { color: "rainbow" } }).join(" "), /pip\.color must be "accent" or "verdict" or "section"/); + assert.match(ok({ rail: { labels: "no" } }).join(" "), /rail\.labels must be true or false/); + assert.match(ok({ rail: { words: false } }).join(" "), /rail\.words is not a deck setting/); + // The module's descriptors carry the new keys. + const keys = rail.ui.map((u) => u.key); + for (const k of ["pip.sectionColor0", "rail.labels"]) assert.ok(keys.includes(k), k); + assert.ok(rail.ui.find((u) => u.key === "pip.color").options.includes("section")); + assert.deepEqual(rail.resolve(renderWith({})).rail, undefined, "no rail key unless set"); + assert.deepEqual(rail.resolve(renderWith({ rail: { labels: false } })).rail, { labels: false }); +}); + +test("railSections: the stretch before the first marker, then marker to marker; a marker's own pip closes the section before it", () => { + const placed = [{ k: 5, x: 900, color: "#5fa8d3" }, { k: 2, x: 400, color: "#e07a9a" }]; + const s = railSections(placed, 8, { pip: {} }, PALETTE); + assert.deepEqual(s.colors, [PALETTE.accent, "#e07a9a", "#5fa8d3"]); + assert.deepEqual(s.bounds, [400, 900]); + assert.deepEqual(s.pipSection, [0, 0, 0, 1, 1, 1, 2, 2]); + // sectionColor0: a hex, or a palette key. + assert.equal(railSections(placed, 8, { pip: { sectionColor0: "#123456" } }, PALETTE).colors[0], "#123456"); + assert.equal(railSections(placed, 8, { pip: { sectionColor0: "amber" } }, PALETTE).colors[0], PALETTE.amber); + // No markers: one section, every pip in it. + assert.deepEqual(railSections([], 3, { pip: {} }, PALETTE), { colors: [PALETTE.accent], bounds: [], pipSection: [0, 0, 0] }); + // A marker after the last clip opens a section with no pip; two after one clip, an empty one between. + const edge = railSections([{ k: 2, x: 500, color: "#111111" }, { k: 2, x: 500, color: "#222222" }, { k: 7, x: 1800, color: "#333333" }], 8, { pip: {} }, PALETTE); + assert.deepEqual(edge.pipSection, [0, 0, 0, 2, 2, 2, 2, 2]); + assert.deepEqual(edge.bounds, [500, 500, 1800]); +}); + +test("sectionFuses: a bar per section with any of the fuse's span, empty ones dropped", () => { + const s = { colors: ["#a", "#b", "#c", "#d"], bounds: [400, 400, 900] }; + assert.deepEqual(sectionFuses(s, 48, 1872).map((f) => [f.k, f.x0, f.x1]), [["fz0", 48, 400], ["fz2", 400, 900], ["fz3", 900, 1872]]); + // A boundary past the fuse's end (a marker after the last clip): its section has no bar. + assert.deepEqual(sectionFuses({ colors: ["#a", "#b"], bounds: [1880] }, 48, 1872).map((f) => f.k), ["fz0"]); +}); + +test("the deck in sections: pips, fuse bars and the marker's rings take their section's colour; the burn is the one fuse's, split", () => { + const r = SECTIONED(); + const s = sched(r); + const c = deckCues(s, r); + assert.deepEqual(c.pips.map((p) => p.section), [0, 0, 0, 1, 1, 1, 2, 2]); + assert.equal(c.init.fuse, undefined, "no single fuse in sections"); + assert.deepEqual(c.sections.fuses.map((f) => f.k), ["fz0", "fz1", "fz2"]); + assert.deepEqual(c.sections.rings, [0, 1, 2]); + assert.deepEqual(c.init.mr0, { opacity: 1 }); + assert.deepEqual(c.init.mr1, { opacity: 0 }); + // Every bar ends burnt through but the last's share past the last pip (none here: even spacing ends on it). + const last = (k) => c.cues.filter((q) => q.k === k).at(-1)?.to.scaleX; + assert.equal(last("fz0"), 1); + assert.equal(last("fz1"), 1); + assert.equal(last("fz2"), 1); + // The burns are in time order and never overlap on one bar; the section 0 bar + // finishes when the fuse crosses the first boundary, as the marker flag pops. + for (const k of ["fz0", "fz1", "fz2"]) { + const cs = c.cues.filter((q) => q.k === k); + for (let i = 1; i < cs.length; i += 1) assert.ok(cs[i].at >= cs[i - 1].at + cs[i - 1].dur - 1e-6, `${k} cue ${i}`); + } + const fz0End = c.cues.filter((q) => q.k === "fz0").at(-1); + const mk0 = c.markers[0]; + assert.ok(Math.abs(fz0End.at + fz0End.dur - mk0.at) < 0.05, `${fz0End.at + fz0End.dur} vs ${mk0.at}`); + // The rings switch once per section change, in order. + const ringCues = c.cues.filter((q) => /^mr\d$/.test(q.k)); + assert.deepEqual(ringCues.map((q) => `${q.k}:${q.to.opacity}`), ["mr0:0", "mr1:1", "mr1:0", "mr2:1"]); + const html = deckHtml(s, r, {}); + const cols = c.sections.colors.map((x) => fitSectionColor(x, "#000000")); + assert.equal(cols.length, 3); + assert.match(html, /<div class="fuse fz" data-k="fz1" style="left:[\d.]+px; width:[\d.]+px; background:#e07a9a"><\/div>/); + assert.match(html, /<div class="pip lit" data-k="pip3" style="left:[\d.]+px; background:#e07a9a"><\/div>/); + assert.match(html, /<div class="pip lit" data-k="pip7" style="left:[\d.]+px; background:#5fa8d3"><\/div>/); + assert.match(html, /<div class="marker sec" data-k="marker"><div class="mring" data-k="mr0"/); + assert.doesNotMatch(html, /data-k="fuse"/); + // Unlabelled markers: ticks, in the colour of the section each opens; no band. + assert.match(html, /<div class="mflag bare" data-k="mk0" data-after="c2" style="left:[\d.]+px; --mc:#e07a9a"><div class="mtick"><\/div><\/div>/); + assert.doesNotMatch(html, /class="mlabel"/); + assert.equal(deckLayout(r, { schedule: s }).markerBand, undefined); + assert.equal(deckLayout(r, { schedule: s }).pipTrack.y, deckLayout(renderWith({}), { schedule: s }).pipTrack.y); +}); + +test("a section colour too dark for the deck is lifted to 3:1; one that reads is kept", () => { + const ground = "#1d1a15"; + assert.equal(fitSectionColor("#5fa8d3", ground), "#5fa8d3"); + const lifted = fitSectionColor("#202020", ground); + assert.notEqual(lifted, "#202020"); + assert.ok(contrast(lifted, ground) >= 3); + assert.equal(fitSectionColor("#abc", "#000000"), "#aabbcc"); + // In the page: a dark marker colour is drawn lifted. + const r = renderWith({ pip: { color: "section" }, markers: [{ after: "c3", color: "#151515" }] }); + const html = deckHtml(sched(r), r, {}); + assert.doesNotMatch(html, /background:#151515/); +}); + +test("unlabelled markers take no label room; a labelled neighbour lays as if they were not there", () => { + const withBare = renderWith({ markers: [{ after: "c1", label: "Opening chapter" }, { after: "c2" }, { after: "c3", label: "Closing" }] }); + const without = renderWith({ markers: [{ after: "c1", label: "Opening chapter" }, { after: "c3", label: "Closing" }] }); + const go = (r) => { + const s = sched(r); + const l = deckLayout(r, { schedule: s }); + const pipped = pipSegments(s); + return { l, ms: deckMarkers(s, r, pipXs(pipped.length, l.pipTrack.x0, l.pipTrack.x1, "even"), pipped, l) }; + }; + const a = go(withBare), b = go(without); + assert.deepEqual(a.ms.filter((m) => m.label).map((m) => m.box), b.ms.map((m) => m.box)); + const bare = a.ms.find((m) => m.after === "c2"); + assert.equal(bare.label, ""); + assert.deepEqual(bare.box, [Math.round(bare.x), Math.round(bare.x)]); + assert.equal(bare.row, undefined); + assert.deepEqual(a.l.markerBand, b.l.markerBand); +}); + +test("rail.labels: false -- every marker a tick, no band, the track where a deck without markers has it", () => { + const r = renderWith({ rail: { labels: false }, markers: [{ after: "c1", label: "One" }, { after: "c4", label: "Two" }] }); + const s = sched(r); + assert.deepEqual(labelledMarkers(resolveDeck(r)), []); + assert.equal(markerRowsOf(s, r), 1); + const l = deckLayout(r, { schedule: s }); + assert.equal(l.markerBand, undefined); + assert.equal(l.pipTrack.y, deckLayout(renderWith({}), { schedule: s }).pipTrack.y); + const html = deckHtml(s, r, {}); + assert.equal((html.match(/class="mflag bare"/g) ?? []).length, 2); + assert.doesNotMatch(html, />One</); +}); + +test("defaults unchanged: a deck without the new keys draws no section, tick or ring", () => { + const r = renderWith({ markers: [{ after: "c2", label: "Two" }] }); + const s = sched(r); + const c = deckCues(s, r); + assert.equal(c.sections, undefined); + assert.equal(c.pips[0].section, undefined); + assert.deepEqual(c.init.fuse, { scaleX: 0, transformOrigin: "0% 50%" }); + const html = deckHtml(s, r, {}); + for (const re of [/mring/, /mtick/, /fuse fz/, /marker sec/]) assert.doesNotMatch(html, re); + assert.match(html, /<div class="marker" data-k="marker"><\/div>/); +}); + +test("subtitle.lines 2: an on-screen title that repeats the source's title is not drawn twice; a different one stands", () => { + const deck = resolveDeck(renderWith({ subtitle: { lines: 2 } })); + const meta = { title: "Why I Use A Voice Changer", uploadDate: "20261020" }; + const clip = (title) => ({ id: "a", type: "clip", video: "v", start: 0, end: 5, ...(title !== undefined ? { onscreen: { title } } : {}) }); + const same = deckText(clip(" why i use a voice changer "), meta, PROV, deck, false); + assert.equal(same.title, ""); + assert.deepEqual(same.subtitleLines, ["Why I Use A Voice Changer", "Oct 20, 2026"]); + assert.equal(deckText(clip("She explains the voice"), meta, PROV, deck, false).title, "She explains the voice"); + // One line: the title stays, as it always did. + const one = resolveDeck(renderWith({})); + assert.equal(deckText(clip("Why I Use A Voice Changer"), meta, PROV, one, false).title, "Why I Use A Voice Changer"); + // Two lines whose head leaves the title out (subtitle.parts without it): kept. + const noTitle = resolveDeck(renderWith({ subtitle: { lines: 2, parts: ["channel", "date"], head: ["channel"] } })); + assert.equal(deckText(clip("Why I Use A Voice Changer"), meta, { ...PROV, channelName: "Ember" }, noTitle, true).title, "Why I Use A Voice Changer"); +});