// The EFFECTS region's composition (release 35, lane O2): one HyperFrames page // for a whole report cut, exactly the footage box (deck.mjs fxGeometry), // transparent but for the effects fx.mjs schedules -- the kinetic quote, the // redaction, the odometer, the scrubber, the glitch, the THEN/NOW wipe, the // receipts and the zoom. Overlays on the evidence, never cards: nothing here // covers the whole picture for longer than a glitch's half second. // // PURE, like chrome-stats.mjs: a schedule and a render block in, an HTML string // out. compose-chrome.mjs copies the assets in beside it (the faces, the // screenshots, the scrubber's thumbnails), writes it and renders it // (`region: "fx"`); the build lays the frames over the cut after the stats. // // SEEK-SAFE. A render is a seek per frame from parallel workers in any order, // so the timeline is a list of cues computed here (fx.mjs compileCues), each // stating its `from`; nothing is rewritten by a callback and nothing measures // the page: every size is in the data (a screenshot's pixels are read by // compose-chrome before the page is written). The glitch's noise is a seeded // generator's (fxRandom), so frame 412 is the same tear on every worker. import { fxGeometry, pageDuration } from "./deck.mjs"; import { assetFile, mix, rgba } from "./chrome-deck.mjs"; import { FX_MOTION, INSTANT, compileCues, fxRandom, noNegZero } from "./fx.mjs"; const esc = (s) => String(s ?? "") .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """); // `|| 0`: no -0 in the data (a JSON round trip makes it 0, and a cue list must survive one). const r2 = (v) => Math.round(v * 100) / 100 || 0; const r4 = (v) => Math.round(v * 10000) / 10000 || 0; /** The VHS stamp's mono, vendored beside the brand's faces; copied in as `assets/FxMono.ttf`. */ // Through assetFile (chrome-deck.mjs): a server bundle's asset URL is not fileURLToPath's. export const FX_MONO_FILE = assetFile(new URL("./fonts/IBMPlexMono-Bold.ttf", import.meta.url)); /** THEN's colour when the palette names none (`palette.then`), as the flips panel's. */ export const FX_THEN_COLOR = "#6fa8dc"; /** The glitch's colours: a red and a cyan channel, and the tear's white. */ export const FX_GLITCH_COLORS = Object.freeze(["rgba(255, 40, 70, 0.62)", "rgba(40, 230, 255, 0.58)", "rgba(255, 255, 255, 0.5)", "rgba(0, 0, 0, 0.55)"]); /** The receipts' resting tilt, card by card (degrees). */ export const FX_FAN = Object.freeze([-4, 3, -2, 5]); /** * Where a scrubber tick sits: its day on the rail, x0..x1 (region pixels). */ export const railX = (day, from, to, x0, x1) => x0 + ((day - from) / Math.max(1e-9, to - from)) * (x1 - x0); /** * The odometer's cell for one column: cell 0 is blank (a leading column the * number does not reach), cell d+1 is digit d, cell 11 is the 0 a 9 rolls on to. */ export function odoCells(value, digits) { const s = String(value).padStart(digits, " "); return [...s.slice(-digits)].map((ch) => (ch === " " ? 0 : Number(ch) + 1)); } /** * The zoom's push: the scale and offset (transform-origin top-left) that put * the focus box's centre in the card's centre at `fill` of the card. */ export function zoomPush(focus, cardW, cardH, fill = 0.86) { const fw = (focus[2] - focus[0]) * cardW, fh = (focus[3] - focus[1]) * cardH; const s = Math.max(1, fill * Math.min(cardW / fw, cardH / fh)); const cx = ((focus[0] + focus[2]) / 2) * cardW, cy = ((focus[1] + focus[3]) / 2) * cardH; return { scale: r4(s), x: r2(cardW / 2 - s * cx), y: r2(cardH / 2 - s * cy) }; } /** A card's size in the region: `width` wide by the shot's aspect, no taller than `maxH`. */ export function cardSize(dims, width, maxH) { const aspect = dims && dims.w > 0 && dims.h > 0 ? dims.h / dims.w : 0.75; let w = Math.round(width), h = Math.round(width * aspect); if (h > maxH) { h = Math.round(maxH); w = Math.round(maxH / aspect); } return { w, h }; } /** * Everything the effects do, as elements and events. Returns the page's body * markup, its init states and its cues. `assets` = `{ shots: {[path]: {src, w, h}}, * thumbs: {[segment]: src} }`. */ export function fxPlan(schedule, render, assets = {}) { const fx = schedule.fx; if (!fx) throw new Error("fx: the schedule draws no effects"); const geo = fxGeometry(render, { feed: schedule.layout === "feed" }); const W = geo.width, H = geo.height; const pal = render.palette; const k = W / 1574; const px = (v) => Math.max(1, Math.round(v * k)); const fps = schedule.fps ?? render.fps ?? 30; const frame = 1 / fps; const init = {}; const ev = []; const html = []; const add = (key, at, dur, to, ease = "none") => ev.push({ k: key, at, dur, to, ease }); const set = (key, at, to) => add(key, at, INSTANT, to); const shots = assets.shots ?? {}; const thumbs = assets.thumbs ?? {}; const thenC = /^#[0-9a-fA-F]{6}$/.test(pal.then ?? "") ? pal.then : FX_THEN_COLOR; // ---- the scrubber (drawn first: under everything) ----------------------- if (fx.scrubber) { const s = fx.scrubber; const top = s.position === "top"; // The rail keeps clear of the odometer when it sits in a corner on the // rail's edge of the box. const odo = fx.odometer; const odoW = odo ? px(36) + odo.digits * px(58) + px(28) + px(24) : 0; const odoSide = odo && odo.position.startsWith(top ? "top" : "bottom") ? odo.position.split("-")[1] : null; const x0 = odoSide === "left" ? odoW + px(24) : px(64); const x1 = odoSide === "right" ? W - odoW - px(24) : W - px(64); const railY = top ? px(38) : H - px(38); const X = (day) => r2(railX(day, s.from, s.to, x0, x1)); const thumbW = px(196), thumbH = Math.round((thumbW * 9) / 16); init.scr = { autoAlpha: 0 }; for (const sp of s.spans) { add("scr", sp.in, Math.min(0.35, (sp.out - sp.in) / 2), { autoAlpha: 1 }, "power2.out"); add("scr", Math.max(sp.in, sp.out - 0.3), Math.min(0.3, (sp.out - sp.in) / 2), { autoAlpha: 0 }, "power1.in"); } const years = s.years.map((y) => `
${y.year}
`).join(""); const ticks = s.ticks.map((t, n) => { const key = `sct${n}`; init[key] = { autoAlpha: 0.4, scale: 1 }; add(key, t.in, 0.25, { autoAlpha: 1, scale: 1.7 }, "back.out(3)"); add(key, Math.max(t.in + 0.25, t.out - 0.2), 0.2, { autoAlpha: 0.85, scale: 1 }, "power1.out"); return `
`; }).join(""); // The playhead and its thumbnail ride together; each clip's picture and // date hand over at the clip's in. init.sch = { x: X(s.ticks[0].day) }; s.ticks.forEach((t, n) => { if (n === 0) return; add("sch", t.in - FX_MOTION.rail / 2, FX_MOTION.rail, { x: X(t.day) }, "power3.inOut"); }); const cards = s.ticks.map((t, n) => { const key = `scc${n}`; init[key] = { autoAlpha: 0, y: top ? -10 : 10 }; add(key, t.in, FX_MOTION.thumb, { autoAlpha: 1, y: 0 }, "power2.out"); add(key, Math.max(t.in + FX_MOTION.thumb, t.out - FX_MOTION.thumb), FX_MOTION.thumb, { autoAlpha: 0, y: top ? -6 : 6 }, "power1.in"); const img = s.thumbs && thumbs[t.segment] ? `` : ""; return `
${img}
${esc(t.label)}
`; }).join(""); html.push( `
` + `
` + `
${years}${ticks}
` + `
` + `
${cards}
` + `
`, ); } // ---- receipts ------------------------------------------------------------------ if (fx.receipts) { const rc = fx.receipts; const right = rc.position !== "left"; const baseW = rc.width * W; rc.clips.forEach((row, r) => { const n = row.cards.length; const cardsHtml = row.cards.map((c, j) => { const key = `rc${r}_${j}`; const dims = shots[c.shot] ?? null; // A label is a band under the screenshot, the card that much taller. const band = c.label ? px(40) : 0; const { w, h } = cardSize(dims, baseW, H * 0.74 - band); const rot = FX_FAN[j % FX_FAN.length]; const restX = (right ? -1 : 1) * j * px(22); const restY = j * px(26) - ((n - 1) * px(26)) / 2; const left = right ? W - px(48) - w : px(48); const top = Math.round((H - h - band) / 2); const off = (right ? 1 : -1) * (w + px(140) + (right ? W - left - w : left)); init[key] = { x: r2(restX + off), y: r2(restY + px(40)), rotation: rot + (right ? 14 : -14), autoAlpha: 1 }; add(key, c.at, FX_MOTION.fan, { x: r2(restX), y: r2(restY), rotation: rot }, "power3.out"); add(key, row.out - 0.38 + (n - 1 - j) * 0.06, 0.32, { x: r2(restX + off), rotation: rot + (right ? 10 : -10) }, "power2.in"); let marker = ""; if (c.mark) { const mk = `rcm${r}_${j}`; const [a, b, cc, d] = c.mark; init[mk] = { scaleX: 0 }; add(mk, row.markAt + j * 0.12, FX_MOTION.marker, { scaleX: 1 }, "power2.inOut"); marker = `
`; } const src = dims?.src ?? ""; return `
` + (src ? `` : "") + marker + (c.label ? `
${esc(c.label)}
` : "") + `
`; }).join(""); html.push(`
${cardsHtml}
`); }); } // ---- the zoom ----------------------------------------------------------------- if (fx.zoom) { fx.zoom.clips.forEach((row, z) => { const dims = shots[row.shot] ?? null; const { w, h } = cardSize(dims, fx.zoom.width * W, H * 0.84); const left = Math.round((W - w) / 2), top = Math.round((H - h) / 2); const card = `zc${z}`, inner = `zi${z}`, box = `zo${z}`; init[card] = { autoAlpha: 0, y: px(36), scale: 0.94 }; add(card, row.in, 0.38, { autoAlpha: 1, y: 0, scale: 1 }, "back.out(1.4)"); add(card, row.out - 0.3, 0.3, { autoAlpha: 0, scale: 0.97 }, "power1.in"); init[box] = { autoAlpha: 0, scale: 1.35 }; add(box, row.outline, FX_MOTION.outline, { autoAlpha: 1, scale: 1 }, "power3.out"); const p = zoomPush(row.focus, w, h); init[inner] = { x: 0, y: 0, scale: 1 }; add(inner, row.push, FX_MOTION.push, { x: p.x, y: p.y, scale: p.scale }, "power2.inOut"); // Then a slow drift on the detail until it leaves, so the held frame // still breathes. About the focus centre: the offsets move with the scale. const drift = Math.max(0, row.out - 0.3 - (row.push + FX_MOTION.push)); if (drift > 0.4) { const s2 = r4(p.scale * 1.04); const cx = ((row.focus[0] + row.focus[2]) / 2) * w, cy = ((row.focus[1] + row.focus[3]) / 2) * h; add(inner, row.push + FX_MOTION.push, drift, { x: r2(w / 2 - s2 * cx), y: r2(h / 2 - s2 * cy), scale: s2 }, "none"); } const [a, b, c, d] = row.focus; const src = dims?.src ?? ""; html.push( `
` + `
` + (src ? `` : "") + `
` + `
` + `
`, ); }); } // ---- the line: kinetic or redacted -------------------------------------------- for (const [qi, q] of (fx.quotes ?? []).entries()) { const kinetic = q.style === "kinetic"; const cfg = kinetic ? schedule.fx.quoteStyle?.kinetic : schedule.fx.quoteStyle?.redact; const size = px(cfg?.size ?? (kinetic ? 54 : 44)); const posTop = (cfg?.position ?? "bottom") === "top"; q.pages.forEach((pg, p) => { const pk = `qp${qi}_${p}`; if (kinetic) { init[pk] = { autoAlpha: 0, y: px(14) }; add(pk, pg.in, FX_MOTION.page, { autoAlpha: 1, y: 0 }, "power2.out"); add(pk, Math.max(pg.in + FX_MOTION.page, pg.out - FX_MOTION.page), FX_MOTION.page, { autoAlpha: 0, y: -px(10) }, "power1.in"); } else { init[pk] = { autoAlpha: 0, rotation: -3, scale: 0.94 }; add(pk, pg.in, 0.3, { autoAlpha: 1, rotation: -1.2, scale: 1 }, "back.out(1.6)"); add(pk, Math.max(pg.in + 0.3, pg.out - FX_MOTION.page), FX_MOTION.page, { autoAlpha: 0, rotation: -0.6, scale: 0.98 }, "power1.in"); } const words = pg.words.map((w, j) => { const wk = `qw${qi}_${p}_${j}`; if (kinetic) { if (w.punch) { init[wk] = { autoAlpha: 0, scale: 1.8, y: 0 }; add(wk, w.at, FX_MOTION.punch, { autoAlpha: 1, scale: 1 }, "back.out(2.6)"); const uk = `qu${qi}_${p}_${j}`; init[uk] = { scaleX: 0 }; add(uk, w.at + 0.06, 0.22, { scaleX: 1 }, "power3.out"); return `${esc(w.text)}`; } init[wk] = { autoAlpha: 0, y: Math.round(size * 0.45), scale: 1 }; add(wk, w.at, FX_MOTION.word, { autoAlpha: 1, y: 0 }, "power3.out"); return `${esc(w.text)}`; } const bk = `qb${qi}_${p}_${j}`; init[bk] = { autoAlpha: 1, x: 0, y: 0, rotation: 0 }; add(bk, w.at, FX_MOTION.bar, { autoAlpha: 0, x: px(8), y: -px(20), rotation: -7 }, "power2.in"); let hl = ""; if (w.punch) { const hk = `qh${qi}_${p}_${j}`; init[hk] = { scaleX: 0 }; add(hk, w.at + 0.12, 0.26, { scaleX: 1 }, "power2.out"); hl = ``; } return `${hl}${esc(w.text)}`; }).join(" "); // Two voices: each on its own side, in its own colour, with its label // (the manifest's; none by default -- which voice, never whose). const voices = schedule.fx.quoteStyle?.voices; const vi = kinetic && voices && Number.isInteger(pg.speaker) ? pg.speaker : null; const voice = vi != null ? voices[vi] : null; const vstyle = voice?.color ? ` --vc:${voice.color};` : ""; const vlabel = voice?.label ? `
${esc(voice.label)}
` : ""; html.push( `
` + `
${vlabel}${words}
`, ); }); } // ---- the odometer ---------------------------------------------------------------- if (fx.odometer) { const o = fx.odometer; const digits = o.digits; const cellH = px(92); init.odc = { autoAlpha: 0, scale: 0.9 }; for (const sp of o.spans) { add("odc", sp.in, Math.min(0.35, (sp.out - sp.in) / 2), { autoAlpha: 1, scale: 1 }, "back.out(1.8)"); add("odc", Math.max(sp.in, sp.out - 0.3), Math.min(0.3, (sp.out - sp.in) / 2), { autoAlpha: 0, scale: 0.94 }, "power1.in"); } const first = odoCells(o.counts[0]?.prev ?? 0, digits); const cols = first.map((cell, c) => { const key = `odd${c}`; init[key] = { y: -cell * cellH }; return key; }); init.odp = { autoAlpha: 0, scale: 1 }; for (const cnt of o.counts) { if (cnt.value === cnt.prev) continue; const from = odoCells(cnt.prev, digits), to = odoCells(cnt.value, digits); cols.forEach((key, c) => { if (from[c] === to[c]) return; if (to[c] < from[c] && to[c] === 1) { // 9 → 0 rolls on to the second 0, then snaps back to the first. add(key, cnt.at, FX_MOTION.roll, { y: -11 * cellH }, "back.out(1.3)"); set(key, cnt.at + FX_MOTION.roll + frame, { y: -1 * cellH }); } else { add(key, cnt.at, FX_MOTION.roll, { y: -to[c] * cellH }, "back.out(1.3)"); } }); set("odp", cnt.at, { autoAlpha: 0.9, scale: 1 }); add("odp", cnt.at + frame, 0.5, { autoAlpha: 0, scale: 1.35 }, "power2.out"); } const cells = Array.from({ length: 12 }, (_, i) => `${i === 0 ? " " : i === 11 ? "0" : String(i - 1)}`).join(""); const [v, hpos] = o.position.split("-"); html.push( `
` + `
${cols.map((key) => `${cells}`).join("")}
` + (o.label ? `
${esc(o.label)}
` : "") + `
`, ); } // ---- the punch-in: a flash and a viewfinder as the footage snaps in ------------- if (fx.punchIn) { fx.punchIn.punches.forEach((pn, n) => { const fk = `pf${n}`, bk = `pb${n}`; init[fk] = { autoAlpha: 0 }; set(fk, pn.at, { autoAlpha: 0.32 }); add(fk, pn.at + frame, 0.14, { autoAlpha: 0 }, "power2.out"); init[bk] = { autoAlpha: 0, scale: 1.12 }; set(bk, pn.at, { autoAlpha: 1, scale: 1.12 }); add(bk, pn.at + frame, 0.22, { scale: 1 }, "power3.out"); add(bk, Math.max(pn.at + 0.3, pn.until - 0.2), 0.2, { autoAlpha: 0 }, "power1.in"); html.push( `
` + `
`, ); }); } // ---- the whip: speed streaks across the cut ------------------------------------ if (fx.whip) { fx.whip.cuts.forEach((wc, n) => { const rnd = fxRandom(7919 * (n + 3)); const streaks = []; for (let j = 0; j < 9; j += 1) { const key = `ws${n}_${j}`; const y = Math.round(rnd() * (H - px(20))); const h = Math.round(px(3) + rnd() * px(16)); const len = Math.round(W * (0.35 + rnd() * 0.5)); const delay = rnd() * wc.seconds * 0.3; // Each streak enters a third of the way in and rakes off the left, // fastest at the middle of the cut. const x0 = Math.round(W - len * 0.35); init[key] = { autoAlpha: 0, x: x0 }; set(key, wc.at + delay, { autoAlpha: 0.9 }); add(key, wc.at + delay + frame / 4, Math.max(frame, wc.seconds - delay), { x: -len - px(40) }, "sine.inOut"); set(key, wc.at + wc.seconds + frame, { autoAlpha: 0, x: x0 }); streaks.push(`
`); } html.push(`
${streaks.join("")}
`); }); } // ---- THEN / NOW ---------------------------------------------------------------- if (fx.thenNow) { const fw = render.width ?? 1920; fx.thenNow.wipes.forEach((wp, n) => { // With the cut's own wipe the divider rides xfade's edge, x = W(1 − p) // in the FRAME, linear; else it sweeps the box from just past its right // edge to just past its left. const x0 = wp.real ? fw - geo.x : W + px(20); const x1 = wp.real ? -geo.x : -px(20); const a = wp.at, d = wp.seconds; const xAt = (t) => x0 + ((x1 - x0) * (t - a)) / d; const tAt = (x) => a + (d * (x0 - x)) / (x0 - x1); const edge = px(28); const scrim = `tns${n}`, div = `tnd${n}`, tw = `tnt${n}`, nw = `tnn${n}`; init[scrim] = { autoAlpha: 0, width: W }; add(scrim, a - 0.35, 0.35, { autoAlpha: 1 }, "power1.out"); // The scrim is the box left of the divider: whole until the divider // enters the box, nothing once it has left. const tIn = x0 > W ? tAt(W) : a; const tOut = x1 < 0 ? tAt(0) : a + d; add(scrim, tIn, Math.max(INSTANT, tOut - tIn), { width: 0 }, "none"); set(scrim, a + d + frame, { autoAlpha: 0, width: W }); init[div] = { autoAlpha: 0, x: r2(x0) }; set(div, a, { autoAlpha: 1 }); add(div, a + frame / 4, d - frame / 4, { x: r2(x1) }, "none"); set(div, a + d + frame, { autoAlpha: 0 }); // THEN rides the divider's left, held inside the box until the divider // reaches it; NOW rides its right until the box's left edge stops it. const tHold = W - edge; init[tw] = { autoAlpha: 0, x: r2(Math.min(tHold, x0)) }; add(tw, a - 0.5, FX_MOTION.tag, { autoAlpha: 1 }, "power2.out"); const tStart = x0 > tHold ? tAt(tHold) : a; add(tw, tStart, Math.max(INSTANT, a + d - tStart), { x: r2(x1) }, "none"); set(tw, a + d + frame, { autoAlpha: 0 }); const nStop = edge; init[nw] = { autoAlpha: 0, x: r2(x0) }; set(nw, a, { autoAlpha: 1 }); const tStop = Math.min(a + d, tAt(nStop)); add(nw, a + frame / 4, Math.max(INSTANT, tStop - a - frame / 4), { x: r2(Math.max(nStop, xAt(tStop))) }, "none"); add(nw, a + d + FX_MOTION.hold, FX_MOTION.tag, { autoAlpha: 0 }, "power1.in"); html.push( `
` + `
` + `
` + `
THEN${wp.thenDate ? `${esc(wp.thenDate)}` : ""}
` + `
NOW${wp.nowDate ? `${esc(wp.nowDate)}` : ""}
` + `
`, ); }); } // ---- the glitch (drawn last: over everything) ------------------------------------ if (fx.glitch) { fx.glitch.bursts.forEach((b, n) => { const a = b.at - b.seconds / 2; const steps = Math.max(3, Math.round((b.seconds * fps) / 2)); const stepDur = b.seconds / steps; const rnd = fxRandom(9301 * (b.seed + 1)); const SL = 7; const sk = `gs${n}`; init[sk] = { autoAlpha: 0 }; const slices = []; for (let j = 0; j < SL; j += 1) { const key = `gl${n}_${j}`; init[key] = { autoAlpha: 0, y: 0, x: 0, height: px(10) }; slices.push(`
`); } const noise = [0, 1, 2].map((v) => { const key = `gn${n}_${v}`; init[key] = { autoAlpha: 0 }; return `` + `` + ``; }); for (let s = 0; s < steps; s += 1) { const t = a + s * stepDur; // The tear is worst at the cut and settles either side of it. const env = 1 - Math.abs((s + 0.5) / steps - 0.5) * 1.4; set(sk, t, { autoAlpha: r2(0.35 + 0.5 * env) }); for (let v = 0; v < 3; v += 1) set(`gn${n}_${v}`, t, { autoAlpha: v === s % 3 ? r2(0.12 + 0.2 * env) : 0 }); for (let j = 0; j < SL; j += 1) { const on = rnd() < 0.35 + 0.55 * env; const hgt = Math.round(px(4) + rnd() * px(70) * env); set(`gl${n}_${j}`, t, on ? { autoAlpha: 1, y: Math.round(rnd() * (H - hgt)), x: Math.round((rnd() - 0.5) * px(160) * env), height: hgt } : { autoAlpha: 0, y: 0, x: 0, height: px(10) }); } } const end = a + b.seconds; set(sk, end, { autoAlpha: 0 }); for (let v = 0; v < 3; v += 1) set(`gn${n}_${v}`, end, { autoAlpha: 0 }); for (let j = 0; j < SL; j += 1) set(`gl${n}_${j}`, end, { autoAlpha: 0, y: 0, x: 0, height: px(10) }); let year = ""; // The new year big over the tear, unless the glitch is bare (`year: false`). if (b.year != null && fx.glitch.year !== false) { const yk = `gy${n}`; init[yk] = { autoAlpha: 0, x: 0, scale: 1.25 }; set(yk, b.at - stepDur, { autoAlpha: 1, x: px(-22), scale: 1.25 }); set(yk, b.at, { autoAlpha: 0.85, x: px(18), scale: 1.1 }); add(yk, b.at + stepDur, 0.18, { autoAlpha: 1, x: 0, scale: 1 }, "power3.out"); add(yk, end + 0.45, 0.25, { autoAlpha: 0, scale: 0.96 }, "power1.in"); year = `
${b.year}
`; } let stamp = ""; if (fx.glitch.stamp && b.date) { const vk = `gv${n}`; init[vk] = { autoAlpha: 0 }; set(vk, b.at, { autoAlpha: 1 }); set(vk, b.at + 1.8, { autoAlpha: 0 }); stamp = `
PLAY ▶${esc(b.date.toUpperCase())}
`; } html.push( `
${noise.join("")}
${slices.join("")}${year}${stamp}
`, ); }); } const cues = compileCues(init, ev); for (const key of Object.keys(init)) init[key] = noNegZero(init[key]); return { W, H, k, init, cues, body: html.join("\n "), thenC }; } /** * The effects composition's HTML, for the whole cut -- or a window of it * (`from`/`duration`, as the deck's). `fonts` = `{ regular, bold, mono }`; * `assets` as `fxPlan`'s. `?still=` and the preview's `deck:seek` take CUT * seconds. */ export function fxHtml(schedule, render, opts = {}) { const plan = fxPlan(schedule, render, opts.assets ?? {}); const { W, H, k } = plan; const px = (v) => Math.max(1, Math.round(v * k)); const pal = render.palette; const fonts = opts.fonts ?? {}; const gsapSrc = opts.gsap ?? "assets/gsap.min.js"; const total = schedule.total; const from = Number(opts.from ?? 0); const dur = opts.duration != null ? r4(Number(opts.duration)) : r4(total - from); if (!(dur > 0)) throw new Error(`fx: nothing to render from ${from}s of a ${total}s cut`); const windowed = from > 0 || Math.abs(dur - total) > 1e-6; const fps = schedule.fps ?? render.fps ?? 30; const data = { total: r4(total), window: windowed ? { from: r4(from), dur } : null, keys: schedule.fx.keys, init: plan.init, cues: plan.cues, }; const json = JSON.stringify(data).replace(/
${plan.body}
`; }