// THE DIAL (module `dial`, region `dial`): an analog bathroom-scale face in // the instruments' column (instruments.mjs, deck.mjs instrumentsGeometry). A // red needle swings to every weight he states, on the word, overshoots and // settles; "almost", "over", "under" draw a wedge; his remembered weights are // grey ghost ticks, the latest a long ghost needle with its as-of date; every // goal in force a mark on the bezel, the CLOSEST (measure-goals.mjs) the full // amber tick with its words, a missed one struck in red; with // `deck.measure.ghosts`, a faint tick on the rim for every weight he has // claimed, coloured by how often (measure-ghosts.mjs); the 300 lb mark // accented; the weight in big digits under the hub. chrome-instruments.mjs // writes the page. import path from "node:path"; import { instrumentsGeometry } from "../deck.mjs"; import { dialHtml } from "../chrome-instruments.mjs"; import { DIAL_DEFAULTS, resolveDial } from "../instruments.mjs"; import { assertRegion, defineModule } from "./contract.mjs"; import { settingsOf } from "./settings.mjs"; import { cornerCollision, hasMeasure, instrumentFonts, noMeasure, wholeCutKeys } from "./instruments-shared.mjs"; export default defineModule({ id: "dial", version: 1, z: 74, kind: "overlay-whole", slot: "instruments", // Its form in the stacked vertical deck (vertical-deck.mjs). vertical: { slot: "panel" }, title: "Scale dial", summary: "A bathroom-scale face: the needle swings to each weight he states, his remembered weights as ghosts, every goal in force on the bezel (the closest headlined), and -- with deck.measure.ghosts -- a faint tick for every weight he has claimed.", configKey: "render.chrome.deck.dial", defaults: DIAL_DEFAULTS, validate: settingsOf("dial").validate, resolve: resolveDial, ui: [ { key: "mark", type: "number", min: 0, max: 2000, step: 1, label: "Accented weight", default: 300 }, { key: "ghosts", type: "boolean", label: "Remembered weights as ghosts", default: true }, { key: "goal", type: "boolean", label: "Every goal in force on the bezel, the closest headlined", default: true }, { key: "finale", type: "boolean", label: "Large in the finale", default: true }, { key: "label", type: "text", label: "Over the digits", default: DIAL_DEFAULTS.label }, { key: "placement", type: "enum", options: ["column", "corner"], label: "Where the instruments stand", default: "column" }, { key: "size", type: "number", min: 200, max: 540, step: 10, label: "The corner dial's size (px at 1920)", default: 340 }, { key: "corner", type: "enum", options: ["bottom-right", "bottom-left", "top-right", "top-left"], label: "The corner", default: "bottom-right" }, { key: "motion", type: "enum", options: ["spring", "ease"], label: "The needle's move", default: "spring" }, { key: "finaleEnd", type: "enum", options: ["auto", "odometer", "promise"], label: "The finale's last beat", default: "auto" }, { key: "rememberedAs", type: "enum", options: ["needle", "rim", "readout", "callout"], label: "A remembered weight drawn as", default: "needle" }, { key: "flash", type: "boolean", label: "Flash its outline when its value changes (unset: deck.measure.flash)" }, ], docs: { heading: "Scale dial", intro: "A bathroom-scale face at the top of the instruments' column (the right of the frame; the clip moves to the left -- `instrumentsGeometry`, 1248×702 footage beside a 600 px column at 1920×1080). It reads the schedule's `measure` (the measure ledger's slice): the red needle swings to each STATED weight at its event's `t` (the spoken word) with a spring (`back.out`, 0.9 s) and rests there -- a frame at rest is reused, not captured again; a BOUND that agrees with the specific weight in force (\">300\" while he is at 342, \"≈390\" at 388, \"330-340\" at 337) is no new figure and moves neither the needle nor the number (measure-totals.mjs `boundAgrees`; it still leaves its claim ghost), while one that contradicts it (\">300\" at 291) moves them as any reading does; a qualifier draws a wedge in pounds (≈ 3 under to 1 over, `>` 10 up, `<` 10 down); every REMEMBERED weight is a grey tick, the latest a long ghost needle with its as-of date. GOALS (measure-goals.mjs `goalBoard`): every goal in force at the playhead is a mark on the bezel at its weight -- in force from the moment the cut shows it until he meets it in time, a newer goal of the same HORIZON replaces it (the same deadline day, the same deadline words, or both undated), or the record's date passes its day. The HEADLINE is the CLOSEST of them -- the least still to lose from his latest stated weight (a range to its top), ties to the soonest deadline -- the full amber tick, its words under the digits (`GOAL 320 · BY APR 2026`); the others a thin amber tick, no words; a range an amber band too. A goal whose day passes with his latest weight over it is MISSED: struck in the needle's red with a red flash, the line under the digits `MISSED 320 · BY APR 2026` for 6 s (`MISS_HOLD`), then gone; a day passing with his weight under it (a reading after the day) leaves quietly. A goal's day: the ledger's `due`, else his `deadline` words read (\"by Christmas\", \"by the end of 2026\"), else the row's `asOf`. Any page that shows a goal reads the same board: `goalBoard(schedule.measure)` -> `[{ t, active, headline, missed, cur }]`, `goalsAt(board, t)`. It comes and goes with the deck (a card, the finale). With any instrument on, the posts stay in the footage box (`posts.shift` does not apply), and the side panel (`threads`, `flips`) and the posts feed are refused.", rows: [ ["`deck.dial`", "`true` · an object of the knobs below · `false` off · absent: ON when the cut draws a measure (`deck.measure` set), else off", "`umtool look
deck.dial=false`"], ["`deck.dial.mark`", "a weight, or `null` · default `300` (its tick and label in the accent)", "`umtool look
deck.dial.mark=300`"], ["`deck.dial.ghosts`, `.goal`", "bool · default `true` each (`.goal`: every goal in force, the closest headlined)", "`umtool look
deck.dial.ghosts=false`"], ["`deck.measure.ghosts`", "`true` · `{opacity, tolerance, ramp, pulse}` · `false` / absent: off (the default). CLAIM GHOSTS (measure-ghosts.mjs), not `deck.dial.ghosts`: every weight he has claimed so far -- each stated weight the needle goes to and each remembered one, his own, in cut order -- leaves a thin faint tick across the dial's rim at its value, under everything else on the face; a value claimed again (within `tolerance` lb of the tick's first value; an `≈` value as its rounded number; `>300` and `<300` at 300) steps that tick along the `ramp` -- 1× faint, 2× warm, 3× and up hot, a little thicker each step -- and it pulses once as the repeat lands (`pulse`). In the finale every tick stays at its count at the cut's end. Seek-safe: a frame at t draws the claims before t", "`umtool look
deck.measure.ghosts=true`"], ["`deck.dial.rememberedAs`", "`needle` · `rim` · `readout` · `callout` · default `needle` (as it was: a long grey second needle from the hub to the value, its words -- \"≈390 / AS OF 24 FEB 2023\" -- along it). `rim`: no long needle; a bold marker across the rim at the value and a flag inside it -- \"HEAVIEST ≈390 / AS OF FEB 2023 · HE SAYS\" -- placed clear of the scale's figures, the hub and the readout. `readout`: a line in the readout under the date -- \"HEAVIEST HE'S SAID: ≈390 (FEB 2023)\", the goal under it -- and the rim marker. `callout`: as he says it a ghost needle sweeps from where the needle stands to the value and a label (\"HEAVIEST HE'S SAID / ≈390 / AS OF FEB 2023\") holds 2.2 s, then the rim's flag. The words are the ledger's: its qualifier, its asOf's month; HEAVIEST only for the record's highest remembered weight above every weight he stated (the peak extra's `totals.peakDrift`), else \"HE SAYS HE WAS\". Each is up while it is the latest remembered; the thin rim ticks of every remembered weight stay as they are", "`umtool look
deck.dial.rememberedAs=rim`"], ["`deck.measure.flash`", "bool · default `false` (off: every cut renders as before) -- THE UPDATE FLASH for every measure widget at once (update-flash.mjs): at the moment a widget's shown value changes its outline lights in its own colour and decays (0.15 s up, 0.7 s down) -- the dial on a weight stated or remembered or a goal change, the odometer on the pounds lost or NET, the trail on each weight landing, the goal stack on a goal set, the diet tags on a new diet; widgets that change on one event flash together; never on frame 0, while the deck is away (the intro, a card) or on a widget's first appearance. A widget's own `flash` overrides it", "`umtool look
deck.measure.flash=true`"], ["`deck.measure.ghosts.opacity`, `.tolerance`", "0.15–0.9 (the 1× tick's; +0.2 a step, at most 0.95) · 0–5 lb · default `0.5`, `0.5`", "`umtool look
deck.measure.ghosts='{\"tolerance\":1}'`"], ["`deck.measure.ghosts.ramp`, `.pulse`", "2–4 #hex, 1× first (the last for every count from there up), or `null`: the palette's muted, amber, and amber half way to the needle's red · bool · default `null`, `true`", "`umtool look
deck.measure.ghosts='{\"ramp\":[\"#98a29b\",\"#e8a33f\",\"#f37e47\"],\"pulse\":false}'`"], ["`deck.dial.needle`", "a #hex · default `#ff5a4e`", "`umtool look
deck.dial.needle='\"#ff5a4e\"'`"], ["`deck.dial.label`", "words over the digits, ≤ 40 · default `HE SAYS HE WEIGHS`", "`umtool look
deck.dial.label='\"…\"'`"], ["`deck.dial.finale`", "bool · default `true`: the dial and the odometer large in the finale (module `dial-finale`)", "`umtool look
deck.dial.finale=false`"], ["`deck.dial.placement`", "`column` `corner` · default `column`. A VARIANT: `corner` drops the column -- the footage stays where the deck puts it, the dial a `size` square over its lower-right corner, the odometer and the trail (at 4/5 size) stacked in its lower-left; the side panel is allowed there, the feed still refused", "`umtool look
deck.dial.placement=corner`"], ["`deck.dial.size`", "200–540 px at 1920 wide · default `340` (the corner dial only)", "`umtool look
deck.dial.size=300`"], ["`deck.dial.corner`", "`bottom-right` `bottom-left` `top-right` `top-left` · default `bottom-right` (the corner only): the dial in that corner, the odometer and the trail up the same side. The measure extras stand at their own anchors in the footage (goals bottom-right, peak top-right, promise top-centre, diet bottom-left, streak bottom-centre): a corner instrument over one that is on is REFUSED by the build, naming it -- move one (`deck.goals.position`, …) or the corner; `top-left` is clear of all five", "`umtool look
deck.dial.corner=top-left`"], ["`deck.dial.motion`", "`spring` `ease` · default `spring`. A VARIANT: the needle's `back.out` overshoot and settle, or a plain `power2.inOut` (the finale's drop too)", "`umtool look
deck.dial.motion=ease`"], ["`deck.dial.finaleEnd`", "`auto` `odometer` `promise` · default `auto` (`promise` when a promise is on camera, else `odometer`): `promise` hands the finale's last beat to the promise clock (module `promise`) -- the instruments fade out once NET has held (`dialFinaleHandoff`) and the clock takes their place in the finale's lower column, clear of the rail; with no promise module on the cut it ends on the odometer", "`umtool look
deck.dial.finaleEnd=promise`"], ["`deck.dial.flash`", "bool · unset (default): follows `deck.measure.flash` -- THE UPDATE FLASH (update-flash.mjs): the bezel lights as a weight is stated or remembered, or the goal in force changes; a thin outline in its own colour, up over 0.15 s and gone over 0.7 s, no size change, never on frame 0 or while the deck is away", "`umtool look
deck.dial.flash=false`"], ], }, region: "dial", // It comes and goes with the deck (chrome-instruments.mjs): full-frame.mjs `followsDeck`. fullFrame: { followsDeck: true }, workers: "narrow", noun: "the dial's", on: (schedule, render) => hasMeasure(schedule) && !!resolveDial(render), check: (schedule, render) => (hasMeasure(schedule) ? cornerCollision("dial", render) : noMeasure("dial")), async page(ctx) { return dialHtml(ctx.schedule, ctx.render, { fonts: await instrumentFonts(ctx), from: ctx.from, duration: ctx.duration }); }, regions(schedule, { render, outDir, frames = null }) { const g = instrumentsGeometry(render).dial; if (!g) return []; return [assertRegion({ name: "dial", frames: frames ?? path.join(outDir, "chrome", "dial-frames"), ...g })]; }, // Its page is its live preview: Play the cut seeks it in the cut's seconds (contract.mjs, PLAY). play: { clock: "cut", ready: "dial:ready" }, frameKeys: wholeCutKeys("dial"), });