Archilyzer · Source

archilyzer

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

commit b00499778f73f7ec60c9dca471cfd1704298516a
parent 8d6ca18c87f91132916ce00f31b9d1c3077f9c9c
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri,  6 Nov 2026 17:11:01 -0500

umtool: the diet's tags fan sideways like the goal stack, with a running day count; the goals on the shelf

The operator on the A2 previews (6 Nov): "overlap the cards to save space and
put the goal alongside this new diet hud space"; "overlap cards like the goals
do but to the side, we can keep the cards the same color. The 'diet runs'
widget might be able to leave in favor of a 'x days' number showing on the
diet card."
- `deck.diet.overlap` (0-0.8, default 0: the row as it was): the share of each
  older tag behind the one in front. Above 0 the tags FAN like the goal stack's
  notes on their side -- the newest in front at the left, landing from above as
  a goal note lands (back.out), each older one a place to the right behind it
  with its own small turn and the stack's shadow, keeping its colours (no dim),
  its regime word and date in the strip that shows (a back face it crossfades
  to as it is pushed); the one past `tags` slides off the back. The fan is
  narrower by what hides (3 tags at 0.5: 440 design px, not 684). An older
  tag's word and date need 110 design px of it, so overlap is refused past 0.5
  (0.63 with days), naming the max.
- `deck.diet.days` (default false): the front tag's running "N days" on its
  diet -- dietDays, to the in-record date at the playhead, the streak chain's
  "Day N" (a test holds them equal) -- in a column of its own; the tag is 300
  wide then. So the streak can leave a shelf and its number stays.
- The goals' shelf form (`deck.goals.position: "shelf"`, goalsShelfHtml): the
  count of goals set in a column, then the notes (same paper, tape, ink) fanned
  sideways the same way, the newest landing on top, a repeat brought to the
  front with its ×n, the number popping at each goal; the dial keeps its goal.
  On the shelf it stays up (`hold` unset -> up from the first goal).
- shelfLayout: the goals' fan takes the shelf's spare width, up to its notes
  side by side, so the shelf ends on the fan, not a gap (this video: diet
  540 + 16 + goals 692 = 1248). A module on the shelf is scaled to its height
  (frameOf), so a widened slot widens the fan, not the type.
Docs: the diet's overlap/days rows, the goals' shelf row, the shelf's width
rule (knobs.md regenerated). Tests in shelf.test.mjs (widths, the refusal, the
page's z-order, back faces and landing, days = the streak's, the goals' form
and slot).

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 | 233++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
Mumtool/report-to-video/measure-extras.mjs | 80++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
Mumtool/report-to-video/modules/diet.mjs | 6+++++-
Mumtool/report-to-video/modules/goals.mjs | 1+
Mumtool/report-to-video/modules/measure-extras-settings.mjs | 32++++++++++++++++++++++++++++++--
Mumtool/report-to-video/modules/shelf.mjs | 2+-
Mumtool/report-to-video/shelf.test.mjs | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
8 files changed, 384 insertions(+), 39 deletions(-)

diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -1744,7 +1744,7 @@ Overlays on the picture -- receipts, a zoom, the scrubber, a kinetic quote, punc ### Shelf -A strip of the frame cleared beside the footage (`render.chrome.deck.shelf`, shelf-settings.mjs): the footage moves to the frame's top, `railGap` (24 px) in (`side: "below"`), or down onto the deck (`"above"`), and what it leaves -- as wide as the footage, 24 px clear of it and of the frame's edge or the deck -- is the shelf (beside the instruments' column, 1248×116 at (24, 750)). Everything that reads the footage box (the instruments, the posts, the chapter band, the finale, Play) follows it. Its occupants stand in it left to right in `items` order, `gap` apart, each at its own width scaled to the shelf's height (all a size down together when they would not fit): the measure extras that take `position: "shelf"` -- `diet` (its dated tags by default: `deck.diet.form`), `streak`, `goals`, `peak` -- and `note`, an entry's `shelfNote` in the width left (a chip that comes and goes with its entry; at least 160 px). Nothing covers the shelf, so its occupants never dodge a post card or a chapter band (an entry's `hideModules` still hides one). It needs 72 px of room or the deck refuses, naming the way out (a smaller `footageScale`, or `subtitle.lines 1`): with the instruments' column it is 116 px, 77 with `subtitle.lines: 2`; full-width footage at the default 0.82 leaves none. Off (absent, `false`), the footage stands where it always did. +A strip of the frame cleared beside the footage (`render.chrome.deck.shelf`, shelf-settings.mjs): the footage moves to the frame's top, `railGap` (24 px) in (`side: "below"`), or down onto the deck (`"above"`), and what it leaves -- as wide as the footage, 24 px clear of it and of the frame's edge or the deck -- is the shelf (beside the instruments' column, 1248×116 at (24, 750)). Everything that reads the footage box (the instruments, the posts, the chapter band, the finale, Play) follows it. Its occupants stand in it left to right in `items` order, `gap` apart, each at its own width scaled to the shelf's height (all a size down together when they would not fit; a goal stack on it takes the width left over, its notes fanning wider, so the shelf does not end in a gap): the measure extras that take `position: "shelf"` -- `diet` (its dated tags by default: `deck.diet.form`), `streak`, `goals`, `peak` -- and `note`, an entry's `shelfNote` in the width left (a chip that comes and goes with its entry; at least 160 px). Nothing covers the shelf, so its occupants never dodge a post card or a chapter band (an entry's `hideModules` still hides one). It needs 72 px of room or the deck refuses, naming the way out (a smaller `footageScale`, or `subtitle.lines 1`): with the instruments' column it is 116 px, 77 with `subtitle.lines: 2`; full-width footage at the default 0.82 leaves none. Off (absent, `false`), the footage stands where it always did. | Knob | Range · default | From a terminal | |---|---|---| @@ -1779,6 +1779,8 @@ 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.form`, `.tags` | `stamp` · `tags`: the last `tags` diets as a row of dated tags -- each a small stamp with the regime's word in its ink, "DIET #n" and the ledger's words (less the regime they open with: "5 carbs a day"), and the day he switched to it (`state.diet.since`, "Mar 14, 2025"; new words for the same diet keep that day); at each change the new tag slams in at the left, the older slide right and dim, the one past `tags` falls off; a change of words alone fades the new tag over the old; a null diet is a grey "NO DIET" tag with its date · 1–4 · default `stamp` (`tags` on the shelf), 3 | `umtool look <p> deck.diet.form=tags deck.diet.tags=2` | +| `deck.diet.overlap` | 0–0.8, the share of each older tag hidden behind the one in front · default 0 (side by side, the slam and the dim). Above 0 the tags FAN sideways the way the goal stack's notes pile: the newest in front at the left, landing from above like a goal note, each older one a place to the right behind it with its own small turn, keeping its colours (the depth is the overlap and the shadow), showing its regime word and date in the strip beside the one in front; the one past `tags` slides off the back. The fan is narrower by what hides. An older tag's word and date need 110 design px of it, so it is refused past 0.5 (0.63 with `days`) | `umtool look <p> deck.diet.overlap=0.5` | +| `deck.diet.days` | `true` · `false`: the front tag's running count of days on its diet (to the in-record date at the playhead, the streak chain's "Day N"), in a column of its own -- the tag 300 design px wide · default `false` | `umtool look <p> deck.diet.days=true` | | `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` | | `deck.diet.position=shelf` | in its own slot on the shelf (`deck.shelf`: under or over the footage), scaled to the shelf's height, left to right in `deck.shelf.items` order -- nothing covers it there, so it never dodges (`onPosts`, `onChapters`, `x`/`y`, `scale` and `avoid` do not apply), and it is over the finale as the shelf is (`deck.shelf.finale`) | `umtool look <p> deck.shelf=true deck.diet.position=shelf` | @@ -1806,6 +1808,7 @@ A sticky note per goal on a pile in a corner of the footage box, read off the sc |---|---|---| | `deck.goals` | `true` · `false` · `{show, position, x, y, scale, hold, finale, max, color, countdown}` · default on with a measure slice | `umtool look <p> deck.goals=false` | | `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.position=shelf` | its shelf form (`deck.shelf`): the count of goals set in a column, then the notes fanned sideways like the diet's tags -- the newest in front, landing from above as on the pile; each older one showing its goal's words in the strip beside it (all of each when there is room); a repeat comes to the front with its ×n. The fan takes the shelf's spare width (shelfLayout), up to its notes side by side. On the shelf it stays up from the first goal (`hold` unset). What the dial draws of the goal stays on the dial | `umtool look <p> deck.shelf.items='["diet","goals"]' deck.goals.position=shelf` | | `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` | diff --git a/umtool/report-to-video/chrome-measure-extras.mjs b/umtool/report-to-video/chrome-measure-extras.mjs @@ -16,10 +16,10 @@ import { formatDeckDate } from "./attribution.mjs"; import { rgba } from "./chrome-deck.mjs"; import { compileCues, cuePageHtml, esc, INSTANT, joinSpans, r4, spanEvents } from "./chrome-cues.mjs"; import { - daysBetween, daysLeftText, daysText, DIET_TAG, dietStates, goalStates, measureBox, measureExtraGeometry, measureOf, MEASURE_BOXES, promiseStripRect, promiseStripType, + daysBetween, daysLeftText, daysText, DIET_TAG, dietDays, dietStates, dietTagStep, goalStates, GOALS_SHELF, jitter, measureBox, measureExtraGeometry, measureOf, MEASURE_BOXES, promiseStripRect, promiseStripType, MEASURE_DODGE_MOVE, measurePlacements, monthYear, peakStates, promiseStates, shortDate, streakStates, upSpans, weightText, } from "./measure-extras.mjs"; -import { MEASURE_RED, resolveMeasureExtra } from "./modules/measure-extras-settings.mjs"; +import { dietTagWidth, MEASURE_RED, resolveMeasureExtra, SHELF_POSITION } from "./modules/measure-extras-settings.mjs"; import { dialFinaleGeometry, dialFinaleHandoff } from "./chrome-instruments.mjs"; /** How each module's panel comes in and goes out, s. */ @@ -30,7 +30,10 @@ const feedOf = (schedule) => schedule?.layout === "feed"; /** The page's frame: its region, its pixel scale against its design box, its fps. */ function frameOf(id, schedule, render) { const geo = measureExtraGeometry(id, render, { feed: feedOf(schedule) }); - const k = geo.width / measureBox(id, render).width; + // On the shelf a module is scaled to the shelf's HEIGHT: its slot may be wider than its box (the goals' fan + // takes the width left over) and is never narrower. + const box = measureBox(id, render); + const k = resolveMeasureExtra(id, render)?.position === SHELF_POSITION ? geo.height / box.height : geo.width / box.width; const px = (v) => Math.max(1, Math.round(v * k)); return { geo, k, px, fps: schedule.fps ?? render.fps ?? 30 }; } @@ -191,6 +194,7 @@ export function goalsHtml(schedule, render, opts = {}) { const m = measureOf(schedule); const states = goalStates(schedule, render); if (!cfg || !m || !states.length) throw new Error("goals: the schedule's measure slice has no goal on camera"); + if (cfg.position === SHELF_POSITION) return goalsShelfHtml(schedule, render, opts, cfg, states); const F = frameOf("goals", schedule, render); const { geo, px } = F; const H = geo.height; @@ -268,6 +272,116 @@ export function goalsHtml(schedule, render, opts = {}) { return { html: page("goals", schedule, opts, F, css, body, init, cues, states.map((_, j) => `s${j}`), render), items }; } +/** + * The goal stack ON THE SHELF (`goals.position: "shelf"`): the count of goals + * set in a column at the left, then the notes -- the same paper, tape, shadow + * and ink as the pile in the footage -- fanned sideways like the diet's tags, + * the newest in front landing from above (the pile's own landing), the older + * ones a place to the right behind it, each showing its goal's words in the + * strip beside the one in front (all of each when the slot is wide enough: + * shelfLayout gives the fan the shelf's spare width). A block per state, as the + * pile's: a repeat comes to the front with its count; the number of goals set + * pops at each. + */ +function goalsShelfHtml(schedule, render, opts, cfg, states) { + const F = frameOf("goals", schedule, render); + const { geo, px } = F; + const pal = render.palette; + const paper = cfg.color ?? pal.amber ?? "#E8A33F"; + const G = GOALS_SHELF; + const max = cfg.max ?? 4; + const room = geo.width / F.k - G.count - G.gap - G.card; + const step = max > 1 ? Math.max(G.back, Math.min(G.card + G.step, room / (max - 1))) : 0; + const backs = step < G.card; + const place = (note, depth) => ({ + x: px(G.count + G.gap + depth * step), + y: Math.round(px(6) + note.dx * 0.15 * F.k + (depth ? px(1) : 0)), + rotation: r4(note.rot * 0.45 + (depth ? (depth % 2 ? -1.4 : 1.2) : 0)), + }); + const spans = upSpans(states.map((s) => s.at), cfg, schedule); + const items = []; + const { init, cues } = stateCues(states, spans, { + own: (st, j, init) => { + const ev = []; + for (const n of st.notes) { + const k = `s${j}.${n.id}`; + const to = place(n, n.depth); + if (n.key === st.top) { + // The pile's landing: from above, turned, a size up -- onto the fan. + init[k] = { x: to.x - px(30), y: to.y - px(140), rotation: r4(to.rotation + 13), scale: 1.12, opacity: 0 }; + ev.push({ k, at: st.at, dur: 0.42, to: { x: to.x, y: to.y, rotation: to.rotation, scale: 1, opacity: 1 }, ease: "back.out(1.3)" }); + } else if (n.prev !== null && n.prev !== n.depth) { + const from = place(n, n.prev); + init[k] = { x: from.x, y: from.y, rotation: from.rotation }; + ev.push({ k, at: st.at, dur: 0.36, to: { x: to.x, y: to.y, rotation: to.rotation }, ease: "power2.out" }); + // Out of the front: its whole face gives way to the strip that shows beside the new one. + if (backs && n.prev === 0 && n.depth > 0) { + init[`${k}f`] = { opacity: 1 }; + init[`${k}b`] = { opacity: 0 }; + ev.push({ k: `${k}f`, at: st.at, dur: 0.3, to: { opacity: 0 }, ease: "power1.out" }); + ev.push({ k: `${k}b`, at: st.at + 0.1, dur: 0.3, to: { opacity: 1 }, ease: "power1.out" }); + } + } else { + init[k] = { x: to.x, y: to.y, rotation: to.rotation }; + } + } + init[`s${j}.c`] = { scale: 1.6, opacity: 0 }; + ev.push({ k: `s${j}.c`, at: st.at + 0.25, dur: 0.3, to: { scale: 1, opacity: 1 }, ease: "back.out(2.2)" }); + return ev; + }, + }); + const blocks = states.map((st, j) => { + const notes = st.notes.map((n) => { + const k = `s${j}.${n.id}`; + const dl = cfg.countdown && n.deadline + ? `<div class="dl">${esc(n.deadline)}${n.days !== null ? ` · ${esc(daysLeftText(n.days))}` : ""}${n.target !== null ? ` · needs ${esc(weightText(n.target))}` : ""}</div>` + : ""; + const count = n.count > 1 ? `<div class="ct">×${n.count}</div>` : ""; + const front = n.depth === 0 || !backs; + const crossing = backs && n.prev === 0 && n.depth > 0; + const face = `<div class="nf"${crossing ? ` data-k="${k}f"` : ""} style="opacity:${front || crossing ? 1 : 0}"><div class="nh">Goal${n.date ? ` · ${esc(monthYear(n.date))}` : ""}</div><div class="nt">${esc(n.text)}</div>${dl}</div>`; + const back = backs && n.depth > 0 + ? `<div class="nb"${crossing ? ` data-k="${k}b"` : ""} style="opacity:${crossing ? 0 : 1}"><div class="bt">${esc(n.text)}</div>${n.date ? `<div class="bh">${esc(monthYear(n.date))}</div>` : ""}</div>` + : ""; + return `<div class="note" data-k="${k}" style="z-index:${20 - n.depth}"><div class="tape"></div>${face}${back}${count}</div>`; + }).join(""); + const html = `<div class="st" data-k="s${j}"><div class="gc"><div class="gn" data-k="s${j}.c">${st.goalsSet}</div><div class="gl">goal${st.goalsSet === 1 ? "" : "s"} set</div></div>${notes}</div>`; + items.push({ key: `s${j}`, gate: [`s${j}`, "autoAlpha"], html }); + return html; + }); + const css = ` + #pn { position: absolute; inset: 0; visibility: hidden; opacity: 0; } + .st { position: absolute; inset: 0; visibility: hidden; opacity: 0; } + .gc { position: absolute; left: 0; top: 0; width: ${px(G.count)}px; height: ${px(G.height)}px; display: flex; flex-direction: column; + align-items: center; justify-content: center; border-radius: ${px(10)}px; background: ${rgba(pal.bg, 0.88)}; } + .gn { font-family: ${DISPLAY}; font-size: ${px(46)}px; line-height: ${px(46)}px; color: ${paper}; font-variant-numeric: tabular-nums; } + .gl { font-family: 'DeckSansBold', sans-serif; font-size: ${px(12)}px; line-height: ${px(15)}px; letter-spacing: 0.12em; text-transform: uppercase; + color: ${pal.muted}; text-align: center; } + .note { position: absolute; left: 0; top: 0; width: ${px(G.card)}px; height: ${px(G.height - 12)}px; border-radius: ${px(3)}px; color: #2a1c06; + background: linear-gradient(168deg, ${paper} 0%, ${paper} 62%, ${rgba(paper, 0.86)} 100%); + box-shadow: 0 ${px(8)}px ${px(18)}px rgba(0, 0, 0, 0.45), ${px(-4)}px 0 ${px(10)}px rgba(0, 0, 0, 0.3), 0 ${px(1)}px ${px(2)}px rgba(0, 0, 0, 0.3); } + .tape { position: absolute; left: 50%; top: ${px(-6)}px; width: ${px(70)}px; height: ${px(18)}px; margin-left: ${px(-35)}px; + background: rgba(255, 255, 255, 0.38); transform: rotate(-3deg); } + .nf { position: absolute; inset: 0; padding: ${px(8)}px ${px(14)}px; display: flex; flex-direction: column; justify-content: center; gap: ${px(1)}px; overflow: hidden; } + .nb { position: absolute; right: 0; top: 0; bottom: 0; width: ${px(Math.min(step, G.card) - 14)}px; padding: 0 ${px(6)}px; + display: flex; flex-direction: column; justify-content: center; align-items: center; overflow: hidden; } + .nh { font-family: 'DeckSansBold', sans-serif; font-size: ${px(13)}px; line-height: ${px(16)}px; letter-spacing: 0.14em; + text-transform: uppercase; color: rgba(42, 28, 6, 0.62); white-space: nowrap; } + .nt { font-family: ${DISPLAY}; font-size: ${px(40)}px; line-height: ${px(44)}px; white-space: nowrap; letter-spacing: 0.01em; } + .dl { font-family: 'DeckSansBold', sans-serif; font-size: ${px(13)}px; line-height: ${px(16)}px; color: #7d150c; white-space: nowrap; + overflow: hidden; text-overflow: ellipsis; } + .bt { font-family: ${DISPLAY}; font-size: ${px(24)}px; line-height: ${px(27)}px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; } + .bh { font-family: 'DeckSansBold', sans-serif; font-size: ${px(12)}px; line-height: ${px(15)}px; letter-spacing: 0.1em; text-transform: uppercase; + color: rgba(42, 28, 6, 0.62); white-space: nowrap; } + .ct { position: absolute; right: ${px(8)}px; top: ${px(5)}px; min-width: ${px(40)}px; height: ${px(24)}px; padding: 0 ${px(7)}px; + border-radius: ${px(12)}px; background: #2a1c06; color: ${paper}; text-align: center; + font-family: ${DISPLAY}; font-size: ${px(19)}px; line-height: ${px(24)}px; }`; + 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}`), render), items }; +} + // --------------------------------------------------------------------------- // PEAK: the moving start. // --------------------------------------------------------------------------- @@ -727,7 +841,18 @@ function dietTagsHtml(schedule, render, opts, cfg, states) { const SLIDE = 0.4; const DIM = 0.45; const n = cfg.tags ?? 3; - const slotX = (i) => px(i * (DIET_TAG.width + DIET_TAG.gap)); + const daysOn = cfg.days === true; + const W = dietTagWidth(daysOn); + const overlap = cfg.overlap ?? 0; + // FANNED (`overlap` > 0): the goal stack's look turned on its side -- each tag its own small turn and drop, + // the depth's tilt, the stack's shadow; the newest lands on top from above (the goal note's landing), the + // older ones slide a place right behind it and show their regime word and date in the strip beside it. They + // keep their colours: the depth is the overlap and the shadow. Side by side (0): the row, the slam and the dim. + const fan = overlap > 0; + const step = dietTagStep(overlap, daysOn); + const slotX = (i) => px(i * step); + const rotOf = (id, i) => (fan ? r4(jitter(`diet${id}`) * 1.8 + (i ? (i % 2 ? -1.6 : 1.3) : 0)) : 0); + const yOf = (id, i) => (fan ? Math.round(px(2) + jitter(`diet${id}`, 7) * px(2) + (i ? px(1) : 0)) : 0); const spans = upSpans(states.map((s) => s.at), cfg, schedule); const init = { pn: { autoAlpha: 0 } }; const ev = []; @@ -737,10 +862,11 @@ function dietTagsHtml(schedule, render, opts, cfg, states) { states.forEach((st) => { for (const t of st.tags) if (!tags.has(t.id)) tags.set(t.id, t); }); for (const id of tags.keys()) { const k = `t${id}`; - init[k] = { x: 0, autoAlpha: 0 }; + init[k] = { x: 0, y: yOf(id, 0), rotation: rotOf(id, 0), scale: 1, autoAlpha: 0 }; init[`${k}.d`] = { opacity: 1 }; init[`${k}.w`] = { x: 0 }; - init[`${k}.s`] = { scale: 1, rotation: -3, opacity: 1 }; + init[`${k}.s`] = { scale: 1, rotation: fan ? 0 : -3, opacity: 1 }; + if (fan) { init[`${k}.f`] = { opacity: 1 }; init[`${k}.b`] = { opacity: 0 }; } } states.forEach((st, j) => { const prev = j ? states[j - 1].tags.map((t) => t.id) : []; @@ -749,23 +875,37 @@ function dietTagsHtml(schedule, render, opts, cfg, states) { const front = cur[0]; if (!prev.includes(front)) { const k = `t${front}`; - ev.push({ k, at, dur: INSTANT, to: { x: 0, autoAlpha: 1 }, ease: "none" }); - if (st.slam) { - // The slam: in from big and turned, hard onto the shelf, then a shake. - init[`${k}.s`] = { scale: 2.3, rotation: -15, opacity: 0 }; - ev.push({ k: `${k}.s`, at, dur: SLAM, to: { scale: 1, rotation: -3, opacity: 1 }, ease: "power4.in" }); - [8, -6, 4, -2, 0].map((v) => Math.round(v * F.k)).forEach((x, m) => ev.push({ k: `${k}.w`, at: at + SLAM + m * 0.045, dur: 0.045, to: { x }, ease: "sine.inOut" })); + if (fan && !st.replaced && st.diet) { + // The goal note's landing: from above, turned, a size up -- onto the stack. + init[k] = { x: -px(30), y: yOf(front, 0) - px(140), rotation: r4(rotOf(front, 0) + 13), scale: 1.12, autoAlpha: 0 }; + ev.push({ k, at, dur: 0.42, to: { x: 0, y: yOf(front, 0), rotation: rotOf(front, 0), scale: 1, autoAlpha: 1 }, ease: "back.out(1.3)" }); } else { - init[`${k}.s`] = { scale: 1, rotation: -3, opacity: 0 }; - ev.push({ k: `${k}.s`, at, dur: 0.3, to: { opacity: 1 }, ease: "power1.out" }); + ev.push({ k, at, dur: INSTANT, to: { x: 0, autoAlpha: 1 }, ease: "none" }); + if (st.slam && !fan) { + // The slam: in from big and turned, hard onto the shelf, then a shake. + init[`${k}.s`] = { scale: 2.3, rotation: -15, opacity: 0 }; + ev.push({ k: `${k}.s`, at, dur: SLAM, to: { scale: 1, rotation: -3, opacity: 1 }, ease: "power4.in" }); + [8, -6, 4, -2, 0].map((v) => Math.round(v * F.k)).forEach((x, m) => ev.push({ k: `${k}.w`, at: at + SLAM + m * 0.045, dur: 0.045, to: { x }, ease: "sine.inOut" })); + } else { + init[`${k}.s`] = { scale: 1, rotation: fan ? 0 : -3, opacity: 0 }; + ev.push({ k: `${k}.s`, at, dur: 0.3, to: { opacity: 1 }, ease: "power1.out" }); + } } } - // The older ones a place to the right, dimmed. + // The older ones a place to the right: dimmed in the row; in the fan, behind the new one, its strip showing. cur.forEach((id, i) => { const p = prev.indexOf(id); if (p < 0 || p === i) return; - ev.push({ k: `t${id}`, at, dur: SLIDE, to: { x: slotX(i) }, ease: "power2.inOut" }); - ev.push({ k: `t${id}.d`, at, dur: SLIDE, to: { opacity: i === 0 ? 1 : DIM }, ease: "power1.out" }); + if (fan) { + ev.push({ k: `t${id}`, at, dur: 0.36, to: { x: slotX(i), y: yOf(id, i), rotation: rotOf(id, i) }, ease: "power2.out" }); + if (p === 0) { + ev.push({ k: `t${id}.f`, at, dur: 0.3, to: { opacity: 0 }, ease: "power1.out" }); + ev.push({ k: `t${id}.b`, at: at + 0.1, dur: 0.3, to: { opacity: 1 }, ease: "power1.out" }); + } + } else { + ev.push({ k: `t${id}`, at, dur: SLIDE, to: { x: slotX(i) }, ease: "power2.inOut" }); + ev.push({ k: `t${id}.d`, at, dur: SLIDE, to: { opacity: i === 0 ? 1 : DIM }, ease: "power1.out" }); + } }); // Off the row: the one replaced by new words fades where it stands; the one past `tags` slides off. for (const id of prev) { @@ -774,6 +914,34 @@ function dietTagsHtml(schedule, render, opts, cfg, states) { else ev.push({ k: `t${id}`, at, dur: SLIDE, to: { x: slotX(n), autoAlpha: 0 }, ease: "power2.in" }); } }); + // THE RUNNING DAY COUNT (`days`): on the front tag, the days on its diet to the in-record date at the playhead + // (dietDays), a number per stretch it holds -- cut wherever the count or the front tag changes. + const dayBlocks = new Map(); + if (daysOn) { + const counts = dietDays(schedule, render); + const cuts = [...new Set([...counts.map((c) => c.at), ...states.map((s) => s.at)])].sort((a, b) => a - b); + const end = Number(schedule.total) || 0; + const valueAt = (list, t) => { let v = null; for (const x of list) { if (x.at <= t + 1e-6) v = x; else break; } return v; }; + const runs = []; + cuts.forEach((t, i) => { + const st = valueAt(states, t); + const c = valueAt(counts, t); + const card = st?.diet && c && c.days !== null ? st.tags[0].id : null; + const days = card === null ? null : c.days; + const last = runs[runs.length - 1]; + const to = cuts[i + 1] ?? end; + if (last && last.card === card && last.days === days) { last.to = to; return; } + runs.push({ from: t, to, card, days }); + }); + runs.filter((r) => r.card !== null).forEach((r, m) => { + const k = `t${r.card}.y${m}`; + init[k] = { autoAlpha: 0 }; + ev.push({ k, at: r.from, dur: INSTANT, to: { autoAlpha: 1 }, ease: "none" }); + if (r.to < end - 1e-6) ev.push({ k, at: r.to, dur: INSTANT, to: { autoAlpha: 0 }, ease: "none" }); + if (!dayBlocks.has(r.card)) dayBlocks.set(r.card, []); + dayBlocks.get(r.card).push(`<div class="dy" data-k="${k}"><div class="dyn">${r.days}</div><div class="dyl">day${r.days === 1 ? "" : "s"}</div></div>`); + }); + } const { cues } = compileCues(init, ev); const items = []; const room = DIET_TAG.width - 44; @@ -788,23 +956,38 @@ function dietTagsHtml(schedule, render, opts, cfg, states) { const sub = d ? `<div class="sb"><span class="dn">Diet${d.n !== null ? ` #${d.n}` : ""}</span>${words ? `<span class="dd">${esc(words)}</span>` : ""}</div>` : `<div class="sb"><span class="dd">he says he is on none</span></div>`; - const html = `<div class="tg" data-k="${k}"><div class="dm" data-k="${k}.d"><div class="sw" data-k="${k}.w"><div class="sp${d ? "" : " off"}" data-k="${k}.s">` + - `<div class="ink" style="color:${ink};border-color:${ink}"><div class="lb" style="font-size:${px(size)}px;line-height:${px(Math.round(size * 1.02))}px">${esc(label)}</div>${sub}` + - `${date ? `<div class="dt">${esc(date)}</div>` : ""}</div></div></div></div></div>`; + const faceBody = `<div class="lb" style="font-size:${px(size)}px;line-height:${px(Math.round(size * 1.02))}px">${esc(label)}</div>${sub}` + + `${date ? `<div class="dt">${esc(date)}</div>` : ""}`; + const face = daysOn ? `<div class="fc">${faceBody}</div><div class="dc">${(dayBlocks.get(t.id) ?? []).join("")}</div>` : faceBody; + // The strip an older tag shows beside the one in front of it: its regime word and its date. + const back = fan + ? `<div class="bk" data-k="${k}.b"><div class="bl" style="font-size:${px(Math.min(32, tagWordSize(label, step - 30)))}px">${esc(label)}</div>${date ? `<div class="bd">${esc(date)}</div>` : ""}</div>` + : ""; + const html = `<div class="tg" data-k="${k}"${fan ? ` style="z-index:${10 + t.id}"` : ""}><div class="dm" data-k="${k}.d"><div class="sw" data-k="${k}.w"><div class="sp${d ? "" : " off"}" data-k="${k}.s">` + + `<div class="ink" style="color:${ink};border-color:${ink}"><div class="fr"${fan ? ` data-k="${k}.f"` : ""}>${face}</div>${back}</div></div></div></div></div>`; items.push({ key: k, gate: [k, "autoAlpha"], html }); return html; }); const css = ` #pn { position: absolute; inset: 0; visibility: hidden; opacity: 0; } - .tg { position: absolute; left: 0; top: 0; width: ${px(DIET_TAG.width)}px; height: ${px(DIET_TAG.height)}px; visibility: hidden; opacity: 0; } + .tg { position: absolute; left: 0; top: 0; width: ${px(W)}px; height: ${px(DIET_TAG.height)}px; visibility: hidden; opacity: 0;${fan ? " transform-origin: 30% 60%;" : ""} } .dm, .sw { position: absolute; inset: 0; } /* A tag: the stamp's plate and pressed ink, small. The plate is solid; only the ink is pressed. */ .sp { position: absolute; left: ${px(4)}px; top: ${px(4)}px; right: ${px(4)}px; bottom: ${px(4)}px; border-radius: ${px(8)}px; - background: ${rgba(pal.bg, 0.93)}; padding: ${px(4)}px; box-shadow: 0 ${px(6)}px ${px(16)}px rgba(0, 0, 0, 0.45); } - .ink { height: 100%; padding: ${px(3)}px ${px(10)}px ${px(4)}px; border: ${px(4)}px solid; border-radius: ${px(6)}px; - box-shadow: inset 0 0 0 ${px(2)}px ${rgba(pal.bg, 0.9)}, inset 0 0 0 ${px(3)}px currentColor; - display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; + background: ${rgba(pal.bg, fan ? 0.97 : 0.93)}; padding: ${px(4)}px; + box-shadow: ${fan ? `0 ${px(8)}px ${px(18)}px rgba(0, 0, 0, 0.5), ${px(-4)}px 0 ${px(10)}px rgba(0, 0, 0, 0.35)` : `0 ${px(6)}px ${px(16)}px rgba(0, 0, 0, 0.45)`}; } + .ink { position: relative; height: 100%; padding: ${px(3)}px ${px(10)}px ${px(4)}px; border: ${px(4)}px solid; border-radius: ${px(6)}px; + box-shadow: inset 0 0 0 ${px(2)}px ${rgba(pal.bg, 0.9)}, inset 0 0 0 ${px(3)}px currentColor; overflow: hidden; -webkit-mask-image: ${INK}; mask-image: ${INK}; -webkit-mask-size: ${px(240)}px ${px(120)}px; mask-size: ${px(240)}px ${px(120)}px; } + .fr { height: 100%; display: flex; ${daysOn ? "flex-direction: row; align-items: stretch;" : "flex-direction: column; align-items: center; justify-content: center;"} } + .fc { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; } + .dc { position: relative; flex: none; width: ${px(76)}px; margin-left: ${px(6)}px; border-left: ${px(2)}px solid ${rgba(pal.fg, 0.18)}; } + .dy { position: absolute; inset: 0; visibility: hidden; opacity: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; } + .dyn { font-family: ${DISPLAY}; font-size: ${px(40)}px; line-height: ${px(40)}px; font-variant-numeric: tabular-nums; } + .dyl { font-family: 'DeckSansBold', sans-serif; font-size: ${px(13)}px; line-height: ${px(16)}px; letter-spacing: 0.16em; text-transform: uppercase; color: ${pal.fg}; } + .bk { position: absolute; right: 0; top: 0; bottom: 0; width: ${px(step - 20)}px; display: flex; flex-direction: column; align-items: center; justify-content: center; } + .bl { font-family: ${DISPLAY}; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; line-height: 1.05; } + .bd { font-family: 'DeckSansBold', sans-serif; font-size: ${px(14)}px; line-height: ${px(18)}px; color: ${pal.fg}; white-space: nowrap; font-variant-numeric: tabular-nums; } .lb { font-family: ${DISPLAY}; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; } .sb { display: flex; align-items: baseline; justify-content: center; gap: ${px(8)}px; white-space: nowrap; max-width: 100%; } .dn { flex: none; font-family: 'DeckSansBold', sans-serif; font-size: ${px(14)}px; line-height: ${px(18)}px; letter-spacing: 0.14em; text-transform: uppercase; } diff --git a/umtool/report-to-video/measure-extras.mjs b/umtool/report-to-video/measure-extras.mjs @@ -27,7 +27,7 @@ // off-scope rule: this only draws state.diet). import { deckGeometry, feedGeometry, instrumentsGeometry } from "./deck.mjs"; import { chapterCover, chapterWindows } from "./chrome-story.mjs"; -import { MEASURE_EXTRAS, MEASURE_POSITIONS, resolveMeasureExtra, SHELF_POSITION } from "./modules/measure-extras-settings.mjs"; +import { dietTagWidth, MEASURE_EXTRAS, MEASURE_POSITIONS, resolveMeasureExtra, SHELF_POSITION } from "./modules/measure-extras-settings.mjs"; import { resolveShelf } from "./modules/shelf-settings.mjs"; const r4 = (v) => Math.round(v * 10000) / 10000; @@ -510,6 +510,34 @@ export function dietStates(schedule, render) { }); } +/** + * The diet's running day count (`diet.days`, on its front tag): `{ at, days, + * run }` wherever it changes -- the days on the current diet (dietRuns: its + * `since`, a new regime or diet number a new run) to the in-record date at the + * playhead (the running latest date of every event so far), the same number + * the streak chain's "Day N" reads; `run` null while no diet is on. + */ +export function dietDays(schedule, render) { + const m = measureOf(schedule); + const cfg = resolveMeasureExtra("diet", render); + if (!m || !cfg) return []; + const runs = dietRuns(m, cfg); + const out = []; + let date = null; + for (const { e } of stepsOf(m)) { + if (e.date) date = isoMax(date, e.date); + const t = e.t; + const run = runs.findIndex((r) => r.startT <= t + 1e-6 && (r.endT === null || r.endT > t + 1e-6)); + if (run < 0 && !out.length) continue; + const days = run >= 0 ? runDays(runs[run], isoMax(runs[run].start, date)) : null; + const last = out[out.length - 1]; + if (last && last.days === days && last.run === (run >= 0 ? run : null)) continue; + if (last && Math.abs(last.at - t) < 1e-6) out.pop(); + out.push({ at: r4(t), days, run: run >= 0 ? run : null }); + } + return out; +} + // --------------------------------------------------------------------------- // STREAK: a chain per run, cracked when it ends. // --------------------------------------------------------------------------- @@ -693,15 +721,41 @@ export const MEASURE_BOXES = Object.freeze({ /** One diet tag (`diet.form: "tags"`), design px: its width, the air between two, and the row's height. */ export const DIET_TAG = Object.freeze({ width: 220, gap: 12, height: 116 }); -/** The diet's row of `n` tags, design px. */ -export const dietTagsBox = (n) => ({ width: n * DIET_TAG.width + (n - 1) * DIET_TAG.gap, height: DIET_TAG.height }); +/** + * Where tag `i` (0 the newest) stands from the row's left, design px: side by + * side `gap` apart, or -- `overlap` above 0 -- fanned, each older one shifted + * right by the share of a tag that shows (`1 - overlap`). + */ +export const dietTagStep = (overlap = 0, days = false) => + (overlap > 0 ? Math.round(dietTagWidth(days) * (1 - overlap)) : dietTagWidth(days) + DIET_TAG.gap); + +/** The diet's row (or fan) of `n` tags, design px. */ +export const dietTagsBox = (n, overlap = 0, days = false) => ({ + width: dietTagWidth(days) + (n - 1) * dietTagStep(overlap, days), + height: DIET_TAG.height, +}); + +/** + * The goal stack ON THE SHELF (`goals.position: "shelf"`), design px: the + * count of goals set in a column at the left, then the notes fanned sideways + * like the diet's tags -- the newest in front -- each older one showing at + * least `back` (its goal's words), more when the shelf has width to give + * (shelfLayout). `natural` is that tightest fan, `widest` the notes side by side. + */ +export const GOALS_SHELF = Object.freeze({ count: 84, gap: 10, card: 250, back: 110, height: 116, step: 12 }); +export const goalsShelfWidth = (max, { widest = false } = {}) => + GOALS_SHELF.count + GOALS_SHELF.gap + GOALS_SHELF.card + (max - 1) * (widest ? GOALS_SHELF.card + GOALS_SHELF.step : GOALS_SHELF.back); -/** A module's design box: the promise clock's compact one in the column, the diet's row of tags. */ +/** A module's design box: the promise clock's compact one in the column, the diet's row of tags, the goals on the shelf. */ export function measureBox(id, render) { if (id === "promise" && resolveMeasureExtra("promise", render)?.slot === "column") return MEASURE_BOXES.promiseColumn; if (id === "diet") { const cfg = resolveMeasureExtra("diet", render); - if (cfg?.form === "tags") return dietTagsBox(cfg.tags ?? 3); + if (cfg?.form === "tags") return dietTagsBox(cfg.tags ?? 3, cfg.overlap ?? 0, cfg.days === true); + } + if (id === "goals") { + const cfg = resolveMeasureExtra("goals", render); + if (cfg?.position === SHELF_POSITION) return { width: goalsShelfWidth(cfg.max ?? 4), height: GOALS_SHELF.height }; } return MEASURE_BOXES[id]; } @@ -715,7 +769,9 @@ export const SHELF_NOTE_MIN = 160; * no shelf. Left to right in `items` order, `gap` apart: each measure extra on * it at its own design box scaled to the shelf's height (all of them a size * down together, centred in the height, when they would not fit its width); - * the note takes what width is left at its place (none under SHELF_NOTE_MIN). + * the goals' fan widens into what width is left (up to its notes side by + * side), then the note takes what is still left at its place (none under + * SHELF_NOTE_MIN). * An item that is off takes no slot. */ export function shelfLayout(render) { @@ -732,7 +788,17 @@ export function shelfLayout(render) { const fit = fixed > 0 ? Math.min(1, (rect.width - gaps) / fixed) : 1; const h = Math.max(2, evenDown(rect.height * fit)); const widths = boxes.map((b) => (b ? evenDown((b.width * h) / b.height) : 0)); - const rest = rect.width - widths.reduce((a, b) => a + b, 0) - gaps; + let rest = rect.width - widths.reduce((a, b) => a + b, 0) - gaps; + // The goals' fan takes the width left over, up to its notes side by side: its older notes show more of + // themselves rather than the shelf ending in a gap. (Then the note, in what is still left.) + const gi = items.indexOf("goals"); + if (gi >= 0 && rest > 0) { + const cfg = resolveMeasureExtra("goals", render); + const widest = evenDown((goalsShelfWidth(cfg.max ?? 4, { widest: true }) * h) / GOALS_SHELF.height); + const more = Math.max(0, Math.min(rest, widest - widths[gi])); + widths[gi] += evenDown(more); + rest -= evenDown(more); + } const noteW = items.includes("note") && rest >= SHELF_NOTE_MIN * k ? evenDown(rest) : 0; const slots = {}; let x = rect.x; diff --git a/umtool/report-to-video/modules/diet.mjs b/umtool/report-to-video/modules/diet.mjs @@ -8,7 +8,7 @@ import { dietHtml } from "../chrome-measure-extras.mjs"; import { dietStates } from "../measure-extras.mjs"; import { measureExtraModule } from "./measure-extras-module.mjs"; -import { DIET_FORMS, DIET_TAGS } from "./measure-extras-settings.mjs"; +import { DIET_BACK_MIN, DIET_FORMS, DIET_OVERLAP, DIET_TAGS, dietOverlapMax } from "./measure-extras-settings.mjs"; export default measureExtraModule({ id: "diet", @@ -23,6 +23,8 @@ export default measureExtraModule({ { key: "labels", type: "object", label: "Words per regime ({glp1: \"Ozempic\", …})" }, { key: "form", type: "enum", options: DIET_FORMS, label: "Drawn as (default: the stamp, the tags on the shelf)" }, { key: "tags", type: "number", min: DIET_TAGS[0], max: DIET_TAGS[1], step: 1, label: "Tags in the row", default: 3, when: { form: "tags" } }, + { key: "overlap", type: "number", min: DIET_OVERLAP[0], max: DIET_OVERLAP[1], step: 0.05, label: "Overlap (0: side by side; the share of each older tag behind the one in front)", default: 0, when: { form: "tags" } }, + { key: "days", type: "boolean", label: "Days on the diet, on the front tag", default: false, when: { form: "tags" } }, ], docs: { intro: "The diet he names as a rubber stamp in a corner of the footage box (`render.chrome.deck.diet`, measure-extras.mjs): at each change of the state's diet -- its regime or its diet number -- a new stamp slams on (in big and turned, onto the page, a shake), the regime's word in its ink and \"DIET #n\" under it with the ledger's words when they say more (\"Keto · 5 carbs a day\"); a change of words alone fades the new stamp in. A null diet after one fades to \"NO DIET\" in grey. It draws `state.diet` as the measure slice gives it -- the off-scope rule (\"off GLP-1\" while on keto is still keto) is the ledger's. The inks default to the quartering-diet regimes' (keto #E0913C, carnivore #C9534B, fasting #4E9BD8, calories #3FA9A0, glp1 #B168C6, other #8E97A8, off #98A29B).", @@ -31,6 +33,8 @@ export default measureExtraModule({ ["`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.form`, `.tags`", "`stamp` · `tags`: the last `tags` diets as a row of dated tags -- each a small stamp with the regime's word in its ink, \"DIET #n\" and the ledger's words (less the regime they open with: \"5 carbs a day\"), and the day he switched to it (`state.diet.since`, \"Mar 14, 2025\"; new words for the same diet keep that day); at each change the new tag slams in at the left, the older slide right and dim, the one past `tags` falls off; a change of words alone fades the new tag over the old; a null diet is a grey \"NO DIET\" tag with its date · 1–4 · default `stamp` (`tags` on the shelf), 3", "`umtool look <p> deck.diet.form=tags deck.diet.tags=2`"], + ["`deck.diet.overlap`", `${DIET_OVERLAP[0]}–${DIET_OVERLAP[1]}, the share of each older tag hidden behind the one in front · default 0 (side by side, the slam and the dim). Above 0 the tags FAN sideways the way the goal stack's notes pile: the newest in front at the left, landing from above like a goal note, each older one a place to the right behind it with its own small turn, keeping its colours (the depth is the overlap and the shadow), showing its regime word and date in the strip beside the one in front; the one past \`tags\` slides off the back. The fan is narrower by what hides. An older tag's word and date need ${DIET_BACK_MIN} design px of it, so it is refused past ${dietOverlapMax(false)} (${dietOverlapMax(true)} with \`days\`)`, "`umtool look <p> deck.diet.overlap=0.5`"], + ["`deck.diet.days`", "`true` · `false`: the front tag's running count of days on its diet (to the in-record date at the playhead, the streak chain's \"Day N\"), in a column of its own -- the tag 300 design px wide · default `false`", "`umtool look <p> deck.diet.days=true`"], ["`deck.diet.colors`, `.labels`", "`{<regime>: #hex}` · `{<regime>: words ≤40}` · default the regimes' inks and names", "`umtool look <p> deck.diet.labels='{\"glp1\":\"Ozempic\"}'`"], ], }, diff --git a/umtool/report-to-video/modules/goals.mjs b/umtool/report-to-video/modules/goals.mjs @@ -28,6 +28,7 @@ export default measureExtraModule({ rows: [ ["`deck.goals`", "`true` · `false` · `{show, position, x, y, scale, hold, finale, max, color, countdown}` · default on with a measure slice", "`umtool look <p> deck.goals=false`"], ["`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.position=shelf`", "its shelf form (`deck.shelf`): the count of goals set in a column, then the notes fanned sideways like the diet's tags -- the newest in front, landing from above as on the pile; each older one showing its goal's words in the strip beside it (all of each when there is room); a repeat comes to the front with its ×n. The fan takes the shelf's spare width (shelfLayout), up to its notes side by side. On the shelf it stays up from the first goal (`hold` unset). What the dial draws of the goal stays on the dial", "`umtool look <p> deck.shelf.items='[\"diet\",\"goals\"]' deck.goals.position=shelf`"], ["`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`"], ], diff --git a/umtool/report-to-video/modules/measure-extras-settings.mjs b/umtool/report-to-video/modules/measure-extras-settings.mjs @@ -9,7 +9,7 @@ // render.chrome.deck.goals { show, position, x, y, scale, hold, finale, max, color, countdown } // render.chrome.deck.peak { show, position, x, y, scale, hold, finale, title, color, values } // render.chrome.deck.promise { show, position, x, y, scale, hold, finale, label, verb, kept, broken, checks, speakers, claimVerb, claimColor } -// render.chrome.deck.diet { show, position, x, y, scale, hold, finale, colors, labels, form, tags } +// render.chrome.deck.diet { show, position, x, y, scale, hold, finale, colors, labels, form, tags, overlap, days } // render.chrome.deck.streak { show, position, x, y, scale, hold, finale, source, axis, title, color, colors, labels } // // Each is ON whenever the cut has a measure slice (the build writes one only @@ -70,6 +70,24 @@ export const DIET_FORMS = Object.freeze(["stamp", "tags"]); /** How many tags the diet's row keeps (`diet.tags`). */ export const DIET_TAGS = Object.freeze([1, 4]); +/** + * How much of each older tag hides behind the one in front (`diet.overlap`): + * 0 is the row of tags side by side; above it the tags fan sideways like the + * goal stack's notes, the newest in front at the left. The bounds a value is + * checked against; legibility caps it lower (dietOverlapMax: an older tag's + * regime word and date need DIET_BACK_MIN of it). + */ +export const DIET_OVERLAP = Object.freeze([0, 0.8]); + +/** The design px of an older tag that must show beside the one in front of it: its regime word and its date. */ +export const DIET_BACK_MIN = 110; + +/** A diet tag's width, design px: 220, or 300 with the running day count (`diet.days`) in a column of its own. */ +export const dietTagWidth = (days) => (days ? 300 : 220); + +/** The most overlap that keeps an older tag's regime word and date in view. */ +export const dietOverlapMax = (days) => Math.floor((1 - DIET_BACK_MIN / dietTagWidth(days)) * 100) / 100; + /** The diet regimes the ledger names (ledgerSchema.regimes), and what the badge calls each. */ export const DIET_LABELS = Object.freeze({ keto: "Keto", carnivore: "Carnivore", fasting: "Fasting", calories: "Counting calories", @@ -116,7 +134,7 @@ export const MEASURE_DEFAULTS = Object.freeze({ speakers: Object.freeze({}), claimVerb: "paid", claimColor: "#E37AB8", slot: "auto" }), // The diet badge: up from the first diet on, re-stamped at every change. // `form` "tags" (the default on the shelf): the last `tags` diets as dated tags, the newest slammed in at the left. - diet: Object.freeze({ ...COMMON, position: "bottom-left", colors: Object.freeze({}), labels: Object.freeze({}), form: "stamp", tags: 3 }), + diet: Object.freeze({ ...COMMON, position: "bottom-left", colors: Object.freeze({}), labels: Object.freeze({}), form: "stamp", tags: 3, overlap: 0, days: false }), // The streak chain: bottom-centre, between the diet badge and the goal // stack, so either or both can run. `title` null is the source's own word. streak: Object.freeze({ ...COMMON, position: "bottom-center", source: "diet", axis: "date", title: null, color: null, colors: Object.freeze({}), labels: Object.freeze({}) }), @@ -168,6 +186,8 @@ export function resolveMeasureExtra(id, render) { if (shelf && SHELF_EXTRAS.includes(id) && (shelf.items.includes(id) || own.position === SHELF_POSITION)) { out.position = SHELF_POSITION; out.finale = shelf.finale; + // The shelf is a HUD: what stands on it stays up from its first event (`hold` unset), the goals too. + if (own.hold === undefined) out.hold = null; if (id === "diet" && own.form === undefined) out.form = "tags"; } else if (out.position === SHELF_POSITION) { // No shelf to stand on (validateMeasureExtra says so): its default anchor, so a stray key draws something. @@ -279,6 +299,14 @@ export function validateMeasureExtra(id, v, where = `render.chrome.deck.${id}`, if (v.tags !== undefined && !(Number.isInteger(v.tags) && numIn(v.tags, DIET_TAGS[0], DIET_TAGS[1]))) { errors.push(`${where}.tags must be a whole number from ${DIET_TAGS[0]} to ${DIET_TAGS[1]}`); } + if (v.days !== undefined && typeof v.days !== "boolean") errors.push(`${where}.days must be true or false`); + if (v.overlap !== undefined) { + const max = dietOverlapMax(v.days === true); + if (!numIn(v.overlap, DIET_OVERLAP[0], DIET_OVERLAP[1])) errors.push(`${where}.overlap must be from ${DIET_OVERLAP[0]} to ${DIET_OVERLAP[1]}`); + else if (v.overlap > max) { + errors.push(`${where}.overlap ${v.overlap} hides an older tag's regime word and date: they need ${DIET_BACK_MIN} of its ${dietTagWidth(v.days === true)} design px (overlap at most ${max}${v.days === true ? "" : `, or ${dietOverlapMax(true)} with days`})`); + } + } } if (id === "diet" || id === "streak") { for (const k of ["colors", "labels"]) { diff --git a/umtool/report-to-video/modules/shelf.mjs b/umtool/report-to-video/modules/shelf.mjs @@ -35,7 +35,7 @@ export default defineModule({ ], docs: { heading: "Shelf", - intro: `A strip of the frame cleared beside the footage (\`render.chrome.deck.shelf\`, shelf-settings.mjs): the footage moves to the frame's top, \`railGap\` (24 px) in (\`side: "below"\`), or down onto the deck (\`"above"\`), and what it leaves -- as wide as the footage, 24 px clear of it and of the frame's edge or the deck -- is the shelf (beside the instruments' column, 1248×116 at (24, 750)). Everything that reads the footage box (the instruments, the posts, the chapter band, the finale, Play) follows it. Its occupants stand in it left to right in \`items\` order, \`gap\` apart, each at its own width scaled to the shelf's height (all a size down together when they would not fit): the measure extras that take \`position: "shelf"\` -- \`diet\` (its dated tags by default: \`deck.diet.form\`), \`streak\`, \`goals\`, \`peak\` -- and \`note\`, an entry's \`shelfNote\` in the width left (a chip that comes and goes with its entry; at least 160 px). Nothing covers the shelf, so its occupants never dodge a post card or a chapter band (an entry's \`hideModules\` still hides one). It needs ${SHELF_MIN} px of room or the deck refuses, naming the way out (a smaller \`footageScale\`, or \`subtitle.lines 1\`): with the instruments' column it is 116 px, 77 with \`subtitle.lines: 2\`; full-width footage at the default 0.82 leaves none. Off (absent, \`false\`), the footage stands where it always did.`, + intro: `A strip of the frame cleared beside the footage (\`render.chrome.deck.shelf\`, shelf-settings.mjs): the footage moves to the frame's top, \`railGap\` (24 px) in (\`side: "below"\`), or down onto the deck (\`"above"\`), and what it leaves -- as wide as the footage, 24 px clear of it and of the frame's edge or the deck -- is the shelf (beside the instruments' column, 1248×116 at (24, 750)). Everything that reads the footage box (the instruments, the posts, the chapter band, the finale, Play) follows it. Its occupants stand in it left to right in \`items\` order, \`gap\` apart, each at its own width scaled to the shelf's height (all a size down together when they would not fit; a goal stack on it takes the width left over, its notes fanning wider, so the shelf does not end in a gap): the measure extras that take \`position: "shelf"\` -- \`diet\` (its dated tags by default: \`deck.diet.form\`), \`streak\`, \`goals\`, \`peak\` -- and \`note\`, an entry's \`shelfNote\` in the width left (a chip that comes and goes with its entry; at least 160 px). Nothing covers the shelf, so its occupants never dodge a post card or a chapter band (an entry's \`hideModules\` still hides one). It needs ${SHELF_MIN} px of room or the deck refuses, naming the way out (a smaller \`footageScale\`, or \`subtitle.lines 1\`): with the instruments' column it is 116 px, 77 with \`subtitle.lines: 2\`; full-width footage at the default 0.82 leaves none. Off (absent, \`false\`), the footage stands where it always did.`, rows: [ ["`deck.shelf`", "`true` · `false` · `{show, side, items, gap, finale}` · default off", "`umtool look <p> deck.shelf=true deck.diet.position=shelf deck.streak.position=shelf`"], ["`deck.shelf.side`", "`below` (the footage at the top) · `above` (the footage on the deck) · default `below`", "`umtool look <p> deck.shelf.side=above`"], diff --git a/umtool/report-to-video/shelf.test.mjs b/umtool/report-to-video/shelf.test.mjs @@ -10,10 +10,10 @@ import path from "node:path"; import test from "node:test"; import { fileURLToPath } from "node:url"; -import { dietHtml, tagWords, tagWordSize } from "./chrome-measure-extras.mjs"; +import { dietHtml, goalsHtml, tagWords, tagWordSize } from "./chrome-measure-extras.mjs"; import { shelfHtml, shelfNoteGeometry } from "./chrome-shelf.mjs"; import { deckGeometry, entryShelfNotes, estimateSchedule, instrumentsGeometry, parseShelfNote, validateChrome } from "./deck.mjs"; -import { dietStates, measureExtraGeometry, measurePlacements, shelfLayout } from "./measure-extras.mjs"; +import { dietDays, dietStates, goalStates, dietTagsBox, GOALS_SHELF, goalsShelfWidth, measureExtraGeometry, measurePlacements, shelfLayout, streakStates } from "./measure-extras.mjs"; import { slotRect } from "./modules/layout.mjs"; import { moduleById, moduleProblems, scheduleSlices } from "./modules/index.mjs"; import { resolveMeasureExtra, validateMeasureExtra } from "./modules/measure-extras-settings.mjs"; @@ -202,3 +202,63 @@ test("the shelf's note: an entry's shelfNote over its span, only with the shelf assert.match(html, /Weighed in on camera/); assert.match(mod.check(s, renderOf(INSTRUMENTS)), /shelf region is off/); }); + +// --------------------------------------------------------------------------- +// THE FAN (operator, 6 Nov: "overlap cards like the goals do but to the side, we can keep the cards the same +// color ... a 'x days' number showing on the diet card"; "put the goal alongside this new diet hud space"). +// --------------------------------------------------------------------------- + +const FAN = { ...INSTRUMENTS, shelf: { items: ["diet", "goals"] }, diet: { position: "shelf", overlap: 0.6, days: true }, goals: { position: "shelf" }, streak: false }; + +test("overlap: the tags fan sideways, the width shrinking by what hides; capped where an older tag's word and date still show", () => { + assert.deepEqual(dietTagsBox(3), { width: 684, height: 116 }, "0: the row as it was"); + assert.deepEqual(dietTagsBox(3, 0.5), { width: 220 + 2 * 110, height: 116 }); + assert.deepEqual(dietTagsBox(3, 0.6, true), { width: 300 + 2 * 120, height: 116 }, "with the day count a tag is 300 wide"); + assert.match(validateMeasureExtra("diet", { overlap: 0.6 }).join(), /overlap 0\.6 hides an older tag's regime word and date: they need 110 of its 220 design px \(overlap at most 0\.5, or 0\.63 with days\)/); + assert.deepEqual(validateMeasureExtra("diet", { overlap: 0.6, days: true }), []); + assert.match(validateMeasureExtra("diet", { overlap: 0.9, days: true }).join(), /overlap must be from 0 to 0\.8/); + assert.match(validateMeasureExtra("diet", { days: "yes" }).join(), /days must be true or false/); + assert.deepEqual(validateChrome(renderOf(FAN).chrome, renderOf(FAN)), []); +}); + +test("the page: older tags behind the newest, their own colours (no dim), each with its strip; the newest lands like a goal note", () => { + const r = renderOf(FAN); + const { html, items } = dietHtml(schedule(), r, { fonts: {} }); + assert.match(html, /class="tg" data-k="t3" style="z-index:13"/, "the newer, the nearer"); + assert.match(html, /<div class="bk" data-k="t0\.b">/, "the strip an older tag shows"); + assert.ok(!/"k":"t\d+\.d","at":[\d.]+,"dur":[\d.]+,"from":\{"opacity":1\},"to":\{"opacity":0\.45/.test(html), "nothing dims"); + assert.match(html, /"to":\{"x":0,"y":-?\d+,"rotation":-?[\d.]+,"scale":1,"autoAlpha":1\},"ease":"back\.out\(1\.3\)"/, "the goal note's landing"); + assert.ok(items.length > 0); + // The region is the fan's, at the shelf's height. + assert.deepEqual(measureExtraGeometry("diet", r), { x: 24, y: 750, width: 540, height: 116 }); +}); + +test("days: the front tag's running count is the streak chain's day count, to the in-record date at the playhead", () => { + const withStreak = renderOf({ ...FAN, streak: { position: "bottom-center" } }); + const days = dietDays(schedule(), withStreak); + const { states } = streakStates(schedule(), withStreak); + for (const st of states.filter((x) => x.live)) { + const d = [...days].reverse().find((x) => x.at <= st.at + 1e-6); + assert.equal(d.days, st.live.days, `at ${st.at}`); + } + const { html } = dietHtml(schedule(), renderOf(FAN), { fonts: {} }); + assert.match(html, /<div class="dy" data-k="t\d+\.y\d+"><div class="dyn">\d+<\/div><div class="dyl">days?<\/div><\/div>/); + // Off (the default): no count, the tag as it was. + assert.doesNotMatch(dietHtml(schedule(), renderOf(SHELF), { fonts: {} }).html, /class="dy"/); +}); + +test("goals on the shelf: the count and the fanned notes, the fan taking the shelf's spare width", () => { + const r = renderOf(FAN); + assert.equal(goalsShelfWidth(4), GOALS_SHELF.count + GOALS_SHELF.gap + 250 + 3 * 110); + const L = shelfLayout(r); + assert.deepEqual(L.slots.diet, { x: 24, y: 750, width: 540, height: 116 }); + assert.deepEqual(L.slots.goals, { x: 24 + 540 + 16, y: 750, width: 1248 - 540 - 16, height: 116 }, "no gap at the shelf's end"); + assert.equal(resolveMeasureExtra("goals", r).hold, null, "on the shelf it stays up"); + const { html, items } = goalsHtml(schedule(), r, { fonts: {} }); + assert.match(html, /<div class="gc"><div class="gn" data-k="s0\.c">1<\/div><div class="gl">goal set<\/div><\/div>/); + assert.match(html, /class="note" data-k="s\d+\.n\d+" style="z-index:19"><div class="tape"><\/div><div class="nf"/); + assert.match(html, /<div class="nb"[^>]*><div class="bt">LOSE 100<\/div>/, "an older note shows its words beside the one in front"); + assert.equal(items.length, goalStates(schedule(), r).length); + // Off the shelf: the pile in the footage, as it was. + assert.doesNotMatch(goalsHtml(schedule(), renderOf(INSTRUMENTS), { fonts: {} }).html, /class="gc"/); +});