// THE ODOMETER (module `odometer`, region `odometer`): mechanical rolling // digits of the pounds he says he has lost, under the dial in the // instruments' column. The total is the measure's (the odometer rule: the // highest real-time claim in each run, summed -- "go by his words"), held to // its running highest so the wheels only ever roll up; NET beside it in plain // digits. chrome-instruments.mjs writes the page. import path from "node:path"; import { instrumentsGeometry } from "../deck.mjs"; import { odometerHtml } from "../chrome-instruments.mjs"; import { ODOMETER_DEFAULTS, resolveOdometer } 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: "odometer", version: 1, z: 75, kind: "overlay-whole", slot: "instruments", // Its form in the stacked vertical deck (vertical-deck.mjs). vertical: { slot: "panel" }, title: "Lost odometer", summary: "Rolling digits of the pounds he says he has lost (only ever up), NET beside them.", configKey: "render.chrome.deck.odometer", defaults: ODOMETER_DEFAULTS, validate: settingsOf("odometer").validate, resolve: resolveOdometer, ui: [ { key: "label", type: "text", label: "Over the wheels", default: ODOMETER_DEFAULTS.label }, { key: "net", type: "boolean", label: "NET beside them", default: true }, { key: "runs", type: "boolean", label: "How many runs", default: true }, { key: "flash", type: "boolean", label: "Flash its outline when its value changes (unset: deck.measure.flash)" }, ], docs: { heading: "Lost odometer", intro: "Under the dial: the measure's `state.lost.total` (the highest real-time loss claim in each run, summed) on mechanical wheels to a tenth, rolling forward at each claim that raises it (1.3 s) and never back -- a lower total is held at the highest so far. NET (`state.net`: the first stated weight of the record to the latest) in plain digits beside it, `−76.5 · 368 → 291.5`; `ACROSS 8 RUNS` under the wheels.", rows: [ ["`deck.odometer`", "`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.odometer=false`"], ["`deck.odometer.label`", "words over the wheels, ≤ 40 · default `POUNDS HE SAYS HE'S LOST`", "`umtool look
deck.odometer.label='\"…\"'`"], ["`deck.odometer.net`, `.runs`", "bool · default `true` each", "`umtool look
deck.odometer.net=false`"], ["`deck.odometer.flash`", "bool · unset (default): follows `deck.measure.flash` -- THE UPDATE FLASH (update-flash.mjs): the card lights as the pounds lost go up (or the runs change) and as NET 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.odometer.flash=false`"], ], }, region: "odometer", // It comes and goes with the deck (chrome-instruments.mjs): full-frame.mjs `followsDeck`. fullFrame: { followsDeck: true }, workers: "narrow", noun: "the odometer's", on: (schedule, render) => hasMeasure(schedule) && !!resolveOdometer(render), check: (schedule, render) => (hasMeasure(schedule) ? cornerCollision("odometer", render) : noMeasure("odometer")), async page(ctx) { return odometerHtml(ctx.schedule, ctx.render, { fonts: await instrumentFonts(ctx), from: ctx.from, duration: ctx.duration }); }, regions(schedule, { render, outDir, frames = null }) { const g = instrumentsGeometry(render).odometer; if (!g) return []; return [assertRegion({ name: "odometer", frames: frames ?? path.join(outDir, "chrome", "odometer-frames"), ...g })]; }, play: { clock: "cut", ready: "odometer:ready" }, frameKeys: wholeCutKeys("odometer"), });