commit e8a45f98e8b166e0293c411d2757e45b0c84090b
parent 4c4ba4837567852888d8ff19fcea77cce74a1a4a
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 11 Nov 2026 13:29:24 -0500
trail: the by-date chart shows every weight said so far, on axes that fit them and advance with the story
The strip laid every STATED weight of the whole cut on one fixed pair of axes
from the first frame (chrome-instruments.mjs trailHtml: `pts` from
measureTrack's `stated`, measure-draw.mjs:193, and d0/d1, lo/hi over all of
them): a remembered weight ("~390 as of Feb 2023", "368 as of Jun 2008") was
never a point, the 2013 weigh-in sat at the left edge of a 2013-2026 axis
until the first 2025 weight at ~2:55, and one line crossed a decade of
nothing to the 2025-26 points squeezed into the last pixels.
trail-plan.mjs: a state per moment a weight is said -- stated and remembered
(hollow grey, a qualifier dashed, never joined into the line) at its own date
(asOf, else the day said); the axes fit what is shown and reflow over 0.4 s as
each lands (years, bounds, every point, the ring); a stretch with no statement
longer than `gap` (auto: a year, or 8x the median spacing if longer) breaks
the time axis into clusters with their own years, a narrow band and // between,
the line across it dotted. New knobs deck.trail.bounds ("fit" | "fixed"),
.remembered, .gap -- in the module's UI and knobs.md.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
7 files changed, 422 insertions(+), 58 deletions(-)
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -2443,7 +2443,7 @@ Under the dial: the measure's `state.lost.total` (the highest real-time loss cla
### Weight trail
-At the foot of the instruments' column: every STATED weight the cut shows, placed by the date he was weighed (its `asOf`, else its date) across the span of them, a dot appearing at its event's `t` and the line between two neighbours drawn once both are said; a red ring on the latest said. The `mark` line (300) dashed across; with `count` and the mark at 300, `UNDER 300 · SAID n×` counts the measure's `totals.under300` rows as the cut reaches each.
+At the foot of the instruments' column: every weight the cut shows -- the STATED ones and (`remembered`) the remembered ones, "≈390, as of Feb 2023" -- placed by the date he was that weight (its `asOf`, else its date), a dot appearing at its event's `t`; the line joins neighbours by date among the stated ones once both are said (a remembered one is a hollow grey dot, never joined; a qualified one hollow). The axes FIT what has been said so far (trail-plan.mjs): each new weight outside them reflows the chart over 0.4 s -- the years, the bounds, every dot -- so the time axis advances with the story; a stretch with no statement longer than `gap` is a break in the time axis (a narrow dashed band, `//` at its foot, each side with its own years) and the line across it dotted, so a decade of nothing does not take the width from the dense run after it. A red ring on the latest said. The `mark` line (300) dashed across; with `count` and the mark at 300, `UNDER 300 · SAID n×` counts the measure's `totals.under300` rows as the cut reaches each.
| Knob | Range · default | From a terminal |
|---|---|---|
@@ -2451,6 +2451,9 @@ At the foot of the instruments' column: every STATED weight the cut shows, place
| `deck.trail.mark` | a weight, or `null` · default `300` | `umtool look <p> deck.trail.mark=300` |
| `deck.trail.count` | bool · default `true` | `umtool look <p> deck.trail.count=false` |
| `deck.trail.label` | its title, ≤ 40 · default `WHAT HE SAYS HE WEIGHS, BY DATE` | `umtool look <p> deck.trail.label='"…"'` |
+| `deck.trail.bounds` | `fit` · `fixed` · default `fit`: the axes fit the weights said so far and reflow as each lands; `fixed` lays every moment on the axes of all the cut's weights | `umtool look <p> deck.trail.bounds=fixed` |
+| `deck.trail.remembered` | bool · default `true`: his remembered weights are points too, hollow and grey, not joined into the line | `umtool look <p> deck.trail.remembered=false` |
+| `deck.trail.gap` | `auto` · days 30–3650 · `0` none · default `auto`: a stretch with no statement longer than a year (or 8× the median spacing, if longer) is a break in the time axis | `umtool look <p> deck.trail.gap=540` |
### Flips
diff --git a/umtool/report-to-video/chrome-instruments.mjs b/umtool/report-to-video/chrome-instruments.mjs
@@ -19,6 +19,7 @@ import { mix, rgba } from "./chrome-deck.mjs";
import { finaleLayout } from "./chrome-finale.mjs";
import { FINALE_MOTION } from "./finale.mjs";
import { resolveDial, resolveOdometer, resolveTrail } from "./instruments.mjs";
+import { TRAIL_REFLOW, trailLayout, trailPoints, trailStates } from "./trail-plan.mjs";
import { promiseStates, upSpans } from "./measure-extras.mjs";
import { ghostOpacity, ghostRamp, ghostTicks, resolveGhosts } from "./measure-ghosts.mjs";
import { goalBoard, goalsAt } from "./measure-goals.mjs";
@@ -708,58 +709,126 @@ export function trailHtml(schedule, render, opts = {}) {
const colors = colorsOf(render);
const track = measureTrack(M);
const mark = Number.isFinite(cfg.mark) ? cfg.mark : null;
- // By date: each stated weight at the day it was weighed, in date order.
- const pts = track.stated
- .map((p, n) => ({ ...p, day: dayNumber(p.date), n }))
- .filter((p) => Number.isFinite(p.day))
- .sort((a, b) => a.day - b.day || a.n - b.n);
- const x0 = px(54), x1 = W - px(18), y0 = px(38), y1 = H - px(26);
- let d0 = pts.length ? pts[0].day : 0, d1 = pts.length ? pts[pts.length - 1].day : 1;
- if (d1 - d0 < 60) { d0 -= 30; d1 += 30; }
- const vals = pts.map((p) => p.value).concat(mark !== null ? [mark] : []);
- const lo = vals.length ? Math.floor((Math.min(...vals) - 5) / 10) * 10 : M.scale.min;
- const hi = vals.length ? Math.ceil((Math.max(...vals) + 5) / 10) * 10 : M.scale.max;
- const X = (d) => r4(x0 + ((d - d0) / (d1 - d0)) * (x1 - x0));
- const Y = (v) => r4(y1 - ((v - lo) / Math.max(1, hi - lo)) * (y1 - y0));
- const parts = [];
- // The years along the foot.
- const yearOf = (d) => new Date(d * 86400000).getUTCFullYear();
- for (let yr = yearOf(d0) + 1; yr <= yearOf(d1); yr += 1) {
- const x = X(Date.UTC(yr, 0, 1) / 86400000);
- parts.push(`<div class="yr" style="left:${x}px; top:${y1 + px(4)}px">${yr}</div><div class="ytick" style="left:${x}px; top:${y0}px; height:${y1 - y0}px"></div>`);
- }
- if (mark !== null && mark >= lo && mark <= hi) {
- parts.push(`<div class="mark" style="left:${x0}px; top:${Y(mark)}px; width:${x1 - x0}px"></div><div class="marklab" style="left:${px(12)}px; top:${Y(mark)}px">${mark}</div>`);
- }
- parts.push(`<div class="lohi" style="left:${px(12)}px; top:${y0}px">${hi}</div><div class="lohi" style="left:${px(12)}px; top:${y1}px">${lo}</div>`);
+ // THE PLAN (trail-plan.mjs): a state per moment a weight is said -- stated, and remembered unless `remembered` is
+ // off -- each laid out on axes that fit what is shown, the time axis broken across long empty stretches.
+ const pts = trailPoints(M, { remembered: cfg.remembered !== false });
+ const box = { x0: px(54), x1: W - px(18), y0: px(38), y1: H - px(26), gapPx: px(22), yearPx: px(34) };
+ const states = trailStates(pts, box, { gap: cfg.gap ?? "auto", mark, bounds: cfg.bounds ?? "fit" });
+ const first = states[0]?.layout ?? trailLayout([], box, { mark });
+ const { y0, y1 } = box;
const L = cueList(fps);
withDeck(L, schedule, render, "rt");
const M2 = INSTRUMENT_MOTION;
- // The line: each pair of neighbours by date, drawn once both have been said.
- for (let j = 0; j + 1 < pts.length; j += 1) {
- const a = pts[j], b = pts[j + 1];
- const xa = X(a.day), ya = Y(a.value), xb = X(b.day), yb = Y(b.value);
- const len = r4(Math.hypot(xb - xa, yb - ya));
- const ang = r4((Math.atan2(yb - ya, xb - xa) * 180) / Math.PI);
- parts.push(`<div class="seg" data-k="s${j}" style="left:${xa}px; top:${ya}px; width:${len}px"></div>`);
- L.set(`s${j}`, { rotation: ang, scaleX: 0, transformOrigin: "0% 50%" });
- L.add(`s${j}`, Math.max(a.t, b.t), M2.segment, { scaleX: 1 }, "power2.out");
- }
- pts.forEach((p, j) => {
- parts.push(`<div class="pt${p.qualifier ? " q" : ""}" data-k="p${j}" style="left:${X(p.day)}px; top:${Y(p.value)}px"></div>`);
- L.set(`p${j}`, { autoAlpha: 0, scale: 0.3 });
- L.add(`p${j}`, p.t, M2.point, { autoAlpha: 1, scale: 1 }, "back.out(2)");
+ const RF = TRAIL_REFLOW;
+ const parts = [];
+ const moved = (a, b) => !a || !b || Math.abs(a.x - b.x) > 0.05 || Math.abs(a.y - b.y) > 0.05;
+
+ // The axes: a label per year (its tick inside a cluster), a break per gap between clusters, the bounds' two figures
+ // and the mark line -- each shown, moved and hidden state by state; before the first weight, the first state's axes.
+ const yearKeys = new Map();
+ const gapKeys = new Map();
+ const bounds = new Map();
+ states.forEach((st) => {
+ for (const y of st.layout.years) if (!yearKeys.has(y.key)) yearKeys.set(y.key, y);
+ for (const g of st.layout.gaps) if (!gapKeys.has(g.key)) gapKeys.set(g.key, g);
+ for (const v of [`hi${st.layout.hi}`, `lo${st.layout.lo}`]) bounds.set(v, null);
});
- // The latest said, ringed in the needle's red: it travels to each as it lands.
- if (pts.length) {
- parts.push(`<div class="ring" data-k="pl"></div>`);
- const inCut = [...pts].sort((a, b) => a.t - b.t || a.n - b.n);
- L.set("pl", { x: X(inCut[0].day), y: Y(inCut[0].value), autoAlpha: 0 });
- inCut.forEach((p, j) => {
- if (j === 0) L.add("pl", p.t, M2.point, { autoAlpha: 1 }, "power1.out");
- else L.add("pl", p.t, M2.point, { x: X(p.day), y: Y(p.value) }, "power2.inOut");
- });
+ if (!states.length) for (const v of [`hi${first.hi}`, `lo${first.lo}`]) bounds.set(v, null);
+ for (const [key, y] of yearKeys) {
+ parts.push(`<div class="yw" data-k="y${key}">${y.tick ? `<div class="ytick" style="top:${y0}px; height:${r4(y1 - y0)}px"></div>` : ""}<div class="yr" style="top:${r4(y1 + px(4))}px">${y.text}</div></div>`);
+ }
+ for (const [key] of gapKeys) {
+ parts.push(`<div class="gp" data-k="g${key}" style="top:${y0}px; height:${r4(y1 - y0)}px"><div class="gz">//</div></div>`);
+ }
+ for (const key of bounds.keys()) {
+ parts.push(`<div class="lohi" data-k="b${key}" style="left:${px(12)}px; top:${key.startsWith("hi") ? y0 : y1}px">${key.slice(2)}</div>`);
}
+ if (mark !== null) parts.push(`<div class="mark" data-k="mk" style="left:${box.x0}px; width:${r4(box.x1 - box.x0)}px"></div><div class="marklab" data-k="ml" style="left:${px(12)}px">${mark}</div>`);
+ const axisAt = (layout, at, prev) => {
+ const vis = (list) => new Map(list.map((x) => [x.key, x]));
+ const ys = vis(layout.years), gs = vis(layout.gaps);
+ const pys = prev ? vis(prev.years) : new Map(), pgs = prev ? vis(prev.gaps) : new Map();
+ for (const [key] of yearKeys) {
+ const now = ys.get(key), was = pys.get(key);
+ if (!prev) { L.set(`y${key}`, { x: (now ?? yearKeys.get(key)).x ?? 0, autoAlpha: now ? 1 : 0 }); continue; }
+ if (now && was) { if (Math.abs(now.x - was.x) > 0.05) L.add(`y${key}`, at, RF, { x: now.x }, "power2.inOut"); }
+ else if (now) L.add(`y${key}`, at, RF, { x: now.x, autoAlpha: 1 }, "power2.out");
+ else if (was) L.add(`y${key}`, at, RF * 0.6, { autoAlpha: 0 }, "power1.in");
+ }
+ for (const [key] of gapKeys) {
+ const now = gs.get(key), was = pgs.get(key);
+ if (!prev) { L.set(`g${key}`, { x: (now ?? gapKeys.get(key)).x, autoAlpha: now ? 1 : 0 }); continue; }
+ if (now && was) { if (Math.abs(now.x - was.x) > 0.05) L.add(`g${key}`, at, RF, { x: now.x }, "power2.inOut"); }
+ else if (now) L.add(`g${key}`, at, RF, { x: now.x, autoAlpha: 1 }, "power2.out");
+ else if (was) L.add(`g${key}`, at, RF * 0.6, { autoAlpha: 0 }, "power1.in");
+ }
+ // A bound's figure gives way to the mark's when they would sit on each other.
+ const clear = (lay, v) => mark === null || Math.abs(lay.Y(mark) - lay.Y(v)) >= px(14);
+ const shows = (lay, key) => (key === `hi${lay.hi}` && clear(lay, lay.hi)) || (key === `lo${lay.lo}` && clear(lay, lay.lo));
+ for (const key of bounds.keys()) {
+ const on = shows(layout, key);
+ const was = prev ? shows(prev, key) : null;
+ if (!prev) L.set(`b${key}`, { autoAlpha: on ? 1 : 0 });
+ else if (on !== was) L.add(`b${key}`, at, RF * 0.6, { autoAlpha: on ? 1 : 0 }, "power1.inOut");
+ }
+ if (mark !== null) {
+ const y = layout.Y(mark);
+ if (!prev) { L.set("mk", { y }); L.set("ml", { y, yPercent: -50 }); }
+ else if (Math.abs(prev.Y(mark) - y) > 0.05) { L.add("mk", at, RF, { y }, "power2.inOut"); L.add("ml", at, RF, { y }, "power2.inOut"); }
+ }
+ };
+ axisAt(first, 0, null);
+
+ // The points: each pops in at its place in the state it is said in, then moves with every reflow after.
+ const firstState = new Map();
+ states.forEach((st, j) => { for (const n of st.shown) if (!firstState.has(n)) firstState.set(n, j); });
+ for (const p of pts) {
+ const j = firstState.get(p.n);
+ const at = states[j].pos.get(p.n);
+ const cls = `pt${p.kind === "remembered" ? " rem" : ""}${p.qualifier ? " q" : ""}`;
+ parts.push(`<div class="${cls}" data-k="p${p.n}"></div>`);
+ L.set(`p${p.n}`, { x: at.x, y: at.y, autoAlpha: 0, scale: 0.3 });
+ L.add(`p${p.n}`, p.t, M2.point, { autoAlpha: 1, scale: 1 }, "back.out(2)");
+ }
+ // The line: neighbours by date among the stated points shown, a pair drawn in when it first is one, moved with the
+ // reflows while it lasts, gone the moment a weight said later lands between them. Across a break it is dotted.
+ const pairFirst = new Map();
+ states.forEach((st, j) => { for (const pr of st.pairs) if (!pairFirst.has(pr.key)) pairFirst.set(pr.key, { ...pr, j }); });
+ const geomOf = (st, pr) => {
+ const a = st.pos.get(pr.a), b = st.pos.get(pr.b);
+ return { x: a.x, y: a.y, width: r4(Math.hypot(b.x - a.x, b.y - a.y)), rotation: r4((Math.atan2(b.y - a.y, b.x - a.x) * 180) / Math.PI) };
+ };
+ for (const [key, pr] of pairFirst) {
+ parts.push(`<div class="seg${pr.gap ? " gap" : ""}" data-k="s${key}"></div>`);
+ L.set(`s${key}`, { ...geomOf(states[pr.j], pr), scaleX: 0, autoAlpha: 1, transformOrigin: "0% 50%" });
+ L.add(`s${key}`, states[pr.j].at, M2.segment, { scaleX: 1 }, "power2.out");
+ }
+ // The latest said, ringed in the needle's red: it travels to each as it lands, and with the reflows.
+ if (pts.length) parts.push(`<div class="ring" data-k="pl"></div>`);
+ states.forEach((st, j) => {
+ const prev = j ? states[j - 1] : null;
+ const latest = pts.filter((p) => p.t <= st.at + 1e-9).at(-1);
+ if (!prev) {
+ const at0 = st.pos.get(latest.n);
+ L.set("pl", { x: at0.x, y: at0.y, autoAlpha: 0 });
+ L.add("pl", st.at, M2.point, { autoAlpha: 1 }, "power1.out");
+ return;
+ }
+ axisAt(st.layout, st.at, prev.layout);
+ for (const n of prev.shown) {
+ const a = prev.pos.get(n), b = st.pos.get(n);
+ if (moved(a, b)) L.add(`p${n}`, st.at, RF, { x: b.x, y: b.y }, "power2.inOut");
+ }
+ const was = new Map(prev.pairs.map((pr) => [pr.key, pr]));
+ const now = new Map(st.pairs.map((pr) => [pr.key, pr]));
+ for (const [key, pr] of was) {
+ if (!now.has(key)) { L.add(`s${key}`, st.at, RF * 0.5, { autoAlpha: 0 }, "power1.in"); continue; }
+ const g0 = geomOf(prev, pr), g1 = geomOf(st, pr);
+ if (moved(g0, g1) || Math.abs(g0.width - g1.width) > 0.05 || Math.abs(g0.rotation - g1.rotation) > 0.05) L.add(`s${key}`, st.at, RF, g1, "power2.inOut");
+ }
+ const ring = st.pos.get(latest.n);
+ L.add("pl", st.at, RF, { x: ring.x, y: ring.y }, "power2.inOut");
+ });
// How many times he says he is under 300, counted as each lands.
const counts = cfg.count && mark === 300 ? track.under.slice().sort((a, b) => a.t - b.t).map((x, n) => ({ t: x.t, n: n + 1 })) : [];
counts.forEach((c) => parts.push(`<div class="cnt" data-k="uc${c.n - 1}">UNDER ${mark} · SAID ${c.n}×</div>`));
@@ -775,22 +844,29 @@ export function trailHtml(schedule, render, opts = {}) {
const css = `
#rt { position: absolute; inset: 0; }
.ty { position: absolute; inset: 0; }
- .trail { position: absolute; inset: 0; border-radius: ${px(10)}px; background: ${colors.card}; }
+ .trail { position: absolute; inset: 0; border-radius: ${px(10)}px; background: ${colors.card}; overflow: hidden; }
.trail .lab { position: absolute; left: ${px(14)}px; top: ${px(10)}px; font-family: ${fontStack(fonts, "condensed")}; font-size: ${px(14)}px;
letter-spacing: 0.12em; color: ${colors.muted}; white-space: nowrap; }
.trail .cnt { position: absolute; right: ${px(16)}px; top: ${px(9)}px; font-family: ${fontStack(fonts, "bold")}; font-size: ${px(15)}px;
letter-spacing: 0.06em; color: ${colors.accent}; white-space: nowrap; }
- .trail .yr { position: absolute; transform: translateX(-50%); font-family: ${fontStack(fonts, "condensed")}; font-size: ${px(13)}px;
- color: ${colors.muted}; letter-spacing: 0.06em; }
- .trail .ytick { position: absolute; width: 1px; background: ${colors.rule}; }
- .trail .mark { position: absolute; height: 0; border-top: ${px(2)}px dashed ${rgba(colors.accent, 0.75)}; }
+ .trail .yw { position: absolute; left: 0; top: 0; width: 0; height: 0; }
+ .trail .yr { position: absolute; left: 0; transform: translateX(-50%); font-family: ${fontStack(fonts, "condensed")}; font-size: ${px(13)}px;
+ color: ${colors.muted}; letter-spacing: 0.06em; white-space: nowrap; }
+ .trail .ytick { position: absolute; left: 0; width: 1px; background: ${colors.rule}; }
+ .trail .gp { position: absolute; left: 0; width: ${px(14)}px; margin-left: -${px(7)}px; background: ${rgba(colors.muted, 0.08)}; }
+ .trail .gz { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-family: ${fontStack(fonts, "condensed")};
+ font-size: ${px(13)}px; color: ${colors.muted}; letter-spacing: -0.1em; }
+ .trail .mark { position: absolute; top: 0; height: 0; border-top: ${px(2)}px dashed ${rgba(colors.accent, 0.75)}; }
.trail .marklab, .trail .lohi { position: absolute; transform: translateY(-50%); font-family: ${fontStack(fonts, "condensed")};
font-size: ${px(13)}px; color: ${colors.muted}; }
- .trail .marklab { color: ${colors.accent}; font-family: ${fontStack(fonts, "bold")}; }
- .trail .seg { position: absolute; height: ${px(2.6)}px; margin-top: -${px(1.3)}px; background: ${colors.accent}; border-radius: ${px(2)}px; }
- .trail .pt { position: absolute; width: ${px(10)}px; height: ${px(10)}px; margin: -${px(5)}px 0 0 -${px(5)}px; border-radius: 50%;
+ .trail .marklab { top: 0; transform: none; color: ${colors.accent}; font-family: ${fontStack(fonts, "bold")}; }
+ .trail .seg { position: absolute; left: 0; top: 0; height: ${px(2.6)}px; margin-top: -${px(1.3)}px; background: ${colors.accent}; border-radius: ${px(2)}px; }
+ .trail .seg.gap { height: 0; margin-top: -${px(1)}px; background: none; border-top: ${px(2)}px dotted ${rgba(colors.accent, 0.55)}; border-radius: 0; }
+ .trail .pt { position: absolute; left: 0; top: 0; width: ${px(10)}px; height: ${px(10)}px; margin: -${px(5)}px 0 0 -${px(5)}px; border-radius: 50%;
background: ${colors.accent}; border: ${px(2)}px solid ${colors.card}; }
.trail .pt.q { background: ${colors.card}; border: ${px(2.4)}px solid ${colors.accent}; }
+ .trail .pt.rem { background: ${colors.card}; border: ${px(2.4)}px solid ${colors.ghost}; }
+ .trail .pt.rem.q { border-style: dashed; }
.trail .ring { position: absolute; left: 0; top: 0; width: ${px(20)}px; height: ${px(20)}px; margin: -${px(10)}px 0 0 -${px(10)}px;
border-radius: 50%; border: ${px(3)}px solid ${colors.needle}; }`;
return pageHtml({
diff --git a/umtool/report-to-video/instruments.mjs b/umtool/report-to-video/instruments.mjs
@@ -89,6 +89,13 @@ export const TRAIL_DEFAULTS = Object.freeze({
// How many times he says he is under 300 (the measure's `totals.under300` rows), as they land.
count: true,
label: "WHAT HE SAYS HE WEIGHS, BY DATE",
+ // The axes: "fit" what is shown so far, reflowing as each weight lands; "fixed" to every point of the cut.
+ bounds: "fit",
+ // His remembered weights ("≈390, as of Feb 2023") as points too: hollow and grey, never joined into the line.
+ remembered: true,
+ // A stretch with no statement longer than this many days is a break in the time axis, not a line across it:
+ // "auto" (a year, or 8× the median spacing if that is longer), a number of days (30–3650), or 0 for none.
+ gap: "auto",
});
/** A label's characters at most. */
@@ -194,5 +201,8 @@ export function validateTrail(v, where = "render.chrome.deck.trail") {
if (obj.mark !== undefined) { const p = markProblem(obj.mark, `${where}.mark`); if (p) errors.push(p); }
if (obj.count !== undefined) { const p = boolProblem(obj.count, `${where}.count`); if (p) errors.push(p); }
if (obj.label !== undefined) { const p = labelProblem(obj.label, `${where}.label`); if (p) errors.push(p); }
+ if (obj.remembered !== undefined) { const p = boolProblem(obj.remembered, `${where}.remembered`); if (p) errors.push(p); }
+ if (obj.bounds !== undefined && !["fit", "fixed"].includes(obj.bounds)) errors.push(`${where}.bounds must be "fit" or "fixed"`);
+ if (obj.gap !== undefined && !(obj.gap === "auto" || obj.gap === 0 || numIn(obj.gap, 30, 3650))) errors.push(`${where}.gap must be "auto", 0 (no breaks) or 30 to 3650 days`);
return errors;
}
diff --git a/umtool/report-to-video/modules/trail.mjs b/umtool/report-to-video/modules/trail.mjs
@@ -30,15 +30,20 @@ export default defineModule({
{ key: "mark", type: "number", min: 0, max: 2000, step: 1, label: "The line across", default: 300 },
{ key: "count", type: "boolean", label: "Count the \"under 300\" claims", default: true },
{ key: "label", type: "text", label: "Its title", default: TRAIL_DEFAULTS.label },
+ { key: "bounds", type: "enum", options: ["fit", "fixed"], label: "Axes: fit what is shown so far, or fixed to the whole cut", default: "fit" },
+ { key: "remembered", type: "boolean", label: "His remembered weights as points too (hollow, not joined)", default: true },
],
docs: {
heading: "Weight trail",
- intro: "At the foot of the instruments' column: every STATED weight the cut shows, placed by the date he was weighed (its `asOf`, else its date) across the span of them, a dot appearing at its event's `t` and the line between two neighbours drawn once both are said; a red ring on the latest said. The `mark` line (300) dashed across; with `count` and the mark at 300, `UNDER 300 · SAID n×` counts the measure's `totals.under300` rows as the cut reaches each.",
+ intro: "At the foot of the instruments' column: every weight the cut shows -- the STATED ones and (`remembered`) the remembered ones, \"≈390, as of Feb 2023\" -- placed by the date he was that weight (its `asOf`, else its date), a dot appearing at its event's `t`; the line joins neighbours by date among the stated ones once both are said (a remembered one is a hollow grey dot, never joined; a qualified one hollow). The axes FIT what has been said so far (trail-plan.mjs): each new weight outside them reflows the chart over 0.4 s -- the years, the bounds, every dot -- so the time axis advances with the story; a stretch with no statement longer than `gap` is a break in the time axis (a narrow dashed band, `//` at its foot, each side with its own years) and the line across it dotted, so a decade of nothing does not take the width from the dense run after it. A red ring on the latest said. The `mark` line (300) dashed across; with `count` and the mark at 300, `UNDER 300 · SAID n×` counts the measure's `totals.under300` rows as the cut reaches each.",
rows: [
["`deck.trail`", "`true` · an object of the knobs below · `false` off · absent: ON when the cut draws a measure (`deck.measure` set), else off", "`umtool look <p> deck.trail=false`"],
["`deck.trail.mark`", "a weight, or `null` · default `300`", "`umtool look <p> deck.trail.mark=300`"],
["`deck.trail.count`", "bool · default `true`", "`umtool look <p> deck.trail.count=false`"],
["`deck.trail.label`", "its title, ≤ 40 · default `WHAT HE SAYS HE WEIGHS, BY DATE`", "`umtool look <p> deck.trail.label='\"…\"'`"],
+ ["`deck.trail.bounds`", "`fit` · `fixed` · default `fit`: the axes fit the weights said so far and reflow as each lands; `fixed` lays every moment on the axes of all the cut's weights", "`umtool look <p> deck.trail.bounds=fixed`"],
+ ["`deck.trail.remembered`", "bool · default `true`: his remembered weights are points too, hollow and grey, not joined into the line", "`umtool look <p> deck.trail.remembered=false`"],
+ ["`deck.trail.gap`", "`auto` · days 30–3650 · `0` none · default `auto`: a stretch with no statement longer than a year (or 8× the median spacing, if longer) is a break in the time axis", "`umtool look <p> deck.trail.gap=540`"],
],
},
region: "trail",
diff --git a/umtool/report-to-video/trail-plan.mjs b/umtool/report-to-video/trail-plan.mjs
@@ -0,0 +1,149 @@
+// THE TRAIL'S PLAN (the by-date chart strip under the instruments, 11 Nov): which
+// weights it shows at each moment of the cut, and where each one stands then.
+//
+// Before this the strip laid every STATED weight of the whole cut on one fixed
+// pair of axes from the first frame: a remembered weight ("≈390, as of Feb
+// 2023", "368 as of Jun 2008") was never a point, a 2013 weigh-in sat pinned at
+// the left edge of a 2013–2026 axis for minutes, and one straight line crossed
+// a decade of nothing to the 2025–26 points squeezed into the last pixels.
+//
+// Now the chart is a sequence of STATES, one per moment a weight is said: the
+// points said so far -- stated ones, and remembered ones (`remembered`, hollow
+// and grey, never joined into the line) -- at their own dates (asOf, else the
+// day said) and values; the axes FIT what is shown (`bounds: "fit"`; "fixed"
+// pins them to the whole cut's points); and a stretch of time with no statement
+// longer than the gap threshold (`gap`) is not drawn as data: the time axis is
+// cut there into CLUSTERS, each with its own years, a narrow break between them
+// and a dotted connector across it, so the dense recent run gets the width. The
+// page (chrome-instruments.mjs trailHtml) moves everything from one state's
+// places to the next's over TRAIL_REFLOW seconds.
+//
+// PURE: the measure slice and a box in, plain data out.
+import { dayNumber } from "./measure-draw.mjs";
+
+/** Seconds a reflow takes: the axes and every point moving to the new state's places. */
+export const TRAIL_REFLOW = 0.4;
+
+/** `gap: "auto"`: a stretch is a break when longer than this many days, or `GAP_MEDIANS` times the median spacing. */
+export const GAP_FLOOR_DAYS = 365;
+export const GAP_MEDIANS = 8;
+
+const r2 = (v) => Math.round(v * 100) / 100;
+
+/**
+ * The trail's points, in the order the cut says them: `{ n, t, row, value, qualifier, day, kind }`, `kind`
+ * "stated" or "remembered" (only with `remembered`), `day` the day number of its asOf, else its date.
+ */
+export function trailPoints(measure, { remembered = true } = {}) {
+ const out = [];
+ for (const e of measure?.events ?? []) {
+ if (!Number.isFinite(e.t) || !Number.isFinite(Number(e.value))) continue;
+ if (e.kind !== "stated" && !(remembered && e.kind === "remembered")) continue;
+ const day = dayNumber(e.asOf ?? e.date);
+ if (!Number.isFinite(day)) continue;
+ out.push({ t: e.t, row: e.row ?? null, value: Number(e.value), qualifier: e.qualifier ?? null, day, kind: e.kind });
+ }
+ out.sort((a, b) => a.t - b.t);
+ return out.map((p, n) => ({ ...p, n }));
+}
+
+/** The gap threshold in days: `gap` a number of days, 0/false never, "auto" from the data (see GAP_FLOOR_DAYS). */
+export function gapThreshold(points, gap = "auto") {
+ if (gap === 0 || gap === false) return Infinity;
+ if (typeof gap === "number" && gap > 0) return gap;
+ const days = [...new Set(points.map((p) => p.day))].sort((a, b) => a - b);
+ const steps = days.slice(1).map((d, i) => d - days[i]).sort((a, b) => a - b);
+ const median = steps.length ? steps[Math.floor(steps.length / 2)] : 0;
+ return Math.max(GAP_FLOOR_DAYS, GAP_MEDIANS * median);
+}
+
+/** Days, sorted, cut into clusters where a step is longer than `thr`: `[{ first, last }]`. */
+export function clustersOf(days, thr) {
+ const ds = [...new Set(days)].sort((a, b) => a - b);
+ const out = [];
+ for (const d of ds) {
+ const c = out[out.length - 1];
+ if (c && d - c.last <= thr) c.last = d;
+ else out.push({ first: d, last: d });
+ }
+ return out;
+}
+
+const yearOf = (d) => new Date(d * 86400000).getUTCFullYear();
+const jan1 = (y) => Date.UTC(y, 0, 1) / 86400000;
+
+/**
+ * One state's places: the y bounds (`lo`/`hi`, tens of the unit around the values shown and the mark), the
+ * clusters along x (each `{ first, last, from, to, x0, x1 }`: its days, its padded span, its pixels), the breaks
+ * between them (`gaps`: `{ key, x }`), the year labels (`years`: `{ key, text, x, tick }`), and `X(day)` / `Y(v)`.
+ *
+ * `box` = `{ x0, x1, y0, y1, gapPx, yearPx }` in page pixels.
+ */
+export function trailLayout(points, box, { thr = Infinity, mark = null } = {}) {
+ const { x0, x1, y0, y1 } = box;
+ const gapPx = box.gapPx ?? 22;
+ const yearPx = box.yearPx ?? 34;
+ const vals = points.map((p) => p.value).concat(mark !== null && mark !== undefined ? [mark] : []);
+ const lo = vals.length ? Math.floor((Math.min(...vals) - 5) / 10) * 10 : 0;
+ const hi = vals.length ? Math.ceil((Math.max(...vals) + 5) / 10) * 10 : 10;
+ const cl = clustersOf(points.map((p) => p.day), thr);
+ const spread = cl.reduce((s, c) => s + (c.last - c.first), 0);
+ const pad = Math.max(20, 0.04 * spread);
+ for (const c of cl) {
+ const p = c.last - c.first < 1 ? Math.max(pad, 60) : pad;
+ c.from = c.first - p;
+ c.to = c.last + p;
+ }
+ const widthDays = cl.reduce((s, c) => s + (c.to - c.from), 0) || 1;
+ const scale = Math.max(0, x1 - x0 - gapPx * Math.max(0, cl.length - 1)) / widthDays;
+ let at = x0;
+ for (const c of cl) {
+ c.x0 = r2(at);
+ c.x1 = r2(at + (c.to - c.from) * scale);
+ at = c.x1 + gapPx;
+ }
+ const X = (d) => {
+ const c = cl.find((k) => d >= k.from - 1e-9 && d <= k.to + 1e-9) ?? null;
+ return c ? r2(c.x0 + (d - c.from) * scale) : null;
+ };
+ const Y = (v) => r2(y1 - ((v - lo) / Math.max(1, hi - lo)) * (y1 - y0));
+ const gaps = cl.slice(1).map((c, i) => ({ key: `${cl[i].last}_${c.first}`, x: r2((cl[i].x1 + c.x0) / 2) }));
+ // The years: each cluster's first year labelled at its first point (unless that year's 1 January is a tick in it),
+ // each 1 January inside a cluster's span a tick; then thinned left to right so no two labels are closer than
+ // `yearPx`, a cluster's own year first.
+ const cands = [];
+ for (const c of cl) {
+ const firstYear = yearOf(c.first);
+ if (jan1(firstYear) < c.from) cands.push({ key: `c${firstYear}`, text: String(firstYear), x: X(c.first), tick: false, lead: true });
+ for (let y = yearOf(c.from) + 1; jan1(y) <= c.to; y += 1) cands.push({ key: `t${y}`, text: String(y), x: X(jan1(y)), tick: true });
+ }
+ cands.sort((a, b) => a.x - b.x || (b.lead ? 1 : 0) - (a.lead ? 1 : 0));
+ const years = [];
+ for (const y of cands) if (!years.length || y.x - years[years.length - 1].x >= yearPx) years.push(y);
+ return { lo, hi, clusters: cl, gaps, years, X, Y };
+}
+
+/**
+ * The trail's states: one per moment a point is said (`at`), each with the points shown (`shown`, their `n`), its
+ * layout, each shown point's place (`pos`: n -> {x, y}) and the line's pairs (`pairs`: neighbours by date among the
+ * STATED points shown, `{ key, a, b, gap }`, `gap` when they straddle a break). `bounds: "fixed"` lays every state on
+ * the layout of all the cut's points (the strip as it was, but with its breaks).
+ *
+ * @param {ReturnType<typeof trailPoints>} points
+ */
+export function trailStates(points, box, { gap = "auto", mark = null, bounds = "fit" } = {}) {
+ const thr = gapThreshold(points, gap);
+ const all = bounds === "fixed" ? trailLayout(points, box, { thr, mark }) : null;
+ const times = [...new Set(points.map((p) => p.t))].sort((a, b) => a - b);
+ return times.map((at) => {
+ const shown = points.filter((p) => p.t <= at + 1e-9);
+ const layout = all ?? trailLayout(shown, box, { thr, mark });
+ const pos = new Map(shown.map((p) => [p.n, { x: layout.X(p.day), y: layout.Y(p.value) }]));
+ const stated = shown.filter((p) => p.kind === "stated").sort((a, b) => a.day - b.day || a.t - b.t);
+ const pairs = stated.slice(1).map((b, i) => {
+ const a = stated[i];
+ return { key: `${a.n}_${b.n}`, a: a.n, b: b.n, gap: b.day - a.day > thr };
+ });
+ return { at, shown: shown.map((p) => p.n), layout, pos, pairs, thr };
+ });
+}
diff --git a/umtool/report-to-video/trail-plan.test.mjs b/umtool/report-to-video/trail-plan.test.mjs
@@ -0,0 +1,118 @@
+// THE TRAIL'S PLAN (trail-plan.mjs; chrome-instruments.mjs trailHtml): the by-date chart shows every weight said
+// so far -- stated and remembered -- on axes that fit them and reflow as each lands, its time axis broken across
+// long empty stretches (rev9-a7, 11 Nov: a 2013 dot pinned at the left edge for minutes, 2008 and ≈390 never drawn,
+// one line across a decade to the 2025–26 points squeezed at the right).
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { trailHtml } from "./chrome-instruments.mjs";
+import { estimateSchedule } from "./deck.mjs";
+import { clustersOf, GAP_FLOOR_DAYS, gapThreshold, trailLayout, trailPoints, trailStates } from "./trail-plan.mjs";
+import { dayNumber } from "./measure-draw.mjs";
+import { validateTrail } from "./instruments.mjs";
+
+/** The a7 sequence: a 2013 weigh-in and a second 2013 weight; a remembered ≈390 (as of Feb 2023) above them; a
+ * remembered 368 as of 2008 -- before everything and above the old top; then the dense 2025–26 run. */
+const ev = (t, kind, value, date, extra = {}) => ({ t, kind, value, date, row: `r${t}`, scope: "weight", qualifier: null, asOf: null, ...extra });
+const EVENTS = [
+ ev(9, "stated", 346.7, "2013-03-09"),
+ ev(31, "stated", 342.9, "2013-03-21"),
+ ev(60, "remembered", 390, "2023-09-29", { asOf: "2023-02-24", qualifier: "≈" }),
+ ev(100, "remembered", 368, "2025-01-10", { asOf: "2008-06-30" }),
+ ev(175, "stated", 349, "2025-04-08"),
+ ev(204, "stated", 341, "2025-06-02"),
+ ev(225, "stated", 336, "2025-07-15"),
+ ev(230, "stated", 331.5, "2025-08-01"),
+ ev(280, "stated", 322, "2025-10-08"),
+ ev(293, "stated", 318, "2025-11-20"),
+ ev(320, "stated", 305, "2026-01-16"),
+ ev(324, "stated", 299, "2026-03-02"),
+ ev(337, "stated", 296, "2026-06-01", { qualifier: "≈" }),
+ ev(347, "goal", 250, "2026-07-01"),
+];
+const MEASURE = { unit: "lb", scale: { min: 220, max: 400 }, events: EVENTS, state: [{ t: 0 }], totals: {} };
+const BOX = { x0: 54, x1: 582, y0: 38, y1: 174, gapPx: 22, yearPx: 34 };
+
+test("the trail's points: stated and remembered, each at its own date (asOf first), in the cut's order", () => {
+ const pts = trailPoints(MEASURE);
+ assert.equal(pts.length, 13, "the goal is not a weight");
+ assert.deepEqual(pts.map((p) => p.kind).slice(0, 5), ["stated", "stated", "remembered", "remembered", "stated"]);
+ assert.equal(pts[3].day, dayNumber("2008-06-30"), "a remembered weight stands at the day it was his weight");
+ assert.equal(trailPoints(MEASURE, { remembered: false }).length, 11);
+});
+
+test("at every moment the chart shows exactly the weights said by then, on axes that contain all of them", () => {
+ const pts = trailPoints(MEASURE);
+ const states = trailStates(pts, BOX, { mark: 300 });
+ assert.equal(states.length, 13);
+ for (const st of states) {
+ const shown = pts.filter((p) => p.t <= st.at);
+ assert.equal(st.shown.length, shown.length, `at ${st.at}`);
+ for (const p of shown) {
+ assert.ok(st.layout.lo <= p.value && p.value <= st.layout.hi, `at ${st.at}: ${p.value} inside ${st.layout.lo}–${st.layout.hi}`);
+ const { x, y } = st.pos.get(p.n);
+ assert.ok(x !== null && x >= BOX.x0 && x <= BOX.x1, `at ${st.at}: ${p.value} on the x axis (${x})`);
+ assert.ok(y >= BOX.y0 && y <= BOX.y1, `at ${st.at}: ${p.value} on the y axis (${y})`);
+ }
+ }
+ // The first weigh-in alone: in the middle of the strip, not pinned to its left edge.
+ const one = states[0].pos.get(0).x;
+ assert.ok(one > BOX.x0 + 100 && one < BOX.x1 - 100, `a lone point stands mid-strip (${one})`);
+ // The remembered ≈390 raises the top; the 2008 one moves the start of time back and keeps 390 in.
+ assert.ok(states[1].layout.hi < 390 && states[2].layout.hi >= 390);
+ assert.ok(states[3].pos.get(3).x < states[3].pos.get(0).x, "2008 stands left of 2013");
+ // The axes advance with the story: no 2026 on the axis until a 2026 weight is said.
+ const years = (st) => st.layout.years.map((y) => y.text);
+ assert.ok(!years(states[4]).includes("2026"));
+ assert.ok(years(states.at(-1)).includes("2026"));
+});
+
+test("the gap rule: a stretch longer than a year (or 8× the median spacing) breaks the time axis; the dense run gets the width", () => {
+ const pts = trailPoints(MEASURE);
+ // The median step between the dates here is 57 days: 8× is 456, past the year's floor.
+ assert.equal(gapThreshold(pts), 456);
+ assert.equal(gapThreshold([0, 7, 14, 21, 28].map((day) => ({ day }))), GAP_FLOOR_DAYS, "weekly statements: the year's floor rules");
+ assert.equal(gapThreshold(pts, 540), 540);
+ assert.equal(gapThreshold(pts, 0), Infinity);
+ // Spacing of 100 days: 8× is 800, past the floor.
+ const sparse = [0, 100, 200, 300, 400].map((day) => ({ day }));
+ assert.equal(gapThreshold(sparse), 800);
+ assert.deepEqual(clustersOf([1, 2, 500, 900, 901], 365), [{ first: 1, last: 2 }, { first: 500, last: 500 }, { first: 900, last: 901 }]);
+ const last = trailStates(pts, BOX, { mark: 300 }).at(-1);
+ // 2008 | 2013 | 2023 | 2025–26: three breaks, each a narrow band.
+ assert.equal(last.layout.clusters.length, 4);
+ assert.equal(last.layout.gaps.length, 3);
+ const dense = last.layout.clusters.at(-1);
+ assert.ok(dense.x1 - dense.x0 > 0.5 * (BOX.x1 - BOX.x0), `the 2025–26 run has most of the width (${dense.x1 - dense.x0} px)`);
+ // The line: stated neighbours only -- the remembered never joined -- dotted across a break.
+ const byN = new Map(pts.map((p) => [p.n, p]));
+ for (const pr of last.pairs) assert.ok(byN.get(pr.a).kind === "stated" && byN.get(pr.b).kind === "stated");
+ const across = last.pairs.find((pr) => byN.get(pr.a).value === 342.9);
+ assert.equal(across.gap, true, "2013 to 2025 is a dotted connector, not data");
+ assert.ok(last.pairs.filter((pr) => !pr.gap).length >= 8);
+ // gap: 0 -- one cluster, no breaks.
+ assert.equal(trailStates(pts, BOX, { gap: 0, mark: 300 }).at(-1).layout.gaps.length, 0);
+ // bounds: "fixed" -- every moment on the whole cut's axes.
+ const fixed = trailStates(pts, BOX, { bounds: "fixed", mark: 300 });
+ assert.equal(fixed[0].layout.hi, fixed.at(-1).layout.hi);
+});
+
+test("the page: points pop in where their moment puts them and move with every reflow, seek-safe; the knobs validate", () => {
+ const timeline = Array.from({ length: 4 }, (_, i) => ({ type: "clip", id: `c${i + 1}`, video: "v", start: 0, end: 100 }));
+ const render = { width: 1920, height: 1080, fps: 30, transition: 0.4, palette: { bg: "#0F1312", fg: "#EDF0EC", muted: "#98A29B", accent: "#22AB83", amber: "#E8A33F" },
+ chrome: { engine: "hyperframes", layout: "deck", deck: { dial: true, odometer: true, trail: true } } };
+ const schedule = { ...estimateSchedule({ slug: "m", title: "M", provenance: {}, render, timeline }), measure: MEASURE };
+ const html = trailHtml(schedule, render, { fonts: {} });
+ const data = JSON.parse(/<script id="trail-data" type="application\/json">(.*?)<\/script>/s.exec(html)[1]);
+ assert.match(html, /class="pt rem q" data-k="p2"/, "the remembered ≈390: hollow, grey, its qualifier dashed");
+ assert.match(html, /class="seg gap" data-k="s1_4"/, "2013 → 2025 dotted");
+ assert.ok(!/data-k="s\d+_2"|data-k="s2_\d+"/.test(html), "the remembered are never joined");
+ // p0 (the 2013 weigh-in) moves when the 2013 second weight lands, and again when 2008 pushes time back.
+ const moves = data.cues.filter((c) => c.k === "p0" && "x" in c.to).map((c) => c.at);
+ assert.ok(moves.includes(31) && moves.includes(100), `p0 reflows at 31 and 100 (${moves})`);
+ // Every cue states its from (seek-safe), and nothing changes at 0 that frame 0 cannot show.
+ assert.ok(data.cues.every((c) => Object.keys(c.to).every((k) => k in c.from)));
+ assert.deepEqual(validateTrail({ bounds: "fixed", remembered: false, gap: 540 }), []);
+ assert.match(validateTrail({ gap: 10 }).join(), /gap must be "auto", 0 \(no breaks\) or 30 to 3650 days/);
+ assert.match(validateTrail({ bounds: "loose" }).join(), /bounds must be "fit" or "fixed"/);
+});
diff --git a/umtool/report-to-video/vertical-deck.test.mjs b/umtool/report-to-video/vertical-deck.test.mjs
@@ -266,7 +266,10 @@ const MAIN = {
deck: "546848c82d65e45e4d1a4ac4c7a9c3c8",
dial: "f7e21e4a3622703975f746d39cbcb738",
odometer: "8425983d217408dddcb6ee794881c6c4",
- trail: "3512192be69f8b9bc33aec6e7b41a088",
+ // Re-pinned on lane/frame-zero (11 Nov): the trail's axes fit the weights said so far and reflow, its remembered
+ // weights are points, its time axis breaks over long empty stretches (trail-plan.mjs) -- the page is new by design.
+ // Main's was 3512192be69f8b9bc33aec6e7b41a088.
+ trail: "39c3694f4e26963277d9b22ebfd0f60b",
dialFinale: "52866e4d87e15bd55afe8c1a703414a3",
geometry: "182959796c281f769766df3d02962904",
bare: "7ce1f7a66452adec21575bcdbba900f1",