Archilyzer · Source

archilyzer

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

commit 8bc4344059cfcb6e4c4757fcece498c829db03d4
parent d3c7a01baa54384419feaeb9a9762068df29fe45
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri,  6 Nov 2026 03:41:00 -0500

Merge lane/rev9-fixes (polish): the dial's as-of and wedge labels never sit on a scale figure; the promise footage strip at 22 px (operator, 5 Nov: "Make variants for me to judge")

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

Diffstat:
Mumtool/report-to-video/chrome-instruments.mjs | 83++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
Mumtool/report-to-video/chrome-measure-extras.mjs | 11++++++++---
Mumtool/report-to-video/measure-draw.mjs | 40++++++++++++++++++++++++++++++++++------
Mumtool/report-to-video/measure-extras.mjs | 31+++++++++++++++++++++++++++++--
Mumtool/report-to-video/rev9-panel.test.mjs | 9++++++++-
5 files changed, 153 insertions(+), 21 deletions(-)

diff --git a/umtool/report-to-video/chrome-instruments.mjs b/umtool/report-to-video/chrome-instruments.mjs @@ -21,7 +21,7 @@ import { resolveDial, resolveOdometer, resolveTrail } from "./instruments.mjs"; import { promiseStates, upSpans } from "./measure-extras.mjs"; import { resolveMeasureExtra } from "./modules/measure-extras-settings.mjs"; import { - cueList, dayNumber, dialAngle, dialFaceSvg, DIAL_SWEEP, esc, fmtDate, fmtSigned, fmtWeight, INSTANT, measureTrack, + cueList, dayNumber, dialAngle, dialFaceSvg, dialFigures, DIAL_SWEEP, esc, fmtDate, fmtSigned, fmtWeight, INSTANT, measureTrack, pageHtml, polar, qualifierMark, r4, sectorPath, wedgeRange, weightWords, wheelCount, wheelRoll, wheelStrip, } from "./measure-draw.mjs"; @@ -123,6 +123,56 @@ export const goalWords = (g) => { // The dial. // --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// Words on the face, kept off its figures. +// --------------------------------------------------------------------------- + +/** Whether boxes `a` and `b` ({x0, x1, y0, y1}) come within `m` px of each other. */ +const boxesTouch = (a, b, m = 0) => a.x0 < b.x1 + m && b.x0 < a.x1 + m && a.y0 < b.y1 + m && b.y0 < a.y1 + m; + +/** How far boxes `a` and `b` overlap, with `m` px between them counted in: 0 when they are clear. */ +const touchArea = (a, b, m = 0) => + Math.max(0, Math.min(a.x1, b.x1 + m) - Math.max(a.x0, b.x0 - m)) * Math.max(0, Math.min(a.y1, b.y1 + m) - Math.max(a.y0, b.y0 - m)); + +/** + * The first of `spots` (each {box, ...}, in order of preference) whose box clears every one of `obstacles` by `m` + * px; when none does, the one that touches them least. The words' boxes are estimates in the face's px (see + * dialFigures), deliberately a little wide. + */ +export function clearSpot(spots, obstacles, m = 0) { + let best = null, least = Infinity; + for (const s of spots) { + if (!obstacles.some((o) => boxesTouch(s.box, o, m))) return s; + const t = obstacles.reduce((n, o) => n + touchArea(s.box, o, m), 0); + if (t < least) { least = t; best = s; } + } + return best; +} + +/** A centred box `w` x `h` at (x, y). */ +const boxAt = (x, y, w, h) => ({ x0: x - w / 2, x1: x + w / 2, y0: y - h / 2, y1: y + h / 2 }); + +/** + * An as-of label's places, best first: along its ghost (angle `a`) at half the face's radius, each of its `forms` + * (its small words on one line, then on two), then stepping in toward the hub; never lower than just under the hub, + * where the readout's words are. Its box from its css (.asof: the head 24, the small words 13 condensed with + * 0.08em spacing, 3/7 padding). + */ +function asofSpots({ C, Rf, u, a, head, forms, px, fpx }) { + const hb = px(24), hs = fpx(13); + const spots = []; + for (let r = Rf * 0.52; r >= Rf * 0.26 - 1e-9; r -= Rf * 0.04) { + const [x, y0] = polar(C, C, r, a); + const y = Math.min(y0, Math.round((C + 30 * u) * 100) / 100); + for (const lines of forms) { + const w = Math.max(head.length * hb * 0.6, ...lines.map((l) => l.length * hs * 0.66)) + 2 * px(7); + const h = hb * 1.05 + lines.length * hs * 1.05 + 2 * px(3); + spots.push({ x, y, lines, box: boxAt(x, y, w, h) }); + } + } + return spots; +} + /** * The dial's face and everything on it, `size` px square at (ox, oy) in the * page: the static face, the ghosts, the wedges, the goal tick, the needles, @@ -138,6 +188,9 @@ function dialParts({ size, ox, oy, scale, cfg, colors, fonts, track, prefix = "" const layer = (k, inner, cls = "ly") => `<div class="${cls}" data-k="${prefix}${k}"><svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}">${inner}</svg></div>`; const parts = []; parts.push(`<div class="ly face">${face.svg}</div>`); + // Where words laid on the face must not go: its scale figures, and the hub. + const faceFigures = dialFigures({ size, scale, mark: cfg.mark }); + const hub = { x0: C - 18 * u, x1: C + 18 * u, y0: C - 18 * u, y1: C + 18 * u }; if (cfg.ghosts) { track.remembered.forEach((g, j) => { parts.push(layer(`g${j}`, `<line x1="${C}" y1="${C - Rf + 6 * u}" x2="${C}" y2="${C - Rf + 46 * u}" stroke="${colors.ghost}" stroke-width="${px(3.5)}" stroke-linecap="round"/>`)); @@ -157,8 +210,17 @@ function dialParts({ size, ox, oy, scale, cfg, colors, fonts, track, prefix = "" // face's own dark around the accent, and its words -- the glyph and the digits -- at its outer edge. parts.push(layer(`q${j}`, `<path d="${sectorPath(C, C, Rf - 48 * u, Rf - 2 * u, a0, a1)}" fill="${colors.accent}" fill-opacity="0.78" stroke="${colors.face}" stroke-width="${px(4)}"/>` + `<path d="${sectorPath(C, C, Rf - 48 * u, Rf - 2 * u, a0, a1)}" fill="none" stroke="${colors.accent}" stroke-width="${px(2)}"/>`)); - const [lx, ly] = polar(C, C, Rf - 108 * u, (a0 + a1) / 2); - parts.push(`<div class="qlab" data-k="${prefix}ql${j}" style="left:${lx}px; top:${ly}px">${esc(weightWords(c))}</div>`); + // Its words clear of every scale figure (rev 9: "3>300", the words on the 300 at the top): inside the wedge + // on its middle, stepping in toward the hub until their box (.qlab: 26 display, 1/6 padding) is clear. + const words = weightWords(c); + const fs = px(26), bw = words.length * fs * 0.6 + 2 * px(6), bh = fs * 1.2 + 2 * px(1); + const spots = []; + for (let r = Rf - 108 * u; r >= Rf - 190 * u - 1e-9; r -= 8 * u) { + const [x, y] = polar(C, C, r, (a0 + a1) / 2); + spots.push({ x, y, box: boxAt(x, y, bw, bh) }); + } + const spot = clearSpot(spots, [...faceFigures.map((f) => f.box), hub], 10 * u); + parts.push(`<div class="qlab" data-k="${prefix}ql${j}" style="left:${spot.x}px; top:${spot.y}px">${esc(words)}</div>`); }); if (cfg.goal) { parts.push(layer("gl", `<polygon points="${C - 11 * u},${C - R - 2 * u} ${C + 11 * u},${C - R - 2 * u} ${C},${C - Rf + 16 * u}" fill="${colors.amber}" stroke="${colors.bg}" stroke-width="${px(2)}"/>`)); @@ -178,16 +240,19 @@ function dialParts({ size, ox, oy, scale, cfg, colors, fonts, track, prefix = "" `<polygon points="${C - 6 * u},${C + 34 * u} ${C + 6 * u},${C + 34 * u} ${C + 1.8 * u},${C - Rf + 30 * u} ${C - 1.8 * u},${C - Rf + 30 * u}" fill="${colors.needle}"/>` + `<circle cx="${C}" cy="${C + 34 * u}" r="${px(9)}" fill="${colors.needle}"/>`)); parts.push(`<div class="ly"><svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}"><circle cx="${C}" cy="${C}" r="${px(16)}" fill="${colors.needle}"/><circle cx="${C}" cy="${C}" r="${px(6)}" fill="${colors.face}"/></svg></div>`); - // The as-of labels, each by its ghost, up while it is the latest. + // The as-of labels, each by its ghost, up while it is the latest -- and never on a scale figure (rev 9: "≈390 · + // AS OF FEB 2025 · TOLD 4×" sat on the 380). Along its ghost, never down into the readout's words under the hub; + // where its box would touch a figure's, its words go on two lines, then it steps in toward the hub. if (cfg.ghosts) { track.remembered.forEach((g, j) => { const a = dialAngle(g.value, scale); - // Along its ghost, but never down into the readout's words under the hub. - const [x, y0] = polar(C, C, Rf * 0.52, a); - const y = Math.min(y0, Math.round((C + 30 * u) * 100) / 100); + const head = weightWords(g); + const asOf = g.asOf ? `AS OF ${fmtDate(g.asOf)}` : "REMEMBERED"; // The moving start's count rides on its ghost (rev 9: "≈390 · TOLD 5×", the peak module off beside the dial). - const told = g.told > 1 ? ` · TOLD ${g.told}×` : ""; - parts.push(`<div class="asof" data-k="${prefix}ga${j}" style="left:${x}px; top:${y}px"><b>${esc(weightWords(g))}</b><span>${g.asOf ? `AS OF ${esc(fmtDate(g.asOf))}` : "REMEMBERED"}${told}</span></div>`); + const told = g.told > 1 ? `TOLD ${g.told}×` : ""; + const forms = told ? [[`${asOf} · ${told}`], [asOf, told]] : [[asOf]]; + const spot = clearSpot(asofSpots({ C, Rf, u, a, head, forms, px, fpx }), [...faceFigures.map((f) => f.box), hub], 3 * u); + parts.push(`<div class="asof" data-k="${prefix}ga${j}" style="left:${spot.x}px; top:${spot.y}px"><b>${esc(head)}</b>${spot.lines.map((l) => `<span>${esc(l)}</span>`).join("")}</div>`); }); } // The readout under the hub: the words, the weight, the weighing's date, the goal. diff --git a/umtool/report-to-video/chrome-measure-extras.mjs b/umtool/report-to-video/chrome-measure-extras.mjs @@ -15,7 +15,7 @@ import { rgba } from "./chrome-deck.mjs"; import { compileCues, cuePageHtml, esc, INSTANT, joinSpans, r4, spanEvents } from "./chrome-cues.mjs"; import { - daysBetween, daysLeftText, daysText, dietStates, goalStates, measureBox, measureExtraGeometry, measureOf, MEASURE_BOXES, promiseStripRect, + daysBetween, daysLeftText, daysText, dietStates, goalStates, 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"; @@ -430,8 +430,11 @@ function promiseStrip(states, place, cfg, render, opts, items) { return html; }); const compiled = compileCues(init, ev); + // Its type from the longest line's words (rev 9: 16 px did not read). + const chars = Math.max(1, ...lines.map((l) => l.replace(/<[^>]+>/g, "").replace(/&[a-z#0-9]+;/gi, "x").length)); + const type = promiseStripType(rect, render, chars); const html = `<div id="ps" data-k="ps" style="left:${rect.x - reg.x}px; top:${rect.y - reg.y}px; width:${rect.width}px; height:${rect.height}px">${lines.join("")}</div>`; - return { html, cues: compiled, rect }; + return { html, cues: compiled, rect, type }; } /** The promise clock's page: `{ html, items }`. `opts.avatars` = `{ <speaker>: "assets/…" }`, `opts.handles` = `{ <speaker>: handle }`. */ @@ -582,7 +585,9 @@ export function promiseHtml(schedule, render, opts = {}) { #ps { position: absolute; visibility: hidden; opacity: 0; } .sl { position: absolute; inset: 0; visibility: hidden; opacity: 0; display: flex; align-items: center; justify-content: center; gap: ${Math.round(sk * 10)}px; white-space: nowrap; overflow: hidden; font-family: 'DeckSansBold', sans-serif; - font-size: ${Math.round(strip ? strip.rect.height * 0.62 : 12)}px; letter-spacing: 0.08em; text-transform: uppercase; color: ${pal.muted}; } + font-size: ${strip ? strip.type.size : 12}px; line-height: 1; letter-spacing: 0.08em; text-transform: uppercase; color: ${pal.muted}; }${strip?.type.lines === 2 ? ` + .sl { flex-wrap: wrap; align-content: center; row-gap: 0; white-space: normal; } + .sl > * { white-space: nowrap; }` : ""} .sl b { color: ${pal.fg}; font-family: ${DISPLAY}; font-weight: 400; letter-spacing: 0.04em; } .sl .no { color: ${red}; } .sl .ok { color: ${green}; } diff --git a/umtool/report-to-video/measure-draw.mjs b/umtool/report-to-video/measure-draw.mjs @@ -236,6 +236,35 @@ export function wedgeRange(value, q, range = null) { } /** + * The dial face's scale figures -- a label every 20 lb and the mark's -- where + * dialFaceSvg draws them: each its value, its anchor (`x` its middle, `y` its + * baseline), its font size and its `box` in the face's px. The box is the + * glyphs' estimate, a little generous (a digit of the condensed face is about + * half an em wide, the cap height about three quarters of one), so a word laid + * beside it on the face keeps clear of the figure whichever font is loaded. + * The one geometry for both the face and whatever must stay off its figures. + */ +export function dialFigures({ size, scale, mark = 300 }) { + const C = size / 2; + const R = C - Math.round(size * 0.012); + const Rf = R - Math.round(size * 0.026); + const u = size / 524; + const fig = (v, r, lift, font, isMark) => { + const [x, y0] = polar(C, C, r, dialAngle(v, scale)); + const y = r2(y0 + lift * u), fs = r2(font * u); + const w = String(v).length * fs * 0.6; + return { v, x, y, fs, mark: isMark, box: { x0: x - w / 2, x1: x + w / 2, y0: y - fs * 0.78, y1: y + fs * 0.06 } }; + }; + const out = []; + for (let v = Math.ceil(scale.min / 20) * 20; v <= scale.max + 1e-9; v += 20) { + if (Number.isFinite(mark) && v === mark) continue; + out.push(fig(v, Rf - 54 * u, 8, 24, false)); + } + if (Number.isFinite(mark) && mark >= scale.min && mark <= scale.max) out.push(fig(mark, Rf - 58 * u, 9, 28, true)); + return out; +} + +/** * The dial face as SVG markup, `size` px square: the bezel, the face, a tick * every 2 lb (longer every 10, longest every 20), a label every 20, the * `mark` weight (300) accented. Static: nothing on it moves. @@ -256,18 +285,17 @@ export function dialFaceSvg({ size, scale, mark = 300, colors, labelFont = "sans const [x2, y2] = polar(C, C, Rf - (major ? 30 : mid ? 22 : 14) * u, a); out.push(`<line x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" stroke="${colors.ink}" stroke-width="${r2((major ? 3 : mid ? 2 : 1.2) * u)}" stroke-opacity="${major ? 1 : mid ? 0.85 : 0.6}"/>`); } - for (let v = Math.ceil(scale.min / 20) * 20; v <= scale.max + 1e-9; v += 20) { - if (Number.isFinite(mark) && v === mark) continue; - const [x, y] = polar(C, C, Rf - 54 * u, dialAngle(v, scale)); - out.push(`<text x="${x}" y="${r2(y + 8 * u)}" text-anchor="middle" font-family="${labelFont}" font-size="${r2(24 * u)}" fill="${colors.ink}">${v}</text>`); + const figures = dialFigures({ size, scale, mark }); + for (const f of figures.filter((g) => !g.mark)) { + out.push(`<text x="${f.x}" y="${f.y}" text-anchor="middle" font-family="${labelFont}" font-size="${f.fs}" fill="${colors.ink}">${f.v}</text>`); } if (Number.isFinite(mark) && mark >= scale.min && mark <= scale.max) { const a = dialAngle(mark, scale); const [x1, y1] = polar(C, C, Rf - 3 * u, a); const [x2, y2] = polar(C, C, Rf - 36 * u, a); out.push(`<line x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" stroke="${colors.mark}" stroke-width="${r2(6 * u)}" stroke-linecap="round"/>`); - const [x, y] = polar(C, C, Rf - 58 * u, a); - out.push(`<text x="${x}" y="${r2(y + 9 * u)}" text-anchor="middle" font-family="${labelFont}" font-size="${r2(28 * u)}" fill="${colors.mark}">${mark}</text>`); + const f = figures.find((g) => g.mark); + out.push(`<text x="${f.x}" y="${f.y}" text-anchor="middle" font-family="${labelFont}" font-size="${f.fs}" fill="${colors.mark}">${mark}</text>`); } return { svg: `<svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}">${out.join("")}</svg>`, C, R, Rf, u }; } diff --git a/umtool/report-to-video/measure-extras.mjs b/umtool/report-to-video/measure-extras.mjs @@ -689,12 +689,39 @@ export function promiseColumnRect(render) { /** * The strip a promise clock in the FOOTAGE box draws while a post item is up: * one line in the post box's top margin, over the card (the post's pad, as - * postLayout lays it: 36 design px of the box's height). + * postLayout lays it: 36 design px of the box's height) -- all of it but a + * pixel above and a pixel and a gap below, so its words can be read (rev 9: + * 22 px at 1080, not 16; promiseStripType). */ export function promiseStripRect(render, { feed = false } = {}) { const f = feed ? feedGeometry(render).footage : deckGeometry(render).footage; const pad = Math.round(36 * (f.height / 1080)); - return { x: f.x + pad, y: f.y + 2, width: f.width - 2 * pad, height: Math.max(18, pad - 4) }; + return { x: f.x + pad, y: f.y + 1, width: f.width - 2 * pad, height: Math.max(18, pad - 3) }; +} + +/** The strip's words at 1080: no smaller than this when the margin holds them. */ +export const PROMISE_STRIP_PX = 22; + +/** + * The strip's type: its size, and whether its words go on two lines. One line + * at PROMISE_STRIP_PX (scaled with the frame) when the margin is tall enough + * and the longest line (`chars`, an uppercase condensed-bold line at about 0.64 + * em a character, its spacing in) fits its width; two lines at that size when + * only the width is short and two fit the height; else the largest one line + * that fits both. Lines are set solid (line-height 1). + * + * @returns {{ size: number, lines: 1 | 2 }} + */ +export function promiseStripType(rect, render, chars) { + const k = (render?.height ?? 1080) / 1080; + const want = PROMISE_STRIP_PX * k; + const room = rect.height - 2 * k; // a pixel of air above and below the glyphs + const em = 0.64; + const fitsWide = (size) => chars * em * size <= rect.width; + const r = (v) => Math.floor(v * 100) / 100; + if (room >= want - 1e-6 && fitsWide(want)) return { size: r(Math.max(want, Math.min(room, rect.height * 0.62))), lines: 1 }; + if (room >= 2 * want - 1e-6 && fitsWide(want / 2)) return { size: r(want), lines: 2 }; + return { size: r(Math.min(room, rect.width / Math.max(1, chars * em))), lines: 1 }; } /** diff --git a/umtool/report-to-video/rev9-panel.test.mjs b/umtool/report-to-video/rev9-panel.test.mjs @@ -14,7 +14,7 @@ import { titleLast } from "./chrome-finale.mjs"; import { instrumentsOn, resolveDial, resolveOdometer, resolveTrail } from "./instruments.mjs"; import { measureTrack, wedgeRange, weightWords } from "./measure-draw.mjs"; import { measureSlice, rangeOf } from "./measure-slice.mjs"; -import { measureExtraGeometry, measurePlacements, promiseStripRect } from "./measure-extras.mjs"; +import { measureExtraGeometry, measurePlacements, PROMISE_STRIP_PX, promiseStripRect, promiseStripType } from "./measure-extras.mjs"; import { placementsFor, promiseFinaleSlot, promiseHtml } from "./chrome-measure-extras.mjs"; import { validateFinaleSettings } from "./finale.mjs"; @@ -182,6 +182,13 @@ test("K: beside the instruments the promise clock stands in the trail's slot (co const strip = promiseStripRect(f); assert.ok(p.region.y <= strip.y && p.region.x <= strip.x); assert.match(promiseHtml(covered, f, { fonts: {} }).html, /<div id="ps" data-k="ps"[^>]*>.*class="sl" data-k="t0"/s); + // Its words read (rev 9: 16 px did not): one line at 22 px at 1080, set solid, inside the margin. + assert.deepEqual(promiseStripType(strip, f, 80), { size: PROMISE_STRIP_PX, lines: 1 }); + assert.match(promiseHtml(covered, f, { fonts: {} }).html, /\.sl \{[^}]*font-size: 22px; line-height: 1;/); + assert.ok(strip.height >= PROMISE_STRIP_PX + 2); + // A margin wide enough for two lines but not one: two at the size; neither: the largest one line that fits. + assert.deepEqual(promiseStripType({ x: 0, y: 0, width: 600, height: 50 }, f, 80), { size: 22, lines: 2 }); + assert.ok(promiseStripType({ x: 0, y: 0, width: 600, height: 27 }, f, 80).size < 22); // `slot: "footage"` beside the instruments keeps it in the footage box. assert.equal(measureExtraGeometry("promise", render({ dial: true, promise: { slot: "footage" } })).width, 640); // The finale: the dial's finale hands its lower column to it ("auto": a promise is on camera).