// THE TRAIL (module `trail`, region `trail`): the weights he says, stated and // remembered, as one thin line by DATE (not cut time) at the foot of the // instruments' column, each point appearing as he says it and the line drawn // between date-neighbours once both are said; the 300 lb line; how many times // he says he is under it. // chrome-instruments.mjs writes the page. import path from "node:path"; import { instrumentsGeometry } from "../deck.mjs"; import { trailHtml } from "../chrome-instruments.mjs"; import { resolveTrail, TRAIL_DEFAULTS } 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: "trail", version: 1, z: 76, kind: "overlay-whole", slot: "instruments", // Its form in the stacked vertical deck (vertical-deck.mjs). vertical: { slot: "panel" }, title: "Weight trail", summary: "The weights he says (stated and remembered) as one line by date, drawn up to the playhead, the 300 lb line and the times he says he is under it.", configKey: "render.chrome.deck.trail", defaults: TRAIL_DEFAULTS, validate: settingsOf("trail").validate, resolve: resolveTrail, ui: [ { key: "mark", type: "number", min: 0, max: 2000, step: 1, label: "The line across", default: 300 }, { key: "count", type: "boolean", label: "Count the \"under 300\" claims", default: true }, { key: "label", type: "text", label: "Its title", default: TRAIL_DEFAULTS.label }, { key: "bounds", type: "enum", options: ["fit", "fixed"], label: "Axes: fit what is shown so far, or fixed to the whole cut", default: "fit" }, { key: "remembered", type: "boolean", label: "His remembered weights as points too (hollow rings on the line)", default: true }, { key: "flash", type: "boolean", label: "Flash its outline when its value changes (unset: deck.measure.flash)" }, ], docs: { heading: "Weight trail", intro: "At the foot of the instruments' column: every weight the cut shows -- the STATED ones and (`remembered`) the remembered ones, \"≈390, as of Feb 2023\" -- placed by the date he was that weight (its `asOf`, else its date), a dot appearing at its event's `t`; ONE line runs through every weight shown, stated and remembered alike, joining neighbours by date once both are said -- so it never passes over a point; of several weights for one day the line takes the one said last and the others stay as marks beside it. A remembered weight is a hollow grey ring with a solid border (a qualified one a size smaller), and a stretch of the line with a remembered end is drawn quieter, grey and thinner; between two stated weights it keeps the accent (a qualified stated one is hollow). The axes FIT what has been said so far (trail-plan.mjs): each new weight outside them reflows the chart over 0.4 s -- the years, the bounds, every dot -- so the time axis advances with the story; a stretch with no statement longer than `gap` is a break in the time axis (a small `//` on the axis foot, each side with its own years; a year inside a stretch a short tick there) and the line across it dotted, so a decade of nothing does not take the width from the dense run after it. The width is shared half by days and half by the weights each stretch holds (each day a weight is said for owns an equal slot), so a run of weights a few days apart is spread out rather than piled into a few pixels, and an empty year still reads as longer than a week. A red ring on the latest said. The `mark` line (300) dashed across; with `count` and the mark at 300, `UNDER 300 · SAID n×` counts the measure's `totals.under300` rows as the cut reaches each.", rows: [ ["`deck.trail`", "`true` · an object of the knobs below · `false` off · absent: ON when the cut draws a measure (`deck.measure` set), else off", "`umtool look

deck.trail=false`"], ["`deck.trail.mark`", "a weight, or `null` · default `300`", "`umtool look

deck.trail.mark=300`"], ["`deck.trail.count`", "bool · default `true`", "`umtool look

deck.trail.count=false`"], ["`deck.trail.label`", "its title, ≤ 40 · default `WHAT HE SAYS HE WEIGHS, BY DATE`", "`umtool look

deck.trail.label='\"…\"'`"], ["`deck.trail.bounds`", "`fit` · `fixed` · default `fit`: the axes fit the weights said so far and reflow as each lands; `fixed` lays every moment on the axes of all the cut's weights", "`umtool look

deck.trail.bounds=fixed`"], ["`deck.trail.remembered`", "bool · default `true`: his remembered weights are points on the line too, hollow grey rings, the line's stretches to them quieter; `false` leaves them out", "`umtool look

deck.trail.remembered=false`"], ["`deck.trail.gap`", "`auto` · days 30–3650 · `0` none · default `auto`: a stretch with no statement longer than a year (or 8× the median spacing, if longer) is a break in the time axis", "`umtool look

deck.trail.gap=540`"], ["`deck.trail.flash`", "bool · unset (default): follows `deck.measure.flash` -- THE UPDATE FLASH (update-flash.mjs): the card lights as each weight lands on it; 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.trail.flash=false`"], ], }, region: "trail", // It comes and goes with the deck (chrome-instruments.mjs): full-frame.mjs `followsDeck`. fullFrame: { followsDeck: true }, workers: "narrow", noun: "the trail's", on: (schedule, render) => hasMeasure(schedule) && !!resolveTrail(render), check: (schedule, render) => (hasMeasure(schedule) ? cornerCollision("trail", render) : noMeasure("trail")), async page(ctx) { return trailHtml(ctx.schedule, ctx.render, { fonts: await instrumentFonts(ctx), from: ctx.from, duration: ctx.duration }); }, regions(schedule, { render, outDir, frames = null }) { const g = instrumentsGeometry(render).trail; if (!g) return []; return [assertRegion({ name: "trail", frames: frames ?? path.join(outDir, "chrome", "trail-frames"), ...g })]; }, play: { clock: "cut", ready: "trail:ready" }, frameKeys: wholeCutKeys("trail"), });