// THE STAMPS (module `stamp`, region `stamp`): each counted mark's word // stamped over the footage as it lands (`render.chrome.factcheck.stamp`). // chrome-stamp.mjs writes the page; factcheck.mjs `stampSchedule` times it. import path from "node:path"; import { stampGeometry } from "../deck.mjs"; import { stampHtml } from "../chrome-stamp.mjs"; import { stampsDrawn } from "../factcheck.mjs"; import { assertRegion, defineModule } from "./contract.mjs"; import { FACTCHECK_DEFAULTS, FACTCHECK_LIMITS, STAMP_MOTIONS, STAMP_POSITIONS } from "../factcheck.mjs"; import { settingsOf } from "./settings.mjs"; export default defineModule({ id: "stamp", version: 1, z: 40, kind: "overlay-whole", slot: "stamp", // Its form in the stacked vertical deck (vertical-deck.mjs). vertical: { slot: "picture" }, title: "Stamps", summary: "Each counted mark's word, stamped over the footage as it lands.", configKey: "render.chrome.factcheck.stamp", defaults: FACTCHECK_DEFAULTS.stamp, validate: settingsOf("stamp").validate, deps: ["counter.series"], ui: [ { key: "show", type: "boolean", label: "Draw the stamps", default: true }, { key: "seconds", type: "number", min: FACTCHECK_LIMITS.seconds[0], max: FACTCHECK_LIMITS.seconds[1], step: 0.5, label: "Seconds", default: 3 }, { key: "position", type: "enum", options: STAMP_POSITIONS, label: "Corner", default: "top-left" }, { key: "scale", type: "number", min: FACTCHECK_LIMITS.scale[0], max: FACTCHECK_LIMITS.scale[1], step: 0.05, label: "Scale", default: 1 }, { key: "motion", type: "enum", options: STAMP_MOTIONS, label: "Motion", default: "slam" }, { key: "opacity", type: "number", min: FACTCHECK_LIMITS.opacity[0], max: FACTCHECK_LIMITS.opacity[1], step: 0.05, label: "Opacity", default: 1 }, ], docs: { heading: "Stamps", intro: "Each counted mark's word stamped over the footage as it lands (`render.chrome.factcheck.stamp`); the word is the mark's `label`, else its series' `stampLabel`, else its label.", rows: [ ["`factcheck.stamp.show`", "bool · default `true` (`false`: nothing drawn, the counter still counts)", "`umtool look

factcheck.stamp.show=false`"], ["`factcheck.stamp.seconds`", `${FACTCHECK_LIMITS.seconds[0]}–${FACTCHECK_LIMITS.seconds[1]} s · default 3`, "`umtool look

factcheck.stamp.seconds=4`"], ["`factcheck.stamp.position`", `${STAMP_POSITIONS.map((p) => `\`${p}\``).join(" ")} · default \`top-left\``, "`umtool look

factcheck.stamp.position=center`"], ["`factcheck.stamp.scale`, `.motion`, `.opacity`", "0.5–2 · `slam` `pop` `fade` `none` · 0.3–1 · default 1, `slam`, 1", "`umtool look

factcheck.stamp.motion=pop`"], ], }, region: "stamp", // A teaser that carries marks keeps its stamps (they are the card's own content), and a clip's stamp leaves // over the next segment's dissolve whole when that segment is full frame: full-frame.mjs `drawsMarks`, `ownFade`. fullFrame: { drawsMarks: true, ownFade: true }, workers: "narrow", noun: "the stamps'", on: (schedule, render) => stampsDrawn(schedule, render), check(schedule, render) { if (!schedule.factcheck?.stamps?.length) return "the stamp region needs a schedule that stamps a claim (an entry with a `claim`)"; if (!stampsDrawn(schedule, render)) { return "the stamps are off (render.chrome.factcheck.stamp.show: false): there is no stamp region to compose"; } return null; }, async page(ctx) { // The fact-check stamps (chrome-stamp.mjs): the deck's faces, no QR. const fonts = await ctx.fonts({ regular: "DeckSans", bold: "DeckSansBold" }, { strict: true }); return stampHtml(ctx.schedule, ctx.render, { fonts, from: ctx.from, duration: ctx.duration }); }, regions(schedule, { render, outDir, frames = null }) { return [assertRegion({ name: "stamp", frames: frames ?? path.join(outDir, "chrome", "stamp-frames"), ...stampGeometry(render, { feed: schedule.layout === "feed" }), })]; }, frameKeys: { data: "stamp-data", omit: ["init", "cues", "window", "total", "ids"] }, });