Archilyzer · Source

archilyzer

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

commit 1173d01f9a50f6e7bac324163d691998f4cc8955
parent 5b2de5c1bc1bd7a5c85da6fe87b79ab49b924d25
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri,  6 Nov 2026 01:23:28 -0500

umtool: the measure extras move clear of post items' cards and chapter bands

rev9-base (6 Nov): during a post item the promise clock covered the card's
author line and the streak strip its foot (~600 s); at an act start the
lower chapter band ran into the diet badge (~72.5 s).

- deck.mjs postCovers: with a measure slice the deck schedule carries
  `covers` -- each post item's card, slot and strip as post-item.mjs
  postLayout lays them in the post box (the footage box the segment is
  framed in; the cut's panel rule on: the layout the card page draws, the
  one check-joins' cardRegion reads), over its segment's span.
- chrome-story.mjs chapterCover: the band a chapter bumper covers (the lower
  band, CHAPTER_LOWER_HEIGHT, or the whole footage box for a card).
- measure-extras.mjs measurePlacements: one pure answer for all five. While
  a cover is up where a module stands, `onPosts` / `onChapters` (new, each
  module's; default "dodge") move it to the first free anchor of the footage
  box in its preference order, a size down (1 → 0.5) if it must, never onto
  another measure extra that is up then -- or hide it when nothing fits;
  "hide" hides, "show" stays. Each module's region is its home and every
  slot it moves to; its page wraps its box in a mover `mv` driven by one step
  function (moverSteps: overlapping covers -- two post items crossfading, a
  band inside a post -- hide wins, else the latest).

Proven on a scratch copy of rev9-base (its schedule with covers added):
shots/dodge-post-600.png (diet a size down beside the card, the clock and
the streak hidden), dodge-post-575.png, dodge-chapter-72.5.png (diet and
streak lifted clear of the band).

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

Diffstat:
Mumtool/docs/knobs.md | 5+++++
Mumtool/report-to-video/chrome-measure-extras.mjs | 92++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
Mumtool/report-to-video/chrome-story.mjs | 17++++++++++++++++-
Mumtool/report-to-video/deck.mjs | 31++++++++++++++++++++++++++++++-
Mumtool/report-to-video/measure-extras.mjs | 153++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mumtool/report-to-video/measure-extras.test.mjs | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Mumtool/report-to-video/modules/measure-extras-module.mjs | 17+++++++++++++----
Mumtool/report-to-video/modules/measure-extras-settings.mjs | 12+++++++++++-
8 files changed, 371 insertions(+), 20 deletions(-)

diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -1745,6 +1745,7 @@ A chain per run along a time axis by in-record date (`render.chrome.deck.streak` | `deck.streak.position`, `.x`/`.y`, `.scale` | an anchor in the footage box · design px · 0.5–2 · default `bottom-center`, unset, 1 | `umtool look <p> deck.streak.position=bottom-left` | | `deck.streak.hold`, `.finale` | 0 (up from the first run on) or 2–600 s · `hide` `show` · default 0, `hide` | `umtool look <p> deck.streak.hold=15` | | `deck.streak.title`, `.color`, `.colors`, `.labels` | ≤40 · #hex · `{<regime>: #hex}` · `{<regime>: words}` · default the source's word, the accent, the regimes' inks and names | `umtool look <p> deck.streak.title='Every diet'` | +| `deck.streak.onPosts`, `.onChapters` | `dodge` `hide` `show` · default `dodge`: while a post item's card (its card, slot and strip as postLayout lays them: the schedule's `covers`) or a chapter band is up where it stands, it moves to a free anchor of the footage box -- a size down to half if it must, never onto another measure extra that is up -- and hides when none fits; `hide` hides, `show` stays over it | `umtool look <p> deck.streak.onPosts=hide` | ### Diet badge @@ -1756,6 +1757,7 @@ The diet he names as a rubber stamp in a corner of the footage box (`render.chro | `deck.diet.position`, `.x`/`.y`, `.scale` | an anchor in the footage box · design px · 0.5–2 · default `bottom-left`, unset, 1 | `umtool look <p> deck.diet.position=top-right` | | `deck.diet.hold`, `.finale` | 0 (up from the first diet on) or 2–600 s · `hide` `show` · default 0, `hide` | `umtool look <p> deck.diet.hold=15` | | `deck.diet.colors`, `.labels` | `{<regime>: #hex}` · `{<regime>: words ≤40}` · default the regimes' inks and names | `umtool look <p> deck.diet.labels='{"glp1":"Ozempic"}'` | +| `deck.diet.onPosts`, `.onChapters` | `dodge` `hide` `show` · default `dodge`: while a post item's card (its card, slot and strip as postLayout lays them: the schedule's `covers`) or a chapter band is up where it stands, it moves to a free anchor of the footage box -- a size down to half if it must, never onto another measure extra that is up -- and hides when none fits; `hide` hides, `show` stays over it | `umtool look <p> deck.diet.onPosts=hide` | ### Moving start @@ -1767,6 +1769,7 @@ The weight he says he started at, as he retells it (`render.chrome.deck.peak`, m | `deck.peak.position`, `.x`/`.y`, `.scale` | an anchor in the footage box · design px · 0.5–2 · default `top-right`, unset, 1 | `umtool look <p> deck.peak.scale=0.9` | | `deck.peak.hold`, `.finale` | 0 (stays up) or 2–600 s · `hide` `show` · default 12, `hide` | `umtool look <p> deck.peak.hold=0` | | `deck.peak.title`, `.values`, `.color` | ≤40 · `drift` `all` · #hex · default "The start keeps moving", `drift`, #FF5A4E | `umtool look <p> deck.peak.values=all` | +| `deck.peak.onPosts`, `.onChapters` | `dodge` `hide` `show` · default `dodge`: while a post item's card (its card, slot and strip as postLayout lays them: the schedule's `covers`) or a chapter band is up where it stands, it moves to a free anchor of the footage box -- a size down to half if it must, never onto another measure extra that is up -- and hides when none fits; `hide` hides, `show` stays over it | `umtool look <p> deck.peak.onPosts=hide` | ### Goal stack @@ -1778,6 +1781,7 @@ A sticky note per goal on a pile in a corner of the footage box, read off the sc | `deck.goals.position`, `.x`/`.y`, `.scale` | `top-left` `top-right` `bottom-left` `bottom-right` `top-center` `bottom-center` · design px · 0.5–2 · default `bottom-right`, unset, 1 | `umtool look <p> deck.goals.position=bottom-left` | | `deck.goals.max`, `.color`, `.countdown` | 1–8 notes · #hex paper · bool · default 4, the palette's amber, `true` | `umtool look <p> deck.goals.max=6` | | `deck.goals.hold`, `.finale` | 0 (up from the first goal on) or 2–600 s after each · `hide` `show` · default 20, `hide` | `umtool look <p> deck.goals.hold=0` | +| `deck.goals.onPosts`, `.onChapters` | `dodge` `hide` `show` · default `dodge`: while a post item's card (its card, slot and strip as postLayout lays them: the schedule's `covers`) or a chapter band is up where it stands, it moves to a free anchor of the footage box -- a size down to half if it must, never onto another measure extra that is up -- and hides when none fits; `hide` hides, `show` stays over it | `umtool look <p> deck.goals.onPosts=hide` | ### Thread rail @@ -1825,5 +1829,6 @@ A days-since counter for a promise (`render.chrome.deck.promise`, measure-extras | `deck.promise.hold`, `.finale` | 0 (stays up) or 2–600 s · `hide` `show` · default 0, `show` | `umtool look <p> deck.promise.finale=hide` | | `deck.promise.label`, `.verb`, `.kept`, `.broken`, `.checks` | ≤40 each · `label` `quote` · default the row's display, "offered", "Posted", "None posted", `label` | `umtool look <p> deck.promise.label='scale video'` | | `deck.promise.speakers`, `.claimVerb`, `.claimColor` | `{<speaker>: {handle, color}}` · ≤40 · #hex · default `{}` (the postAvatars handle), "paid", #E37AB8 | `umtool look <p> deck.promise.speakers='{"madamsavvy":{"handle":"MadamSavvy"}}'` | +| `deck.promise.onPosts`, `.onChapters` | `dodge` `hide` `show` · default `dodge`: while a post item's card (its card, slot and strip as postLayout lays them: the schedule's `covers`) or a chapter band is up where it stands, it moves to a free anchor of the footage box -- a size down to half if it must, never onto another measure extra that is up -- and hides when none fits; `hide` hides, `show` stays over it | `umtool look <p> deck.promise.onPosts=hide` | <!-- modules:end --> diff --git a/umtool/report-to-video/chrome-measure-extras.mjs b/umtool/report-to-video/chrome-measure-extras.mjs @@ -16,7 +16,7 @@ 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, - monthYear, peakStates, promiseStates, shortDate, streakStates, upSpans, weightText, + 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"; @@ -59,10 +59,82 @@ function stateCues(states, spans, { overlap = 0, own = () => [] } = {}, initExtr return compileCues(init, ev); } -const page = (id, schedule, opts, { geo, fps }, css, body, init, cues, ids) => cuePageHtml({ - id, W: geo.width, H: geo.height, fps, fonts: opts.fonts, gsapSrc: opts.gsap, css: `${displayFace(opts.fonts)}\n ${css}`, - body, init, cues, whole: { total: schedule.total, from: opts.from, duration: opts.duration, ids }, primeWindow: true, -}); +/** + * Where the mover stands over time: `[{ at, to: "home" | "hide" | { x, y, size } }]`, + * one step wherever that changes. Moves may overlap (a post item's span + * crossfades into the next one's, a chapter band rises inside a post): while + * any move that hides is on, it is hidden; else it stands where the latest + * move to start puts it; with none, at home. + */ +export function moverSteps(moves) { + const cuts = [...new Set(moves.flatMap((m) => [m.from, m.to]))].sort((a, b) => a - b); + const steps = []; + let was = "home"; + for (const at of cuts) { + const on = moves.filter((m) => m.from <= at + 1e-6 && m.to > at + 1e-6); + let to = "home"; + if (on.some((m) => !m.rect)) to = "hide"; + else if (on.length) { + const m = on.reduce((x, y) => (y.from >= x.from ? y : x)); + to = { x: m.rect.x, y: m.rect.y, size: m.size }; + } + if (JSON.stringify(to) !== JSON.stringify(was)) steps.push({ at, to }); + was = to; + } + return steps; +} + +/** + * The mover's cues (measure-extras.mjs measurePlacements, through + * moverSteps): the module's box `mv` slides to each slot clear of a post card + * or a chapter band (scaled from its corner) and back, or fades out and in + * when nothing fits -- each change over MEASURE_DODGE_MOVE, or half the time + * to the next. + */ +export function moverCues(place) { + const { home } = place; + const init = { mv: { x: 0, y: 0, scale: 1, autoAlpha: 1 } }; + const steps = moverSteps(place.moves); + const ev = []; + let alpha = 1; + let pos = { x: 0, y: 0, scale: 1 }; + steps.forEach((st, i) => { + const next = steps[i + 1]?.at ?? Infinity; + const d = Math.max(INSTANT, Math.min(MEASURE_DODGE_MOVE, (next - st.at) / 2)); + if (st.to === "hide") { + if (alpha !== 0) ev.push({ k: "mv", at: st.at, dur: d, to: { autoAlpha: 0 }, ease: "power1.in" }); + alpha = 0; + return; + } + const want = st.to === "home" ? { x: 0, y: 0, scale: 1 } : { x: st.to.x - home.x, y: st.to.y - home.y, scale: st.to.size }; + const moved = JSON.stringify(want) !== JSON.stringify(pos); + if (alpha === 0) { + // Hidden: put it in place at once, then fade it in there. + if (moved) ev.push({ k: "mv", at: st.at, dur: INSTANT, to: want, ease: "none" }); + ev.push({ k: "mv", at: st.at, dur: d, to: { autoAlpha: 1 }, ease: "power1.out" }); + } else if (moved) ev.push({ k: "mv", at: st.at, dur: d, to: want, ease: "power2.inOut" }); + alpha = 1; + pos = want; + }); + return compileCues(init, ev); +} + +/** + * 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]; + 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], + whole: { total: schedule.total, from: opts.from, duration: opts.duration, ids }, primeWindow: true, + }); +}; // --------------------------------------------------------------------------- // GOALS: the sticky notes. @@ -157,7 +229,7 @@ export function goalsHtml(schedule, render, opts = {}) { const body = `<div id="pn" data-k="pn"> ${blocks.join("\n ")} </div>`; - return { html: page("goals", schedule, opts, F, css, body, init, cues, states.map((_, j) => `s${j}`)), items }; + return { html: page("goals", schedule, opts, F, css, body, init, cues, states.map((_, j) => `s${j}`), render), items }; } // --------------------------------------------------------------------------- @@ -284,7 +356,7 @@ export function peakHtml(schedule, render, opts = {}) { ${marks.join("")} ${blocks.join("\n ")} </div>`; - return { html: page("peak", schedule, opts, F, css, body, init, cues, states.map((_, j) => `s${j}`)), items }; + return { html: page("peak", schedule, opts, F, css, body, init, cues, states.map((_, j) => `s${j}`), render), items }; } // --------------------------------------------------------------------------- @@ -416,7 +488,7 @@ export function promiseHtml(schedule, render, opts = {}) { 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}`)), items }; + return { html: page("promise", schedule, opts, F, css, body, init, cues, states.map((_, j) => `s${j}`), render), items }; } // --------------------------------------------------------------------------- @@ -498,7 +570,7 @@ export function dietHtml(schedule, render, opts = {}) { const body = `<div id="pn" data-k="pn"> ${blocks.join("\n ")} </div>`; - return { html: page("diet", schedule, opts, F, css, body, init, cues, states.map((_, j) => `s${j}`)), items }; + return { html: page("diet", schedule, opts, F, css, body, init, cues, states.map((_, j) => `s${j}`), render), items }; } // --------------------------------------------------------------------------- @@ -659,5 +731,5 @@ export function streakHtml(schedule, render, opts = {}) { ${chains} ${blocks.join("\n ")} </div>`; - return { html: page("streak", schedule, opts, F, css, body, allCues.init, allCues.cues, states.map((_, j) => `s${j}`)), items }; + return { html: page("streak", schedule, opts, F, css, body, allCues.init, allCues.cues, states.map((_, j) => `s${j}`), render), items }; } diff --git a/umtool/report-to-video/chrome-story.mjs b/umtool/report-to-video/chrome-story.mjs @@ -206,6 +206,21 @@ export function chapterGeometry(render, { feed = false } = {}) { return footageBox(render, { feed }); } +/** The lower chapter band's height, design px (1920 wide). */ +export const CHAPTER_LOWER_HEIGHT = 220; + +/** + * What a chapter bumper covers in the frame while it is up: the lower band + * across the footage box's foot (`style: "lower"`), else the whole footage + * box (the card). What the measure extras move clear of. + */ +export function chapterCover(render, { feed = false } = {}) { + const f = chapterGeometry(render, { feed }); + if (resolveChapter(render).style !== "lower") return { ...f }; + const h = pxOf(render)(CHAPTER_LOWER_HEIGHT); + return { x: f.x, y: f.y + f.height - h, width: f.width, height: h }; +} + /** One chapter window's page. `window` is the snapped `{ segment, from, to }`. */ export function chapterHtml(schedule, render, window, opts = {}) { const C = resolveChapter(render); @@ -225,7 +240,7 @@ export function chapterHtml(schedule, render, window, opts = {}) { const css = ` .chapter { position: absolute; visibility: hidden; opacity: 0; display: flex; flex-direction: column; ${lower - ? `left: 0; right: 0; bottom: 0; height: ${px(220)}px; padding: ${px(26)}px ${px(48)}px; justify-content: center; + ? `left: 0; right: 0; bottom: 0; height: ${px(CHAPTER_LOWER_HEIGHT)}px; padding: ${px(26)}px ${px(48)}px; justify-content: center; background: linear-gradient(to top, ${rgba(pal.bg, 0.94)}, ${rgba(pal.bg, 0.0)});` : `inset: 0; align-items: center; justify-content: center; text-align: center; padding: ${px(60)}px; background: ${rgba(pal.bg, 0.92)};`} } diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs @@ -23,7 +23,7 @@ import { COMPOSITION_PARAMS } from "yt-dlp-transcript-common/lib/report/fxParams import { INTRO_SECONDS } from "yt-dlp-transcript-common/lib/report/intro.mjs"; import { attributionParts, deckSubtitle, deckSubtitleLines, formatDeckDate } from "./attribution.mjs"; -import { postDeckText, postItemSeconds } from "./post-item.mjs"; +import { panelEntry, postDeckText, postItemSeconds, postLayout } from "./post-item.mjs"; import { videoDip, videoEnter, videoHidesChrome, videoSeconds } from "./video-entry.mjs"; import { claimOf, marksOf, originalUrlAt, resolveFactcheck, roundStamps, stampSchedule, stampsWithFinale, tallyOf, tallyVerdicts, validateFactcheck, @@ -1352,11 +1352,40 @@ export function deckSchedule({ doc, { words: measure.words ?? null, clock, gaps, asOf: measure.asOf ?? null }, ); + // Where each post item's card stands while it is up (postCovers): the + // measure extras move clear of it (measure-extras.mjs measurePlacements). + const covers = postCovers(entries, doc.segments, render, { feed: doc.layout === "feed" }); + if (covers.length) doc.covers = covers; } return doc; } /** + * The boxes each POST ITEM draws over the footage while it is up, in the + * frame: `[{ segment, from, to, rects: [{x, y, width, height}] }]` -- its card, + * and its attachments' slot and strip when it has them, as post-item.mjs + * postLayout lays them in the post box (the footage box the segment is framed + * in: build-video deckFraming; the feed's in a feed cut), with the cut's panel + * rule on (panelEntry) -- the layout the card page draws, the one check-joins' + * cardRegion reads. `from`/`to` the segment's span in the cut. + */ +export function postCovers(entries, segments, render, { feed = false } = {}) { + const box = feed ? feedGeometry(render).footage : deckGeometry(render).footage; + const r = (v) => Math.round(v); + const out = []; + entries.forEach((e, i) => { + const seg = segments[i]; + if (e?.type !== "post" || !seg || seg.id !== e.id) return; + const L = postLayout(panelEntry(e, render), { width: box.width, height: box.height }); + const rects = [L.card, L.slot, L.strip] + .filter((b) => b && [b.x, b.y, b.width, b.height].every(Number.isFinite)) + .map((b) => ({ x: r(box.x + b.x), y: r(box.y + b.y), width: r(b.width), height: r(b.height) })); + if (rects.length) out.push({ segment: e.id, from: seg.start, to: Math.round((seg.start + seg.duration) * 1000) / 1000, rects }); + }); + return out; +} + +/** * The deck's claim checks (`deck.claims`, claims.mjs) in the cut's clock: * `{ dates, items }`, or null when the deck carries none (or none in this * cut). THE arithmetic -- the build's schedule and umtool's preview both come diff --git a/umtool/report-to-video/measure-extras.mjs b/umtool/report-to-video/measure-extras.mjs @@ -26,7 +26,8 @@ // 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 { resolveMeasureExtra } from "./modules/measure-extras-settings.mjs"; +import { chapterCover, chapterWindows } from "./chrome-story.mjs"; +import { MEASURE_EXTRAS, MEASURE_POSITIONS, resolveMeasureExtra } from "./modules/measure-extras-settings.mjs"; const r4 = (v) => Math.round(v * 10000) / 10000; const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v); @@ -691,3 +692,153 @@ export function measureExtraGeometry(id, render, { feed = false } = {}) { y = Math.max(0, Math.min(g.H - height, Math.round(y))); return { x, y, width, height }; } + +// --------------------------------------------------------------------------- +// MOVING CLEAR: post items' cards and chapter bands. +// --------------------------------------------------------------------------- +// +// While a post item's card (the deck schedule's `covers`, deck.mjs postCovers: +// the card, slot and strip as postLayout lays them) or a chapter band +// (chrome-story.mjs chapterCover, over chapterWindows) is up where a module +// stands, the module moves to a slot clear of it -- the anchors of the footage +// box in its preference order, a size down if it must (MEASURE_DODGE_SCALES), +// never onto another measure module that is up then -- or hides when nothing +// fits (`onPosts` / `onChapters`: "dodge" | "hide" | "show"). One pure answer +// for all five, so two modules never dodge into one slot; each module's page +// and region read their own part of it. + +/** The sizes a dodging module may take, largest first; below the last it hides. */ +export const MEASURE_DODGE_SCALES = Object.freeze([1, 0.85, 0.7, 0.6, 0.5]); + +/** How long a module takes to move clear, and back. */ +export const MEASURE_DODGE_MOVE = 0.3; + +/** The order the five are placed in (the first takes a free slot first): the promise clock, then the rest. */ +const DODGE_ORDER = Object.freeze(["promise", "goals", "peak", "diet", "streak"]); + +const intersects = (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; +const within = (a, b) => a.x >= b.x && a.y >= b.y && a.x + a.width <= b.x + b.width && a.y + a.height <= b.y + b.height; +const overlapsSpan = (spans, from, to) => spans.some((sp) => sp.in < to - 1e-6 && sp.out > from + 1e-6); + +/** A module's box at an anchor of the footage box and a size (its own `scale` times `size`). */ +export function anchorRect(id, render, anchor, size = 1, { feed = false } = {}) { + const cfg = resolveMeasureExtra(id, render) ?? resolveMeasureExtra(id, { chrome: { deck: {} } }); + const g = deckGeometry(render); + const f = feed ? feedGeometry(render).footage : g.footage; + const k = (g.W / 1920) * (cfg.scale ?? 1) * size; + const box = MEASURE_BOXES[id]; + const width = Math.min(even(box.width * k), even(f.width)); + const height = Math.min(even(box.height * k), even(f.height)); + const inset = Math.round(24 * (g.W / 1920)); + const [v, h] = anchor.split("-"); + const x = h === "left" ? f.x + inset : h === "right" ? f.x + f.width - inset - width : f.x + (f.width - width) / 2; + const y = v === "top" ? f.y + inset : f.y + f.height - inset - height; + return { x: Math.round(x), y: Math.round(y), width, height }; +} + +/** The anchors a module tries when it moves: its own first, then the same edge, then the rest. */ +function anchorsFor(position) { + const [v] = position.split("-"); + const same = MEASURE_POSITIONS.filter((p) => p !== position && p.startsWith(v)); + const other = MEASURE_POSITIONS.filter((p) => p !== position && !p.startsWith(v)); + return [position, ...same, ...other]; +} + +/** When a module is up: its states' times through upSpans. */ +function upOf(id, schedule, render) { + const cfg = resolveMeasureExtra(id, render); + if (!cfg) return []; + const states = id === "goals" ? goalStates(schedule, render) + : id === "peak" ? peakStates(schedule, render) + : id === "promise" ? promiseStates(schedule, render) + : id === "diet" ? dietStates(schedule, render) + : streakStates(schedule, render).states; + return upSpans(states.map((s) => s.at), cfg, schedule); +} + +/** + * What covers the footage when: `[{ kind: "post" | "chapter", from, to, rects }]`, + * the post items' cards (the schedule's `covers`) and the chapter bands. + */ +export function measureCovers(schedule, render) { + const feed = schedule?.layout === "feed"; + const out = []; + for (const c of Array.isArray(schedule?.covers) ? schedule.covers : []) { + if (Number.isFinite(c?.from) && Number.isFinite(c?.to) && Array.isArray(c.rects) && c.rects.length) out.push({ kind: "post", from: c.from, to: c.to, rects: c.rects }); + } + const chapters = render?.chrome?.chapter ? chapterWindows(schedule, render) : []; + if (chapters.length) { + const band = chapterCover(render, { feed }); + for (const w of chapters) out.push({ kind: "chapter", from: w.from, to: w.to, rects: [band] }); + } + return out.sort((a, b) => a.from - b.from); +} + +/** + * Every measure module's placement over the cut: `{ [id]: { home, region, + * moves: [{ from, to, rect | null, size }] } }` -- `home` where it stands, + * each move a span it stands elsewhere (`rect` at `size`) or is hidden + * (`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) { + const feed = schedule?.layout === "feed"; + const covers = schedule ? measureCovers(schedule, render) : []; + const out = {}; + for (const id of MEASURE_EXTRAS) { + const home = measureExtraGeometry(id, render, { feed }); + out[id] = { home, region: home, moves: [], up: covers.length && schedule ? upOf(id, 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)); + // The modules that stay where they are take their homes first. + const taken = []; + const toMove = []; + for (const id of active) { + const cfg = resolveMeasureExtra(id, render); + const mode = c.kind === "post" ? cfg.onPosts : cfg.onChapters; + if (mode === "show" || !hit(out[id].home)) taken.push(out[id].home); + else toMove.push({ id, cfg, mode }); + } + const footage = feed ? feedGeometry(render).footage : deckGeometry(render).footage; + for (const { id, cfg, mode } of toMove) { + let move = null; + if (mode === "dodge") { + const pinned = Number.isFinite(cfg.x) && Number.isFinite(cfg.y); + const anchors = anchorsFor(pinned ? "top-left" : cfg.position); + search: for (const size of MEASURE_DODGE_SCALES) { + for (const a of anchors) { + const r = anchorRect(id, render, a, size, { feed }); + if (!within(r, footage) || hit(r) || taken.some((t) => intersects(t, r))) continue; + move = { from: c.from, to: c.to, rect: r, size }; + break search; + } + } + } + if (!move) move = { from: c.from, to: c.to, rect: null, size: 1 }; + else taken.push(move.rect); + out[id].moves.push(move); + } + } + for (const id of MEASURE_EXTRAS) { + const p = out[id]; + // Two moves that meet, to the same place: one. + const merged = []; + for (const m of p.moves.sort((a, b) => a.from - b.from)) { + const last = merged[merged.length - 1]; + const same = last && JSON.stringify(last.rect) === JSON.stringify(m.rect) && last.size === m.size; + if (same && m.from - last.to < MEASURE_DODGE_MOVE * 2 + 0.05) last.to = Math.max(last.to, m.to); + else merged.push({ ...m }); + } + p.moves = merged; + const rects = [p.home, ...merged.map((m) => m.rect).filter(Boolean)]; + 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)); + const y1 = Math.max(...rects.map((r) => r.y + r.height)); + p.region = { x: x0, y: y0, width: even(x1 - x0), height: even(y1 - y0) }; + delete p.up; + } + return out; +} diff --git a/umtool/report-to-video/measure-extras.test.mjs b/umtool/report-to-video/measure-extras.test.mjs @@ -9,12 +9,12 @@ import path from "node:path"; import test from "node:test"; import { fileURLToPath } from "node:url"; -import { goalsHtml, dietHtml, peakHtml, promiseHtml, spreadLabels, stampSize, streakHtml } from "./chrome-measure-extras.mjs"; +import { goalsHtml, dietHtml, moverCues, moverSteps, peakHtml, promiseHtml, spreadLabels, stampSize, streakHtml } from "./chrome-measure-extras.mjs"; import { cuePageHtml } from "./chrome-cues.mjs"; import { estimateSchedule, validateChrome } from "./deck.mjs"; import { frameKeys } from "./frame-keys.mjs"; import { - daysBetween, deadlineDate, dietRuns, dietStates, goalStates, goalText, lostRunsRuns, measureExtraGeometry, peakStates, pledgeRuns, + daysBetween, deadlineDate, dietRuns, dietStates, goalStates, goalText, lostRunsRuns, measureExtraGeometry, measurePlacements, peakStates, pledgeRuns, promiseStates, streakStates, upSpans, } from "./measure-extras.mjs"; import { deckOverlays, moduleById, moduleProblems, playModules, scheduleSlices } from "./modules/index.mjs"; @@ -290,3 +290,63 @@ test("a deck cut without a measure slice renders exactly as before: none of the assert.deepEqual(validateChrome(chrome, rest), []); } }); + +// --------------------------------------------------------------------------- +// Moving clear of post items' cards and chapter bands (rev 9 fixes, 6 Nov). +// --------------------------------------------------------------------------- + +test("postCovers: a post item's card (and slot) as postLayout lays it in the footage box, over its segment's span", async () => { + const { postCovers, deckGeometry } = await import("./deck.mjs"); + const { postLayout, panelEntry } = await import("./post-item.mjs"); + const post = { type: "post", id: "p1", platform: "x", author: { handle: "a", name: "A" }, date: "2026-10-23", text: "Ok I bought your coffee." }; + const covers = postCovers([{ type: "clip", id: "c1" }, post], [{ id: "c1", start: 0, duration: 5 }, { id: "p1", start: 4.6, duration: 9 }], RENDER); + assert.equal(covers.length, 1); + const f = deckGeometry(RENDER).footage; + const L = postLayout(panelEntry(post, RENDER), { width: f.width, height: f.height }); + assert.deepEqual(covers[0], { segment: "p1", from: 4.6, to: 13.6, rects: [{ x: f.x + L.card.x, y: f.y + L.card.y, width: L.card.width, height: L.card.height }] }); +}); + +test("measurePlacements: over a post card a module moves to a free slot (a size down if it must), hides when none fits; over a chapter band likewise", () => { + const f = { x: 173, y: 2, width: 1574, height: 886 }; + // A card down the middle, leaving ~300 px each side. + const card = { x: 476, y: 38, width: 968, height: 814 }; + const sched = schedule(MEASURE, { covers: [{ segment: "p1", from: 715, to: 725, rects: [card] }] }); + const p = measurePlacements(sched, RENDER); + const moveAt = (id, t) => p[id].moves.find((m) => m.from <= t && m.to > t) ?? null; + // The promise clock (640 wide, up from 712) cannot fit beside the card: hidden there. + assert.deepEqual(moveAt("promise", 720), { from: 715, to: 725, rect: null, size: 1 }); + // The diet badge (bottom-left, 440 wide) moves to a slot clear of the card, a size down. + const d = moveAt("diet", 720); + assert.ok(d.rect && d.size < 1, JSON.stringify(d)); + assert.ok(d.rect.x + d.rect.width <= card.x || d.rect.x >= card.x + card.width, "clear of the card"); + assert.ok(d.rect.x >= f.x && d.rect.x + d.rect.width <= f.x + f.width, "inside the footage box"); + // Its region holds home and the slot. + assert.ok(p.diet.region.x <= d.rect.x && p.diet.region.y <= d.rect.y); + // A module whose home is clear stays: none. + const free = measurePlacements(schedule(MEASURE, { covers: [{ segment: "p1", from: 715, to: 725, rects: [{ x: 700, y: 300, width: 400, height: 200 }] }] }), RENDER); + assert.equal(free.diet.moves.length, 0); + // onPosts: "hide" hides, "show" stays. + assert.equal(measurePlacements(sched, withDeck({ diet: { onPosts: "hide" } })).diet.moves[0].rect, null); + assert.equal(measurePlacements(sched, withDeck({ diet: { onPosts: "show" } })).diet.moves.length, 0); + // A chapter band (lower) at the foot of the footage: the bottom modules move up. + 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); + assert.ok(band?.rect && band.rect.y + band.rect.height <= f.y + f.height - Math.round(220), JSON.stringify(band)); + // Nothing to move clear of: home alone. + assert.deepEqual(measurePlacements(schedule(), RENDER).diet.region, measureExtraGeometry("diet", RENDER)); +}); + +test("moverSteps: overlapping moves (two post items crossfading, a band inside a post) are one step function -- hide wins, else the latest", () => { + const r = { x: 10, y: 10, width: 100, height: 50 }; + assert.deepEqual(moverSteps([{ from: 1, to: 5, rect: null }, { from: 4.6, to: 9, rect: null }]), [{ at: 1, to: "hide" }, { at: 9, to: "home" }]); + assert.deepEqual(moverSteps([{ from: 1, to: 5, rect: r, size: 0.6 }, { from: 2, to: 3, rect: null }]), [ + { at: 1, to: { x: 10, y: 10, size: 0.6 } }, { at: 2, to: "hide" }, { at: 3, to: { x: 10, y: 10, size: 0.6 } }, { at: 5, to: "home" }, + ]); + // The cues: a hidden mover is put in place at once, then faded in. + const { cues } = moverCues({ home: { x: 0, y: 0, width: 100, height: 50 }, moves: [{ from: 1, to: 5, rect: null }, { from: 4.6, to: 9, rect: r, size: 0.6 }] }); + assert.ok(cues.every((c, i, a) => i === 0 || c.at >= a[i - 1].at)); + assert.equal(cues[0].to.autoAlpha, 0); + assert.deepEqual(cues.find((c) => c.to.x === 10).to, { x: 10, y: 10, scale: 0.6 }); +}); diff --git a/umtool/report-to-video/modules/measure-extras-module.mjs b/umtool/report-to-video/modules/measure-extras-module.mjs @@ -7,10 +7,10 @@ // file says only what is its own. import path from "node:path"; -import { measureExtraGeometry, measureOf } from "../measure-extras.mjs"; +import { measureExtraGeometry, measureOf, measurePlacements } from "../measure-extras.mjs"; import { assertRegion, defineModule } from "./contract.mjs"; import { - MEASURE_DEFAULTS, MEASURE_FINALE, MEASURE_LIMITS, MEASURE_POSITIONS, resolveMeasureExtra, + MEASURE_AVOID, MEASURE_DEFAULTS, MEASURE_FINALE, MEASURE_LIMITS, MEASURE_POSITIONS, resolveMeasureExtra, } from "./measure-extras-settings.mjs"; import { settingsOf } from "./settings.mjs"; @@ -23,6 +23,8 @@ const commonUi = (id) => [ { key: "scale", type: "number", min: MEASURE_LIMITS.scale[0], max: MEASURE_LIMITS.scale[1], step: 0.05, label: "Scale", default: 1 }, { key: "hold", type: "number", min: MEASURE_LIMITS.hold[0], max: MEASURE_LIMITS.hold[1], label: "Seconds up after each event (0: stays up)", ...(MEASURE_DEFAULTS[id].hold !== null ? { default: MEASURE_DEFAULTS[id].hold } : {}) }, { key: "finale", type: "enum", options: MEASURE_FINALE, label: "Over the finale", default: MEASURE_DEFAULTS[id].finale }, + { key: "onPosts", type: "enum", options: MEASURE_AVOID, label: "Over a post item's card", default: "dodge" }, + { key: "onChapters", type: "enum", options: MEASURE_AVOID, label: "Over a chapter band", default: "dodge" }, ]; /** @@ -49,7 +51,13 @@ export function measureExtraModule(spec) { validate: settingsOf(id).validate, resolve: (render) => resolveMeasureExtra(id, render), ui: [...commonUi(id), ...(spec.ui ?? [])], - docs: { heading: spec.title, intro: spec.docs.intro, rows: spec.docs.rows }, + docs: { + heading: spec.title, intro: spec.docs.intro, + rows: [ + ...spec.docs.rows, + [`\`deck.${id}.onPosts\`, \`.onChapters\``, "`dodge` `hide` `show` · default `dodge`: while a post item's card (its card, slot and strip as postLayout lays them: the schedule's `covers`) or a chapter band is up where it stands, it moves to a free anchor of the footage box -- a size down to half if it must, never onto another measure extra that is up -- and hides when none fits; `hide` hides, `show` stays over it", `\`umtool look <p> deck.${id}.onPosts=hide\``], + ], + }, region: id, workers: "narrow", noun: `the ${spec.title.toLowerCase()}'s`, @@ -71,7 +79,8 @@ export function measureExtraModule(spec) { regions(schedule, { render, outDir, frames = null }) { return [assertRegion({ name: id, frames: frames ?? path.join(outDir, "chrome", `${id}-frames`), - ...measureExtraGeometry(id, render, { feed: schedule.layout === "feed" }), + // Its home, and every slot it moves clear to (a post card, a chapter band: measurePlacements). + ...measurePlacements(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 @@ -31,6 +31,13 @@ /** 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"]); +/** + * What a module does when a post item's card (`onPosts`) or a chapter band + * (`onChapters`) is up where it stands: moves to a slot clear of it (a size + * down if it must, hidden when nothing fits), hides, or stays (drawn over it). + */ +export const MEASURE_AVOID = Object.freeze(["dodge", "hide", "show"]); + /** What a module does over the finale's window (`finale`): hidden under it, or drawn over it. */ export const MEASURE_FINALE = Object.freeze(["hide", "show"]); @@ -72,7 +79,7 @@ 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" }); +const COMMON = Object.freeze({ show: true, position: "top-left", x: null, y: null, scale: 1, hold: null, finale: "hide", onPosts: "dodge", onChapters: "dodge" }); /** Each module's settings and their defaults. */ export const MEASURE_DEFAULTS = Object.freeze({ @@ -166,6 +173,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"`); + 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"`); + } if (id === "goals") { if (v.max !== undefined && !(Number.isInteger(v.max) && numIn(v.max, L.max[0], L.max[1]))) { errors.push(`${where}.max must be a whole number from ${L.max[0]} to ${L.max[1]}`);