// THE EFFECTS (module `fx`, region `fx`): overlays drawn over the footage box
// -- receipts, a zoom, a scrubber, captions (`render.chrome.fx`, fx.mjs).
// chrome-fx.mjs writes the page.
import path from "node:path";
import { fxGeometry } from "../deck.mjs";
import { assertRegion, defineModule } from "./contract.mjs";
import { settingsOf } from "./settings.mjs";
export default defineModule({
id: "fx",
version: 1,
z: 60,
kind: "overlay-whole",
slot: "footage",
// Its form in the stacked vertical deck (vertical-deck.mjs).
vertical: { slot: "picture" },
title: "Effects",
summary: "Overlays on the picture: receipts, a zoom, a scrubber, captions.",
validate: settingsOf("fx").validate,
docs: {
heading: "Effects",
intro: "Overlays on the picture -- receipts, a zoom, the scrubber, a kinetic quote, punch-ins, whip cuts -- (`render.chrome.fx`, fx.mjs); `umtool takes effects
` lists the presets.",
rows: [
["`render.chrome.fx.`", "scrubber · receipts · zoom · kineticQuote · redact · odometer · punchIn · thenNow · whip · glitch", "a take: `umtool take --effect `"],
["`render.chrome.fx.glitch.on`, `.clips`", "`year` (a tear at each cut between years) · `every` (each cut between clips) · `clips` (only the cut INTO each clip `clips` names: 1–60 ids, each with a clip right before it) · default `year`; `clips` only with `on: \"clips\"`. `.seconds` 0.2–1.5 · 0.5, `.stamp` (the `PLAY ▶` date) · `true`, `.year` (the new year big over the tear; `false` with `stamp: false` is a bare tear, no text) · `true`", "manifest"],
["a clip's `fx` — what an effect draws on it, inert until that effect is on: `zoom` `{shot, focus, at?, hold?}`, `receipts` `[{shot, mark?, at?, hold?, label?}]` (1–4; `at` a source second inside the clip, gap-aware, `hold` 0.5–10 s once landed, `label` ≤ 80 characters in a band under the shot), `punch` (the words), `quote` (false: no line), `punchIn` `[source s…]` (1–8, inside the clip), `speakers` `[{at, who: 0|1}]`. A `shot` is a file in the project (a bare name under its `shots/` is written as `shots/`); `focus`/`mark` are `[left, top, right, bottom]` fractions of it", "`fx.=` sets one and keeps the rest · `fx=` all · `fx=` none; checked by the build's own `validateFxEntries`", "`umtool set fx.zoom='{\"shot\":\"shots/x.png\",\"focus\":[0.1,0.2,0.9,0.4],\"at\":5.9}'` · `PUT /api/report/window {project, clip, fx}` (or `\"fx.zoom\"`, …)"],
["beside popup posts that move the footage (`deck.posts.shift`)", "the effects are drawn over the footage box where it stays, so an effect on screen WHILE the posts hold the footage aside is refused, naming both and their seconds — a zoom, receipts, a quote or a punch-in on its own clip's span; a whip, glitch or THEN/NOW wipe around its cut; the scrubber and the odometer over every clip (so beside any shift). A persisting bar holds it aside from its first post to its glide back. Apart in time, both are drawn. `umtool check` reads the estimated schedule; the build checks again on the measured one before any chrome is drawn", "`deck.posts.shift=false`, the feed, or move one of them"],
["the zoom's timing (`fx.zoom.at`, `.hold`)", "up 0.2 s into the clip's clean span (the card rises in over 0.38 s, `back.out`); its focus box draws 0.55 s later (0.45 s); it pushes in on the box at `at` — seconds into the clip, default as soon as the box has drawn — over 1 s (`power2.inOut`), then drifts slowly on the detail. It leaves with a 0.3 s fade 0.3 s before the clip's clean span ends, or with `hold` (0.5–10 s) that long after the push lands (never past the clip's own leave)", "`fx.zoom='{…,\"hold\":4}'`"],
],
},
region: "fx",
workers: "wide",
noun: "the effects'",
configKey: "render.chrome.fx",
on: (schedule) => !!schedule?.fx,
check: (schedule) => (!schedule.fx ? "the fx region needs a schedule with an effect on (render.chrome.fx)" : null),
async page(ctx) {
// The effects (chrome-fx.mjs): the deck's faces, a mono, the screenshots
// the receipts and the zoom show, and the scrubber's thumbnails.
// A page module reached by a dynamic import, as the teaser's: it carries
// its mono as an asset URL (docs/quirks.md).
const { fxHtml, FX_MONO_FILE } = await import("../chrome-fx.mjs");
const { schedule, render } = ctx;
const fonts = await ctx.fonts({ regular: "DeckSans", bold: "DeckSansBold" }, { strict: true });
fonts.mono = await ctx.asset(FX_MONO_FILE, "FxMono.ttf");
const shots = await ctx.fxShots(schedule.fx);
const thumbs = schedule.fx.scrubber?.thumbs ? await ctx.fxThumbs(schedule) : {};
return fxHtml(schedule, render, { fonts, assets: { shots, thumbs }, from: ctx.from, duration: ctx.duration });
},
regions(schedule, { render, outDir, frames = null }) {
return [assertRegion({
name: "fx", frames: frames ?? path.join(outDir, "chrome", "fx-frames"),
...fxGeometry(render, { feed: schedule.layout === "feed" }),
})];
},
// Its page is its live preview: Play the cut seeks it in the cut's seconds (contract.mjs, PLAY).
play: { clock: "cut", ready: "fx:ready" },
// A cue interpreter like the deck's: keyed per frame (frame-keys.mjs).
frameKeys: { data: "fx-data", omit: ["init", "cues", "window", "total"] },
});