commit c7ee78ad49c0a4180f5f25066b0fc0da2ff7e406
parent eccf6e1358fa7f9c94cf1df6bba18b41ddfbb992
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 4 Nov 2026 20:38:03 -0500
Merge main (slam-bar, the slur mask) into lane/join-continuity: the post record keeps main's fields and the join's `joinAnchor`
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
16 files changed, 271 insertions(+), 38 deletions(-)
diff --git a/umtool/components/projects/PostZoomPanel.tsx b/umtool/components/projects/PostZoomPanel.tsx
@@ -248,6 +248,7 @@ export default function PostZoomPanel({
</b>
<span className="text-text-2">
{typeof fx0.match === "string" ? `on “${sl.match}” · ` : ""}
+ {typeof fx0.bar === "string" ? `on a bar “${fx0.bar}” · ` : ""}
{t?.error ? `no time: ${t.error}` : `hits at ${hits.map((x) => x.toFixed(2)).join(", ")} s (${t.source === "words" ? "over the spoken word" : t.source === "at" ? "its at" : "the estimate"})`}
</span>
<button type="button" className="ink-link ml-auto" onClick={() => setS(Math.max(0, (hits[0] ?? 0) - 0.6))} disabled={!hits.length} data-post-slam-go={i}>
diff --git a/umtool/components/projects/review/PostItemPlayer.tsx b/umtool/components/projects/review/PostItemPlayer.tsx
@@ -15,7 +15,7 @@ import {
import { clockCss, clockFace, clockHtml, clockStateAt, measureClockPlace, mountClock, setClockState } from "umtool-report-to-video/post-clock";
import { measureProgressPlace, mountProgress, progressAt, progressCss, progressHeight, progressOpacityAt, setProgressState } from "umtool-report-to-video/post-progress";
import {
- SLAM_DUST, SLAM_FACE_STACK, SLAM_MOTION, mountSlams, setSlamState, slamCss, slamHits, slamLayout, slamListAt, slamPlan, slamShakeAt, slamSize, slamVars,
+ SLAM_DUST, SLAM_FACE_STACK, SLAM_MOTION, mountSlams, slamBarOf, setSlamState, slamCss, slamHits, slamLayout, slamListAt, slamPlan, slamShakeAt, slamSize, slamVars,
} from "umtool-report-to-video/post-slam";
import { TRAILER_AUDIO, trailerHitSamples } from "umtool-report-to-video/trailer-hits";
import { WORD_ZOOM_HIGHLIGHT_ALPHA, findMatch, highlightAt, resolveWordZoom, targetScope, targetTextOf, wordZoomTimes, zoomAt, zoomProgressAt, zoomSpan, zoomWindow } from "umtool-report-to-video/word-zoom";
@@ -64,7 +64,7 @@ export type ProgressPlan = { from: number; to: number; ticks: number[]; until: n
/** A caption of the item, placed in its card page: its span, its place, the phrase's box and lines when placed. */
type LiveCaption = { i: number; span: { t0: number; t1: number; t2: number; t3: number }; scope: string; from: number; to: number; placed: NonNullable<ReturnType<typeof placeCaption>>; base: Rect; lines: Rect[] };
/** A slam of the item, placed in its card page: its plan (span, units, its fx), each unit's centre, the words' box when placed. */
-type LiveSlam = { i: number; span: { t0: number; t2: number; t3: number; landings: number[] }; fx: Record<string, unknown> & { fromScale: number; volume: number }; scope: string | null; from: number; to: number; centers: Array<{ x: number; y: number }>; base: Rect | null; where: string };
+type LiveSlam = { i: number; span: { t0: number; t2: number; t3: number; landings: number[] }; fx: Record<string, unknown> & { fromScale: number; volume: number }; scope: string | null; from: number; to: number; centers: Array<{ x: number; y: number }>; bar: { cx: number; cy: number } | null; base: Rect | null; where: string };
type LiveZoom = { i: number; span: ReturnType<typeof zoomSpan>; scope: string; from: number; to: number; color: string | null; region: Rect; word: Rect };
/** The card's children placed so the region shows `win` (zoomWindow) at z; their layout boxes measured before any transform. */
@@ -737,7 +737,8 @@ export default function PostItemPlayer({
const size = slamSize(p.fx, line, k);
p.units.forEach((text: string, kk: number) => all.push({ i: p.i, k: kk, text, size, face: SLAM_FACE_STACK[p.fx.face as keyof typeof SLAM_FACE_STACK] ?? SLAM_FACE_STACK.jp, vars: slamVars(p.fx, size) }));
}
- const boxes = mountSlams(all.length ? { css: slamCss(), units: all, dust: [...SLAM_DUST] } : null, doc);
+ const bars = splan.map((p) => slamBarOf(p, k)).filter((b): b is NonNullable<typeof b> => !!b);
+ const boxes = mountSlams(all.length ? { css: slamCss(), units: all, dust: [...SLAM_DUST], bars } : null, doc);
splan.forEach((p, pi) => {
const g = geos[pi];
const cardEl = doc.querySelector("[data-post-card]");
@@ -745,7 +746,7 @@ export default function PostItemPlayer({
if (!cardBox || (p.scope && !g)) return;
const units = boxes.filter((b) => b.i === p.i).sort((a, b) => a.k - b.k);
const lay = slamLayout({ word: g ? g.word : null, card: cardBox, bounds: bounds0, units, place: p.fx.place, gap: Math.round(6 * k), protect: g ? [...g.lines, ...g.avoid] : [], obstacles: g ? g.obstacles : [] });
- placedSlams.push({ i: p.i, span: p.span, fx: p.fx, scope: p.scope, from: p.from, to: p.to, centers: lay.centers, base: g ? g.word : null, where: lay.where });
+ placedSlams.push({ i: p.i, span: p.span, fx: p.fx, scope: p.scope, from: p.from, to: p.to, centers: lay.centers, bar: lay.bar, base: g ? g.word : null, where: lay.where });
});
}
setSlams(placedSlams);
@@ -1006,6 +1007,7 @@ export default function PostItemPlayer({
data-post-slams={slams.length ? String(slams.length) : undefined}
data-post-slam-fx={slamsUp.length ? slamsUp.map((p) => String(p.i)).join(" ") : undefined}
data-post-slam-where={slams.length ? slams.map((p) => p.where).join(" ") : undefined}
+ data-post-slam-bar={slams.some((p) => p.bar) ? slams.map((p) => (p.bar ? "1" : "0")).join(" ") : undefined}
data-post-slam-landed={slamsUp.length ? String(slamsUp.reduce((a, p) => a + p.span.landings.filter((L) => L <= s).length, 0)) : undefined}
data-post-progress={progFrac !== null ? String(Math.round(progFrac * 1000) / 1000) : undefined}
data-post-progress-place={progress && progAt ? `${Math.round(progAt.x)},${Math.round(progAt.y)},${Math.round(progAt.width)}` : undefined}
diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md
@@ -94,7 +94,7 @@ Inbox cannot disagree about what is wrong with one.
| `posts narrate <project> --import [--dry-run] [--json]` · `--list` · `<item> [--script "…"] [--pick <n>] [--approve\|--unapprove] [--off\|--on] [lead= tail= ramp= linger= clip=read\|full wet= lowpass= duck=on\|off short=hold\|loop attach=under\|after lufs= pace=fast\|normal]` · `<item> --take [--note "…"] [--voice v] [--engine e] [--speed s] [--script "…"]` · `<item> --derive <n> --op enhance\|convert [--engine e] [--voice v]` · `<item> --delete <n>` · `--all --draft-scripts [--force]` · `--all --take [--limit N]` · `--cut <k=v>…` | a **narrated post item** ([report-video.md](report-video.md#narrated-post-items), [knobs.md](knobs.md#a-narrated-post-item)): `--import` reads `narration/posts/index.json` (`[{id, entry, script, takes: [{file, engine, voice, seconds}], pick}]`, and a take's `take-<n>.parts.json`) into the cut in ONE write, measuring each take (length, loudness); a re-run adds only takes not there. `--take` asks the EDITOR for a new take (`POST /api/ops/tts`, its `out` the next `narration/posts/<postId>/take-<n>.<engine>-<voice>.wav`; a job, waited for; `ARCHILYZER_EDITOR_URL`, `WORKER_TOKEN`) and picks it, its `--note` kept with it; `--pick <n>` is the take's number as `--list` shows it. `--derive <n>` makes a NEW take from take n through the editor's `voice-enhance` / `voice-convert` op (a stock synthetic voice; "not installed" until the editor has the engine), the original kept; `--delete <n>` moves a take's file to the post's `.trash/`. A new script or pick takes the approval away. `--all --draft-scripts` writes every post's words as its script, VERBATIM (cleaned only to be spoken: @handles, links, emoji dropped; `plan(s)` → plans, `w/` → with, `&` → and; paragraphs kept). `--cut` sets `render.postNarration` (and its read-follow: `follow=on\|off`, `follow.dim=`, `follow.ease=`; its thread reads: `thread.parent=`, `thread.quoted=`, `thread.carry=`, `thread.reveal=`, `thread.shrink=`, `thread.dim=`, `thread.seconds=`, `thread.pan=`). Refused in the build's words (**exit 1**) |
| `posts fx <project> <item> add caption --match "…" --text "…" [--target post\|quoted\|parent:<i>] [--occurrence n] [--at s] [--lead s] [--hold s] [--place below\|above\|side]` · `add clock [--rewind auto\|on\|off] [--off]` · `set <n> [--text …] [--place …] [--rewind …]` | a post item's **caption** ([report-video.md](report-video.md#a-caption), [knobs.md](knobs.md#a-caption-a-chip-explaining-a-phrase-as-it-is-read)): a chip explaining a phrase (any script: CJK drawn), up as it is read -- `--at`, else the take's word timings, else the reading estimate -- held `--hold` s, by the phrase and never over a word read while it is up; it waits for a word zoom. Its **clock** ([knobs.md](knobs.md#the-clock-each-posts-own-time-on-its-card-run-between-items)): the post's own time on the card, run from the clock item before it (forward; a REWIND when earlier: `--rewind`), `--off` not on this item. Through `updatePostFx`, refused in the build's words (**exit 1**); a zoom's knob on a caption, or a caption's on a zoom (**exit 1**) |
| `posts clock <project> [on\|off\|default] [--zone <IANA zone>] [--json]` | the cut's **clock** default (`render.posts.clock`, `updatePostClock`); bare, which items show it and their times |
-| `posts fx <project> <item> add slam --text "不動心" [--match "…" \| --at s] [--whole \| --per-glyph] [--gap s] [--hold s] [--from-scale x] [--color #rrggbb] [--outline #rrggbb] [--outline-width px] [--place over-match\|center] [--size px] [--face jp\|sc\|tc\|kr] [--sfx trailer-hit\|off] [--volume x] [--swell \| --no-swell]` · `set <n> [those flags]` | a post item's **slam** ([report-video.md](report-video.md#a-slam), [knobs.md](knobs.md#a-slam-a-trailer-style-title-slam-over-a-word-as-it-is-read)): a corny trailer title slam -- each glyph huge, shrinking onto the card just above the matched words' line and HITTING (a flash, dust, the frame's punch, a trailer hit's boom: the teaser's generator, `trailer-hits.mjs`), gold with a black outline; the hits spread evenly over the words' spoken span (`--gap` spaces them, `--at` moves the first), held `--hold` s; a caption up with it waits for it. Through `updatePostFx`, refused in the build's words (**exit 1**); a slam's knob on another effect, or another's on a slam (**exit 2**) |
+| `posts fx <project> <item> add slam --text "不動心" [--match "…" \| --at s] [--whole \| --per-glyph] [--gap s] [--hold s] [--from-scale x] [--color #rrggbb] [--outline #rrggbb] [--outline-width px] [--place over-match\|center] [--size px] [--face jp\|sc\|tc\|kr] [--sfx trailer-hit\|off] [--volume x] [--swell \| --no-swell] [--bar "…" [--bar-style dark\|gold\|plain]]` · `set <n> [those flags; --bar off clears it]` | a post item's **slam** ([report-video.md](report-video.md#a-slam), [knobs.md](knobs.md#a-slam-a-trailer-style-title-slam-over-a-word-as-it-is-read)): a corny trailer title slam -- each glyph huge, shrinking onto the card just above the matched words' line and HITTING (a flash, dust, the frame's punch, a trailer hit's boom: the teaser's generator, `trailer-hits.mjs`), gold with a black outline; the hits spread evenly over the words' spoken span (`--gap` spaces them, `--at` moves the first), held `--hold` s; `--bar` lands the glyphs on a translation bar (rising in at the first hit, faded with them); a caption up with it waits for it. Through `updatePostFx`, refused in the build's words (**exit 1**); a slam's knob on another effect, or another's on a slam (**exit 2**) |
| `posts fx <project> <item> [ls]` · `add word-zoom --match "…" [--target post\|quoted\|parent:<i>] [--occurrence n] [--at s] [--scale s] [--hold s] [--lead s] [--ease out\|inOut\|snap] [--highlight #rrggbb\|off]` · `set <n> [those flags; default clears one]` · `remove <n>` · `posts narrate <project> <item> --words [--worker <id>]` | a post item's **word zoom** ([report-video.md](report-video.md#a-word-zoom), [knobs.md](knobs.md#a-word-zoom-a-post-items-card-pushed-in-on-a-word-as-it-is-read)): the card pushed in on a word as it is read, a highlight under it, then back out -- through `updatePostFx`, refused in the build's words (a match not in the words, a knob out of bounds; **exit 1**). Its time is `--at`, else the word's start in the picked take's word timings; `ls` prints each zoom's time and where it came from. An un-narrated post's `add` fills `at` with the reading estimate. `--words` asks the EDITOR's transcribe op (`words: true`, a job per take or per part file; `ARCHILYZER_EDITOR_URL`, `WORKER_TOKEN`) and keeps the words heard, aligned to the script, on the take (`takes[i].words`) |
| `posts fit <project> [--all \| <item> …] [--linger <s>] [--dry-run] [--json]` · `posts set-item <project> <item> fit=read[:<linger>]` | narrated posts' video attachments cut to their **best part** for the read (lead + take + tail + linger): a scored scan of the sound (loudness, its peaks), the speech (a transcript) and the scene cuts, the start snapped to a pause or a cut, recorded with why (`narration.window`) -- ONE write; each post's old and new length printed. A video no longer than the read is left as it is |
| `posts avatar <project> [<handle> <image-file> \| <handle> off] [--json]` · `posts avatars <project> [--dry-run] [--json]` | the **authors' pictures** (`postAvatars`): `avatar` copies a picture into `posts-media/_avatars/` for every card that draws that handle (manual; never replaced by the archive's), `off` clears it, no handle lists them; `avatars` copies the archive's (the channels' `posts-media/_avatars/avatars.json`, capture-posts') for every author the cut's cards draw unblurred that it has none of. A blurred author never shows one |
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -816,6 +816,7 @@ time, the place, the one exemption, the sound, the render). One writer, `updateP
| WHEN -- the hits spread evenly over the matched words' spoken span (the first on its start, the last on its end); `gap` 0.12–2 s spaces them instead; `at` (item seconds) moves the first; no span: 0.45 s apart | the slam's row (its hits; **go**) | `set <n> --gap 0.4` · `set <n> --at 4.1` (`default` clears one) | `fx: {set: <i>, patch: {gap, at}}` |
| THE LOOK -- `hold` 0.3–4 s after the last hit (1.6), `fromScale` 1.5–8 (3.5), `color` (#f5c542) and `outline` (#000000), `outlineWidth` 0–30 px (at a 120 px glyph; default 11% of the glyph), `size` 40–320 px at 1080 (by the words' line), `face` `jp` \| `sc` \| `tc` \| `kr` (Noto Sans CJK Black; 八极拳 reads `sc`) | — | `set <n> --hold 2 --from-scale 4 --color #ffd700 --outline #000000 --outline-width 14 --size 130 --face sc` | `fx: {set: <i>, patch: {…}}` |
| WHERE -- `place` `over-match` (above the words' line; below it when above is out of the frame or over a word read at a hit) \| `center` (the card's middle) | — | `set <n> --place center` | `fx: {set: <i>, patch: {place}}` |
+| THE BAR -- `bar` (≤ 140 characters: the translation the glyphs land ON, the part before " — " bold; `fudōshin — "immovable mind"`), `barStyle` `dark` (default: the card's ground, a thin gold rule) \| `gold` \| `plain` -- it rises in as the first glyph lands, holds through the hold and fades with the glyphs; the row and the bar are placed as one block (above the words' line, below it when too tall above or over a word read at a hit). The caption module stays as it was: an item may still carry one (it waits for the slam) | the slam's row shows its bar | `set <n> --bar 'fudōshin — "immovable mind"' [--bar-style gold]` · `--bar off` clears it | `fx: {set: <i>, patch: {bar, barStyle}}` |
| THE SOUND -- `sfx` `trailer-hit` \| `off`, `volume` 0–3 × the hit's level (1), `swell` (the teaser's swell under the hold) | — | `set <n> --sfx off` · `--volume 0.7` · `--swell` / `--no-swell` | `fx: {set: <i>, patch: {sfx, volume, swell}}` |
| remove one | the slam's **remove** | `umtool posts fx <p> <item> remove <n>` | `fx: {remove: <i>}` |
| list them, each with its hits and where they came from | the block's rows; the plan strip marks each (yellow, a tick per hit) | `umtool posts fx <p> <item> [ls] [--json]` | — |
diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md
@@ -726,7 +726,9 @@ character"; "do it above the word on the page"; "do the same with baji quan (八
"size": 120, // px at 1080; absent: 2.5 × the words' line, 64–170
"face": "jp", // Noto Sans CJK JP | SC | TC | KR, Black (八极拳: "sc")
"sfx": "trailer-hit", // | "off"
- "volume": 1, "swell": false // × the hit's level; the teaser's low swell under the hold
+ "volume": 1, "swell": false, // × the hit's level; the teaser's low swell under the hold
+ "bar": "fudōshin — \"immovable mind\"", // a translation bar the glyphs land ON (≤ 140 characters)
+ "barStyle": "dark" // "dark" (default: the card's ground, a thin gold rule) | "gold" | "plain"
}]
```
@@ -749,6 +751,17 @@ below it when there is no room above in the frame, or when the row would cover a
read as a glyph lands; `center`: the card's middle. Kept in the frame. It rides the card's
pan (read-follow): every frame is placed by where the words are drawn then.
+**The bar** (operator, 4 Nov: "have the characters appear above a bar with the translation
+rather than have the tooltip pop up after, though keep that tooltip as a module"): with
+`bar`, the glyph row lands ON a bar carrying the translation -- centred on it, standing on its
+gold rule -- in a clean sans (the card's face, 30 px at 1080, balanced over at most two lines
+of 820 px). It rises in as the first glyph lands (0.28 s), holds through the hold and fades
+with the glyphs. The row and the bar are ONE block for the placing rules below: above the
+words' line, below it when the block is too tall above or would cover a word being read. The
+caption stays its own module; an item carrying both shows the caption after the slam. A slam
+with a bar draws at its own version in the segment key (its look appended); one without keeps
+its key.
+
**The one exemption** (deliberate, the gag): the landed row may cover the line ABOVE the
word -- for the slam's own window only (its hits, its hold, its fade). It is drawn OVER the
card, never in it (no `data-w`, no `data-post-block`), so the read-follow geometry and
diff --git a/umtool/e2e/post-slam.spec.ts b/umtool/e2e/post-slam.spec.ts
@@ -117,3 +117,30 @@ test("A PHRASE (operator, 4 Nov: 八极拳 on \"Baji Quan\"): a two-word match,
expect(await page.frameLocator('[data-post-card-frame="read"]').locator(".pslam").first().evaluate((el) => el.ownerDocument.fonts.check("900 100px 'Noto Sans CJK SC'", "八极拳"))).toBe(true);
if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "post-slam-phrase.png") });
});
+
+test("THE BAR (operator, 4 Nov: \"have the characters appear above a bar with the translation\"): the glyphs land ON a translation bar, the two above the word and over none of it; the caption module untouched", async ({ page }) => {
+ const m = manifest();
+ Object.assign(m.timeline.find((e) => e.id === "p-11")!, { fx: [{ kind: "slam", text: "不動心", match: "speaks", gap: 0.22, volume: 0.5, bar: "fudōshin — \"immovable mind\"" }] });
+ writeFileSync(MANIFEST, JSON.stringify(m, null, 2) + "\n");
+ await page.setViewportSize({ width: 1500, height: 1000 });
+ await page.goto(urls.playHref(PROJECT, { bare: true, clip: "p-11" }));
+ const player = await playUntilLanded(page, "p-11", 3);
+ await expect(player).toHaveAttribute("data-post-slam-bar", "1");
+ const bar = page.frameLocator('[data-post-card-frame="read"]').locator(".pslam-bar");
+ await expect(bar).toContainText("fudōshin");
+ await expect(bar).toContainText("immovable mind");
+ await expect.poll(() => bar.evaluate((el) => Number((el as HTMLElement).style.opacity))).toBeGreaterThan(0.5);
+ const barBox = await bar.evaluate((el) => {
+ const b = el.getBoundingClientRect();
+ return { x: b.left, y: b.top, width: b.width, height: b.height };
+ });
+ const { units, words } = await slamBoxes(page);
+ const word = words.find((w) => w.id === "post:2")!;
+ // The row stands on the bar, centred on it; the bar sits above the word, over none of it.
+ for (const u of units) expect(u.y + u.height).toBeLessThanOrEqual(barBox.y + 4);
+ const mid = (units[0].x + units[2].x + units[2].width) / 2;
+ expect(Math.abs(mid - (barBox.x + barBox.width / 2))).toBeLessThan(4);
+ expect(overlap(barBox, word)).toBe(0);
+ expect(barBox.y + barBox.height).toBeLessThanOrEqual(word.y + 2);
+ if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "post-slam-bar.png") });
+});
diff --git a/umtool/lib/report/postFx.test.mjs b/umtool/lib/report/postFx.test.mjs
@@ -139,3 +139,21 @@ test("posts fx add slam: its glyphs and word kept, its hits listed (the estimate
assert.equal(r.code, 2);
assert.match(r.err, /add slam needs --match/);
});
+
+test("posts fx slam --bar: the translation bar set (its style too), shown by ls, cleared with --bar off", async () => {
+ const p = await project("slambar", [item("1")]);
+ let r = await cli(["fx", "slambar", "p-1", "add", "slam", "--text", "不動心", "--match", "barbecue", "--gap", "0.22", "--volume", "0.5", "--bar", "fudōshin — \"immovable mind\""]);
+ assert.equal(r.code, 0, r.err);
+ assert.match(r.out, /0\.22 s apart from the reading estimate/);
+ assert.match(r.out, /· on a dark bar "fudōshin — "immovable mind""/);
+ r = await cli(["fx", "slambar", "p-1", "set", "1", "--bar-style", "gold"]);
+ assert.equal(r.code, 0, r.err);
+ assert.deepEqual((await manifest(p)).timeline[0].fx[0], { kind: "slam", text: "不動心", match: "barbecue", gap: 0.22, volume: 0.5, bar: "fudōshin — \"immovable mind\"", barStyle: "gold" });
+ // A style with no bar is refused in the build's words.
+ r = await cli(["fx", "slambar", "p-1", "set", "1", "--bar", "off"]);
+ assert.equal(r.code, 1);
+ assert.match(r.err, /the slam has no bar/);
+ r = await cli(["fx", "slambar", "p-1", "set", "1", "--bar", "off", "--bar-style", "default"]);
+ assert.equal(r.code, 0, r.err);
+ assert.equal((await manifest(p)).timeline[0].fx[0].bar, undefined);
+});
diff --git a/umtool/lib/report/postFxCli.mjs b/umtool/lib/report/postFxCli.mjs
@@ -13,7 +13,7 @@
// umtool posts fx <p> <item> add slam --text "不動心" [--match "…" | --at s] [--whole | --per-glyph] [--gap s]
// [--hold s] [--from-scale x] [--color #] [--outline #] [--outline-width px]
// [--place over-match|center] [--size px] [--face jp|sc|tc|kr] [--sfx trailer-hit|off]
-// [--volume x] [--swell | --no-swell] (post-slam.mjs)
+// [--volume x] [--swell | --no-swell] [--bar "…" [--bar-style dark|gold|plain]] (post-slam.mjs)
// umtool posts fx <p> <item> set <n> [the same flags; a flag's value `default` clears it]
// umtool posts fx <p> <item> remove <n>
// umtool posts narrate <p> <item> --words [--worker <id>]
@@ -42,7 +42,8 @@ export const FX_USAGE = [
" umtool posts fx <project> <item> add clock [--rewind auto|on|off] [--off]",
" umtool posts fx <project> <item> add slam --text \"不動心\" [--match \"…\" | --at s] [--whole | --per-glyph] [--gap s] [--hold s]",
" [--from-scale x] [--color #rrggbb] [--outline #rrggbb] [--outline-width px] [--place over-match|center]",
- " [--size px] [--face jp|sc|tc|kr] [--sfx trailer-hit|off] [--volume x] [--swell | --no-swell] [--json]",
+ " [--size px] [--face jp|sc|tc|kr] [--sfx trailer-hit|off] [--volume x] [--swell | --no-swell]",
+ " [--bar \"<the translation>\" [--bar-style dark|gold|plain]] [--json]",
" umtool posts fx <project> <item> set <n> [those flags; `default` clears one] | remove <n>",
" A WORD ZOOM: the card pushed in on a word (or a phrase) as it is read, a highlight under it, then back out.",
" --match is the word as the card shows it (case and edge punctuation aside); --occurrence its n-th time in the",
@@ -69,6 +70,9 @@ export const FX_USAGE = [
` ${SLAM_GAP} s apart). Held --hold s after the last (${SLAM_DEFAULTS.hold}), then gone; a caption up with it waits for it.`,
` --size px at 1080 (default: by the word's line), --face ${SLAM_FACES.join("|")} (the CJK forms, ${SLAM_DEFAULTS.face}), --sfx ${SLAM_SFX.join("|")},`,
" --volume × the hit's level (1), --swell the teaser's low swell under the hold.",
+ " --bar \"fudōshin — \\\"immovable mind\\\"\": the glyphs land ON a translation bar (rising in at the first hit, held,",
+ " faded with them; the part before \" — \" bold), the row and the bar placed as one; --bar-style dark (the card's",
+ " ground, a gold rule) | gold | plain; --bar off clears it.",
].join("\n");
export class FxError extends Error {}
@@ -78,7 +82,7 @@ const NUM_KEYS = {
"--gap": "gap", "--from-scale": "fromScale", "--outline-width": "outlineWidth", "--size": "size", "--volume": "volume",
};
/** A slam's own knobs (the CLI refuses them on another kind, and another kind's on a slam). */
-const SLAM_ONLY = ["gap", "fromScale", "outlineWidth", "size", "volume", "color", "outline", "face", "sfx", "whole", "swell"];
+const SLAM_ONLY = ["gap", "fromScale", "outlineWidth", "size", "volume", "color", "outline", "face", "sfx", "whole", "swell", "bar", "barStyle"];
/** The flags as an effect patch (null: back to the default). `has`: a bare flag's presence (--whole, --swell). */
export function fxPatchOf(str, has = () => false) {
@@ -109,6 +113,10 @@ export function fxPatchOf(str, has = () => false) {
const v = str(flag);
if (v !== null) out[key] = v === "default" ? null : v;
}
+ const bar = str("--bar");
+ if (bar !== null) out.bar = ["default", "off", "none"].includes(bar) ? null : bar;
+ const bs = str("--bar-style");
+ if (bs !== null) out.barStyle = bs === "default" ? null : bs;
if (has("--whole")) out.whole = true;
if (has("--per-glyph")) out.whole = null;
if (has("--swell")) out.swell = true;
@@ -142,9 +150,9 @@ export function fxLines(e, render) {
else {
const L = slamLandings(fx0, { t: t.t, end: t.end ?? null });
const sp = slamSpan(fx0, L);
- when = `hits at ${L.map((x) => x.toFixed(2)).join(", ")} s (${t.source === "words" ? "spread over the words' spoken span" : t.source === "at" ? "from its at" : "the reading estimate"}), gone by ${sp.t3 ?? "?"} s`;
+ when = `hits at ${L.map((x) => x.toFixed(2)).join(", ")} s (${Number.isFinite(fx0.gap) ? `${fx0.gap} s apart from ${t.source === "words" ? "the word's start" : t.source === "at" ? "its at" : "the reading estimate"}` : t.source === "words" ? "spread over the words' spoken span" : t.source === "at" ? "from its at" : "the reading estimate"}), gone by ${sp.t3 ?? "?"} s`;
}
- return ` #${i + 1} slam "${sl.text}"${typeof fx0.match === "string" ? ` on "${sl.match}" (${sl.target}, ${nth(sl.occurrence)})` : ""} ${when} · ${sl.whole ? "whole" : "per glyph"}, ${sl.fromScale}× in, held ${sl.hold} s, ${sl.place}, ${sl.color}/${sl.outline}, face ${sl.face}, sfx ${sl.sfx}${sl.volume !== 1 ? ` ×${sl.volume}` : ""}${sl.swell ? ", swell" : ""}${sl.size ? `, ${sl.size} px` : ""}`;
+ return ` #${i + 1} slam "${sl.text}"${typeof fx0.match === "string" ? ` on "${sl.match}" (${sl.target}, ${nth(sl.occurrence)})` : ""} ${when} · ${sl.whole ? "whole" : "per glyph"}, ${sl.fromScale}× in, held ${sl.hold} s, ${sl.place}, ${sl.color}/${sl.outline}, face ${sl.face}, sfx ${sl.sfx}${sl.volume !== 1 ? ` ×${sl.volume}` : ""}${sl.swell ? ", swell" : ""}${sl.size ? `, ${sl.size} px` : ""}${typeof fx0.bar === "string" ? ` · on a ${sl.barStyle} bar "${fx0.bar}"` : ""}`;
}
if (fx0?.kind === "clock") {
const on = fx0.on !== false;
@@ -242,7 +250,7 @@ export async function fxCommand(project, words, { json = false, out = (s) => con
if (verb === "set") {
const i = index();
const patch = fxPatchOf(str, has);
- if (!Object.keys(patch).length) throw new FxError("set changes something: --match, --at, --hold, --lead, --occurrence, --target; a zoom's --scale, --ease, --highlight; a caption's --text, --place; a slam's --text, --gap, --from-scale, --color, --outline, --outline-width, --place, --size, --face, --sfx, --volume, --whole/--per-glyph, --swell/--no-swell");
+ if (!Object.keys(patch).length) throw new FxError("set changes something: --match, --at, --hold, --lead, --occurrence, --target; a zoom's --scale, --ease, --highlight; a caption's --text, --place; a slam's --text, --gap, --from-scale, --color, --outline, --outline-width, --place, --size, --face, --sfx, --volume, --whole/--per-glyph, --swell/--no-swell, --bar, --bar-style");
const { result } = await write({ set: i, patch });
say(result.entry);
return 0;
diff --git a/umtool/lib/report/postSlurs.test.mjs b/umtool/lib/report/postSlurs.test.mjs
@@ -87,7 +87,7 @@ test("posts slurs on|off|level|visual|voice|add|except|remove: one writer, refus
await ok("level", "strong");
await ok("visual", "blackout");
await ok("voice", "skip");
- assert.match(await ok("add", "zorbo"), /z\*{4} is masked in this cut/);
+ assert.match(await ok("add", "zorbo"), / \*{5} is masked in this cut/);
await ok("except", F);
assert.deepEqual((await manifest(p)).render.posts.slurs, { level: "strong", visual: "blackout", voice: "skip", add: ["zorbo"], except: [F] });
const red = await projectRedaction(p.dir, await manifest(p));
diff --git a/umtool/lib/report/postSlursCli.mjs b/umtool/lib/report/postSlursCli.mjs
@@ -14,7 +14,7 @@
//
// Plain ESM: the CLI runs under bare node.
import { isNarrated, pickedTake, rootTakeOf } from "umtool-report-to-video/post-narration";
-import { SLURS_DEFAULTS, SLUR_LEVELS, SLUR_VISUALS, SLUR_VOICES, maskOfWord, slurReport, takeBleeps } from "umtool-report-to-video/post-slurs";
+import { SLURS_DEFAULTS, SLUR_LEVELS, SLUR_VISUALS, SLUR_VOICES, maskOfOwnWord, slurReport, takeBleeps } from "umtool-report-to-video/post-slurs";
import { cutSlurs } from "umtool-report-to-video/post-redact-files";
import { readManifest } from "../projects/report.mjs";
import { withEditNotes } from "./edit-guard.mjs";
@@ -89,7 +89,7 @@ export async function slursCommand(project, rest, { json = false, out = (s) => c
if (sub === "add" || sub === "except" || sub === "remove") {
if (!arg || !/^[A-Za-z][A-Za-z-]{1,39}$/.test(arg)) throw new SlursError(`posts slurs ${sub} takes a word (letters, 2–40)`);
const what = sub === "add" ? "masked in this cut" : sub === "except" ? "never masked in this cut" : "off the project's lists";
- return said({ [sub]: arg }, `${maskOfWord(arg.toLowerCase())} is ${what}`);
+ return said({ [sub]: arg }, `${maskOfOwnWord(arg)} is ${what}`);
}
if (sub !== "ls") throw new SlursError(`posts slurs: ls, on, off, level, visual, voice, add, except or remove (not ${sub})`);
const manifest = await readManifest(project.dir);
diff --git a/umtool/lib/report/postsCli.mjs b/umtool/lib/report/postsCli.mjs
@@ -160,7 +160,7 @@ export const POSTS_USAGE = [
" umtool posts scenes <project> [on|off] [--json] the MEDIA SCENES: neighbours with the same attachment",
].join("\n");
-const VALUED = new Set(["--set", "--attach", "--flag", "--author", "--id", "--crop", "--since", "--until", "--replies", "--order", "--limit", "--after", "--script", "--note", "--voice", "--engine", "--speed", "--pick", "--linger", "--derive", "--op", "--delete", "--match", "--target", "--occurrence", "--at", "--scale", "--hold", "--lead", "--ease", "--highlight", "--worker", "--without", "--drop-parts", "--text", "--place", "--rewind", "--zone", "--gap", "--from-scale", "--color", "--outline", "--outline-width", "--size", "--face", "--sfx", "--volume", "--tempo-for", "--tempo", "--parts", "--stretch", "--yell-gain", "--yell-style"]);
+const VALUED = new Set(["--set", "--attach", "--flag", "--author", "--id", "--crop", "--since", "--until", "--replies", "--order", "--limit", "--after", "--script", "--note", "--voice", "--engine", "--speed", "--pick", "--linger", "--derive", "--op", "--delete", "--match", "--target", "--occurrence", "--at", "--scale", "--hold", "--lead", "--ease", "--highlight", "--worker", "--without", "--drop-parts", "--text", "--place", "--rewind", "--zone", "--gap", "--from-scale", "--color", "--outline", "--outline-width", "--size", "--face", "--sfx", "--volume", "--bar", "--bar-style", "--tempo-for", "--tempo", "--parts", "--stretch", "--yell-gain", "--yell-style"]);
const SLUG_RE = /^[A-Za-z0-9._-]+$/;
const POST_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
diff --git a/umtool/report-to-video/post-render.mjs b/umtool/report-to-video/post-render.mjs
@@ -28,7 +28,7 @@ import { sceneEntry } from "./post-media-scene.mjs";
import { CAPTION_OUT, CAPTION_SLIDE, captionCss, captionInnerHtml, captionPlan, measureCaptionWords, mountCaptions, placeCaption, setCaptionState, slideDir } from "./post-caption.mjs";
import { clockCss, clockFace, clockFrameTimes, clockHtml, clockPlan, clockStateAt, measureClockPlace, mountClock, setClockState } from "./post-clock.mjs";
import { POST_PROGRESS_DRAW_V, measureProgressPlace, mountProgress, progressCss, progressFilters, progressHeight, progressPlan, setProgressState } from "./post-progress.mjs";
-import { SLAM_DUST, SLAM_FACE_STACK, SLAM_MOTION, mountSlams, setSlamState, slamCss, slamCoverErrors, slamHits, slamLayout, slamListAt, slamPlan, slamShakeExpr, slamSize, slamVars } from "./post-slam.mjs";
+import { SLAM_BAR, SLAM_DUST, SLAM_FACE_STACK, SLAM_MOTION, mountSlams, slamBarOf, setSlamState, slamCss, slamCoverErrors, slamHits, slamLayout, slamListAt, slamPlan, slamShakeExpr, slamSize, slamVars } from "./post-slam.mjs";
import { TRAILER_AUDIO, TRAILER_HIT_TIERS, trailerHitsGraph } from "./trailer-hits.mjs";
import { panelReadErrors } from "./post-thread.mjs";
import { applyJoinState, endMediaOf, joinClockOf } from "./post-join.mjs";
@@ -951,7 +951,9 @@ export async function shootSlams(browser, entry, { box, render, dir, fonts, pare
const line = geo ? geo.lines.reduce((a, l) => (l.height > a.height ? l : a), geo.lines[0]) : null;
const size = slamSize(p.fx, line, k);
const units = p.units.map((text, kk) => ({ i: p.i, k: kk, text, size, face: SLAM_FACE_STACK[p.fx.face] ?? SLAM_FACE_STACK.jp, vars: slamVars(p.fx, size) }));
- const arg = { css: slamCss(), units, dust: [...SLAM_DUST] };
+ // Its translation bar (with `bar`): the row lands on it, placed with it as one block.
+ const bar = slamBarOf(p, k);
+ const arg = { css: slamCss(), units, dust: [...SLAM_DUST], bars: bar ? [bar] : [] };
await page.evaluate(mountSlams, arg);
await page.evaluate(() => document.fonts.ready.then(() => true));
// Measured again once its face is in.
@@ -962,7 +964,7 @@ export async function shootSlams(browser, entry, { box, render, dir, fonts, pare
});
const errs = slamCoverErrors(entry.id, p.i, layout);
if (errs.length) throw new Error(errs.join("; "));
- const q = { ...p, centers: layout.centers };
+ const q = { ...p, centers: layout.centers, bar: layout.bar };
// Shot alone: the card hidden, the page clear.
await page.evaluate(() => {
const st = document.createElement("style");
@@ -1184,11 +1186,16 @@ export const POST_CLOCK_DRAW_V = 1;
* change to the shared generator rebuilds the items that play it.
*/
export const POST_SLAM_DRAW_V = 1;
+/** A slam WITH a bar draws at this version (and its key carries the bar's look): one without keeps POST_SLAM_DRAW_V. */
+export const POST_SLAM_BAR_DRAW_V = 2;
export function postFxKeyFields(entry, render, prev = null, { plan = null, layout = null } = {}) {
const out = {};
const fx = Array.isArray(entry?.fx) ? entry.fx : [];
if (fx.some((f) => f?.kind === "caption")) out.captionV = POST_CAPTION_DRAW_V;
- if (fx.some((f) => f?.kind === "slam")) out.slam = { v: POST_SLAM_DRAW_V, motion: SLAM_MOTION, hit: TRAILER_HIT_TIERS.title, audio: TRAILER_AUDIO };
+ if (fx.some((f) => f?.kind === "slam")) {
+ const barred = fx.some((f) => f?.kind === "slam" && typeof f.bar === "string");
+ out.slam = { v: barred ? POST_SLAM_BAR_DRAW_V : POST_SLAM_DRAW_V, motion: SLAM_MOTION, hit: TRAILER_HIT_TIERS.title, audio: TRAILER_AUDIO, ...(barred ? { bar: SLAM_BAR } : {}) };
+ }
const clk = clockPlan(entry, render, prev);
if (clk) Object.assign(out, { clockV: POST_CLOCK_DRAW_V, clock: clk });
// The progress bar (post-progress.mjs): its plan (the read's span, the parts' ticks, when it goes) and its drawing.
@@ -1409,7 +1416,7 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box
// The follow frames are in the segment now: a rebuild shoots them again (they are many, and the key decides).
if (cards.follow) await rm(path.dirname(cards.follow.list), { recursive: true, force: true });
// Through a rename: a record `--from` linked in (another take's) is replaced, never written through.
- await writeFile(`${record}.tmp`, JSON.stringify({ version: 1, id: entry.id, key, layout: layout.mode, total: plan.total, steps: plan.steps.length, ...(zooms.length ? { zooms: zooms.map((z) => ({ i: z.i, at: z.t, source: z.source, span: z.span, region: z.region, word: z.word })) } : {}), ...(cards.captions?.length ? { captions: cards.captions.map((c) => ({ i: c.i, at: c.t, source: c.source, span: c.span, place: c.placed.place, rel: c.placed.rel, box: { x: c.placed.x, y: c.placed.y, width: c.placed.width, height: c.placed.height }, word: c.placed.word, covers: c.placed.covers, leader: c.placed.leader, ...(c.cutByPan ? { cutByPan: c.cutByPan } : {}) })) } : {}), ...(cards.slams?.length ? { slams: cards.slams.map((sl) => ({ i: sl.i, text: sl.fx.text, at: sl.t, end: sl.end, source: sl.source, landings: sl.landings, span: { t0: sl.span.t0, t2: sl.span.t2, t3: sl.span.t3 }, where: sl.layout.where, box: { x: sl.layout.x, y: sl.layout.y, width: sl.layout.width, height: sl.layout.height }, size: sl.size, covers: sl.layout.covers, sfx: sl.fx.sfx, shots: sl.shots })) } : {}), ...(narration ? { narration: { take: take.file, ...plan.narration, gainDb: narration.gainDb, measured: narration.lufs, ...(bleeps ? { slurs: { mode: bleeps.mode, spans: bleeps.spans } } : {}) } } : {}), ...(cards.follow ? { follow: { blocks: plan.follow.blocks.length, shots: cards.follow.shots, frames: cards.follow.frames, pan: cards.follow.path.segments.length, max: cards.follow.path.max } } : {}), ...(Number.isFinite(cards.joinAnchor) ? { joinAnchor: cards.joinAnchor } : {}) }, null, 2) + "\n", "utf8");
+ await writeFile(`${record}.tmp`, JSON.stringify({ version: 1, id: entry.id, key, layout: layout.mode, total: plan.total, steps: plan.steps.length, ...(zooms.length ? { zooms: zooms.map((z) => ({ i: z.i, at: z.t, source: z.source, span: z.span, region: z.region, word: z.word })) } : {}), ...(cards.captions?.length ? { captions: cards.captions.map((c) => ({ i: c.i, at: c.t, source: c.source, span: c.span, place: c.placed.place, rel: c.placed.rel, box: { x: c.placed.x, y: c.placed.y, width: c.placed.width, height: c.placed.height }, word: c.placed.word, covers: c.placed.covers, leader: c.placed.leader, ...(c.cutByPan ? { cutByPan: c.cutByPan } : {}) })) } : {}), ...(cards.slams?.length ? { slams: cards.slams.map((sl) => ({ i: sl.i, text: sl.fx.text, at: sl.t, end: sl.end, source: sl.source, landings: sl.landings, span: { t0: sl.span.t0, t2: sl.span.t2, t3: sl.span.t3 }, where: sl.layout.where, box: { x: sl.layout.x, y: sl.layout.y, width: sl.layout.width, height: sl.layout.height }, ...(sl.layout.bar ? { bar: { text: sl.fx.bar, style: sl.fx.barStyle, x: sl.layout.bar.x, y: sl.layout.bar.y, width: sl.layout.bar.width, height: sl.layout.bar.height } } : {}), size: sl.size, covers: sl.layout.covers, sfx: sl.fx.sfx, shots: sl.shots })) } : {}), ...(narration ? { narration: { take: take.file, ...plan.narration, gainDb: narration.gainDb, measured: narration.lufs, ...(bleeps ? { slurs: { mode: bleeps.mode, spans: bleeps.spans } } : {}) } } : {}), ...(cards.follow ? { follow: { blocks: plan.follow.blocks.length, shots: cards.follow.shots, frames: cards.follow.frames, pan: cards.follow.path.segments.length, max: cards.follow.path.max } } : {}), ...(Number.isFinite(cards.joinAnchor) ? { joinAnchor: cards.joinAnchor } : {}) }, null, 2) + "\n", "utf8");
await rename(`${record}.tmp`, record);
if (pool) await poolPut(pool, "post", key, { "seg.mp4": seg, "post.json": record });
emit("note", {
diff --git a/umtool/report-to-video/post-slam.mjs b/umtool/report-to-video/post-slam.mjs
@@ -19,7 +19,9 @@
// place?: "over-match" | "center", // above the matched words (default), or the card's middle
// size?: px, // the glyphs' size at rest, px at 1080 (absent: by the word's line)
// face?: "jp" | "sc" | "tc" | "kr", // the CJK face (Noto Sans CJK <face> Black)
-// sfx?: "trailer-hit" | "off", volume?: x, swell?: true }]
+// sfx?: "trailer-hit" | "off", volume?: x, swell?: true,
+// bar?: "fudōshin — \"immovable mind\"", // a translation bar the glyphs land ON (≤ SLAM_BAR_MAX)
+// barStyle?: "dark" | "gold" | "plain" }] // its look (default dark: the card's ground, a thin gold rule)
//
// WHEN: each glyph LANDS on a hit. Absent `at` and `gap`, the hits are spread
// evenly over the matched words' SPOKEN span in the picked take's word timings
@@ -47,6 +49,15 @@
// the words read at each hit. A row that would is placed below the line; when
// neither place is clear the build refuses, in its own words.
//
+// THE BAR (operator, 4 Nov: "have the characters appear above a bar with the
+// translation rather than have the tooltip pop up after"): with `bar`, the
+// glyph row lands ON a bar carrying the translation, centred on it -- the bar
+// rises in as the first glyph lands, holds through the hold and fades with
+// the glyphs. The row and the bar are placed as ONE unit by the same rules
+// (above the words' line; below it when that leaves the frame or covers a
+// word being read). The caption module is untouched: an item may still carry
+// one, and it waits for the slam as before.
+//
// THE SOUND: one trailer hit per glyph at its landing (trailer-hits.mjs, the
// teaser's generator, title tier), the tail's swell after the last with
// `swell`, mixed into the segment's audio without ducking the read.
@@ -66,7 +77,7 @@ export const SLAM_FACES = Object.freeze(["jp", "sc", "tc", "kr"]);
export const SLAM_SFX = Object.freeze(["trailer-hit", "off"]);
export const SLAM_DEFAULTS = Object.freeze({
target: "post", occurrence: 1, whole: false, hold: 1.6, fromScale: 3.5, color: "#f5c542", outline: "#000000",
- place: "over-match", face: "jp", sfx: "trailer-hit", volume: 1, swell: false,
+ place: "over-match", face: "jp", sfx: "trailer-hit", volume: 1, swell: false, barStyle: "dark",
});
export const SLAM_LIMITS = Object.freeze({
at: [0, 600], gap: [0.12, 2], hold: [0.3, 4], fromScale: [1.5, 8], outlineWidth: [0, 30], size: [40, 320], volume: [0, 3], occurrence: [1, 99],
@@ -96,7 +107,17 @@ export const SLAM_FACE_STACK = Object.freeze({
kr: "'Noto Sans CJK KR', 'Noto Sans CJK JP', 'Source Han Sans KR', sans-serif",
});
-const KEYS = new Set(["kind", "text", "target", "match", "occurrence", "at", "gap", "whole", "hold", "fromScale", "color", "outline", "outlineWidth", "place", "size", "face", "sfx", "volume", "swell"]);
+const KEYS = new Set(["kind", "text", "target", "match", "occurrence", "at", "gap", "whole", "hold", "fromScale", "color", "outline", "outlineWidth", "place", "size", "face", "sfx", "volume", "swell", "bar", "barStyle"]);
+export const SLAM_BAR_STYLES = Object.freeze(["dark", "gold", "plain"]);
+export const SLAM_BAR_MAX = 140;
+/**
+ * THE BAR's motion and size: it rises `rise` × its height into place over `in`
+ * seconds from `lead` before the first landing; its text `font` px at 1080, at
+ * most `maxWidth` px wide (it wraps), the glyphs overlapping its top edge by
+ * `overlap` × their size (0: their em box stands on its rule -- the ink and the
+ * outline already reach it, so a bigger overlap hides its words).
+ */
+export const SLAM_BAR = Object.freeze({ lead: 0.04, in: 0.28, rise: 0.6, font: 30, maxWidth: 820, overlap: 0 });
const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
const fin = (v) => typeof v === "number" && Number.isFinite(v);
const numIn = (v, [lo, hi]) => fin(v) && v >= lo && v <= hi;
@@ -107,7 +128,7 @@ const MATCH_MAX = 120;
/**
* One slam with every default filled in.
* @param {Record<string, any> | null | undefined} fx
- * @returns {{ kind?: string, text: string, target: string, match: string, occurrence: number, at?: number, gap?: number, whole: boolean, hold: number, fromScale: number, color: string, outline: string, outlineWidth?: number, place: string, size?: number, face: string, sfx: string, volume: number, swell: boolean }}
+ * @returns {{ kind?: string, text: string, target: string, match: string, occurrence: number, at?: number, gap?: number, whole: boolean, hold: number, fromScale: number, color: string, outline: string, outlineWidth?: number, place: string, size?: number, face: string, sfx: string, volume: number, swell: boolean, bar?: string, barStyle: string }}
*/
export const resolveSlam = (fx) => ({ ...SLAM_DEFAULTS, ...Object.fromEntries(Object.entries(fx ?? {}).filter(([, v]) => v !== undefined && v !== null)) });
@@ -153,6 +174,10 @@ export function slamErrors(e, fx, fw) {
if (fx.face !== undefined && !SLAM_FACES.includes(fx.face)) errors.push(`${fw}.face must be one of ${SLAM_FACES.join(", ")}`);
if (fx.sfx !== undefined && !SLAM_SFX.includes(fx.sfx)) errors.push(`${fw}.sfx must be one of ${SLAM_SFX.join(", ")}`);
for (const k of ["whole", "swell"]) if (fx[k] !== undefined && typeof fx[k] !== "boolean") errors.push(`${fw}.${k} must be true or false`);
+ if (fx.bar !== undefined && !(typeof fx.bar === "string" && fx.bar.trim())) errors.push(`${fw}.bar must be the translation the glyphs land on (or absent)`);
+ else if (typeof fx.bar === "string" && fx.bar.length > SLAM_BAR_MAX) errors.push(`${fw}.bar is longer than ${SLAM_BAR_MAX} characters (a bar is a line, not a paragraph)`);
+ if (fx.barStyle !== undefined && !SLAM_BAR_STYLES.includes(fx.barStyle)) errors.push(`${fw}.barStyle must be one of ${SLAM_BAR_STYLES.join(", ")}`);
+ if (fx.barStyle !== undefined && fx.bar === undefined) errors.push(`${fw}.barStyle: the slam has no bar (set bar)`);
return errors;
}
@@ -292,6 +317,18 @@ export function slamStateAt(p, s) {
return { units };
}
+/**
+ * The bar's look at `s` (null when the slam has none, or before it comes in):
+ * `{ opacity, rise }` -- `rise` the share of its height it still has to come up.
+ * @param {{ t0: number, t2: number, t3: number, landings: number[] }} span
+ */
+export function slamBarAt(span, s) {
+ const t = span.landings[0] - SLAM_BAR.lead;
+ if (s < t || s >= span.t3) return null;
+ const e = easeOut2((s - t) / SLAM_BAR.in);
+ return { opacity: r3(e * slamFadeAt(span, s)), rise: r3((1 - e) * SLAM_BAR.rise) };
+}
+
/** The frame's punch at `s` (unit amplitudes: × SLAM_MOTION.shake.amp × k px): `{ x, y }`. */
export function slamShakeAt(landings, s) {
const { tau, span, hz } = SLAM_MOTION.shake;
@@ -423,11 +460,21 @@ export function slamSize(fx, word, k = 1) {
* height, centers: [{ x, y }], where: "above"|"below"|"center"|"clamped",
* covers: n (the boxes of `obstacles` it lies over: the gag), blocked: bool
* (it covers a protected box) }`.
- * @param {{ word?: Rect | null, card: Rect, bounds: Rect, units: Array<{ width: number, height: number }>, place?: string, gap?: number, protect?: Rect[], obstacles?: Rect[] }} o
+ * With a BAR (a box among `units` whose `k` is -1): the row sits ON it --
+ * centred, overlapping its top by SLAM_BAR.overlap × the glyphs' height -- and
+ * the row and the bar are placed as one block; `bar` is then its box and
+ * centre (null without one).
+ * @param {{ word?: Rect | null, card: Rect, bounds: Rect, units: Array<{ width: number, height: number, k?: number }>, place?: string, gap?: number, protect?: Rect[], obstacles?: Rect[] }} o
*/
-export function slamLayout({ word = null, card, bounds, units, place = "over-match", gap = 8, protect = [], obstacles = [] }) {
- const W = units.reduce((a, u) => a + u.width, 0);
- const H = Math.max(...units.map((u) => u.height));
+export function slamLayout({ word = null, card, bounds, units: all, place = "over-match", gap = 8, protect = [], obstacles = [] }) {
+ const barBox = all.find((u) => u.k === -1) ?? null;
+ const units = all.filter((u) => u.k !== -1);
+ const RW = units.reduce((a, u) => a + u.width, 0);
+ const RH = Math.max(...units.map((u) => u.height));
+ // The block: the row, and under it the bar it lands on (centred on each other).
+ const over = barBox ? Math.round(RH * SLAM_BAR.overlap) : 0;
+ const W = barBox ? Math.max(RW, barBox.width) : RW;
+ const H = barBox ? RH - over + barBox.height : RH;
const clampX = (x) => Math.min(bounds.x + bounds.width - W, Math.max(bounds.x, x));
const clampY = (y) => Math.min(bounds.y + bounds.height - H, Math.max(bounds.y, y));
const tries = [];
@@ -445,13 +492,16 @@ export function slamLayout({ word = null, card, bounds, units, place = "over-mat
return { ...t, blocked: protect.some((p) => hits(r, p)), covers: obstacles.filter((o) => hits(r, o)).length };
});
const pick = judged.find((t) => !t.blocked) ?? judged[0];
- let cx = pick.x;
+ let cx = pick.x + (W - RW) / 2;
const centers = units.map((u) => {
- const c = { x: Math.round(cx + u.width / 2), y: Math.round(pick.y + H / 2) };
+ const c = { x: Math.round(cx + u.width / 2), y: Math.round(pick.y + RH / 2) };
cx += u.width;
return c;
});
- return { x: Math.round(pick.x), y: Math.round(pick.y), width: Math.round(W), height: Math.round(H), centers, where: pick.where, covers: pick.covers, blocked: pick.blocked };
+ const bar = barBox
+ ? { x: Math.round(pick.x + (W - barBox.width) / 2), y: Math.round(pick.y + RH - over), width: Math.round(barBox.width), height: Math.round(barBox.height), cx: Math.round(pick.x + W / 2), cy: Math.round(pick.y + RH - over + barBox.height / 2) }
+ : null;
+ return { x: Math.round(pick.x), y: Math.round(pick.y), width: Math.round(W), height: Math.round(H), centers, bar, where: pick.where, covers: pick.covers, blocked: pick.blocked };
}
/**
@@ -484,6 +534,17 @@ export function slamCss() {
.pslam-ring { position: absolute; left: 50%; top: 50%; width: 1.5em; height: 1.5em; margin: -0.75em 0 0 -0.75em; border-radius: 50%; opacity: 0;
border: 0.05em solid var(--pslam-hi); box-shadow: 0 0 0.12em var(--pslam-gold); }
.pslam-dust { position: absolute; left: 50%; top: 62%; width: 0; height: 0; }
+.pslam-bar { position: absolute; left: 0; top: 0; opacity: 0; box-sizing: border-box; text-align: center; line-height: 1.3; font-synthesis: none;
+ font-family: 'PostSans', 'Fira Sans', 'Noto Sans', 'Noto Sans CJK JP', sans-serif; will-change: transform, opacity; overflow-wrap: anywhere; }
+.pslam-bar b { font-family: 'PostSansBold', 'Fira Sans', 'Noto Sans', 'Noto Sans CJK JP', sans-serif; font-weight: 700; }
+.pslam-bar { text-wrap: balance; }
+.pslam-bar[data-style="dark"] { background: rgba(14,12,9,0.95); color: #f6f1e6; border-top: 2px solid var(--pslam-gold); border-bottom: 1px solid rgba(245,197,66,0.35);
+ box-shadow: 0 0.3em 1em rgba(0,0,0,0.5); }
+.pslam-bar[data-style="dark"] b { color: var(--pslam-hi); }
+.pslam-bar[data-style="dark"] .pslam-bar-rest { color: #d9cfbd; }
+.pslam-bar[data-style="gold"] { background: linear-gradient(180deg, var(--pslam-hi), var(--pslam-gold)); color: #1a1206; border-top: 2px solid #fff6d2; border-bottom: 2px solid var(--pslam-lo); box-shadow: 0 0.3em 1em rgba(0,0,0,0.55); }
+.pslam-bar[data-style="plain"] { background: transparent; color: #fffaf0; text-shadow: 0 0.06em 0.2em rgba(0,0,0,0.95), 0 0 0.06em #000; }
+.pslam-bar[data-style="plain"] b { color: var(--pslam-hi); }
.pslam-dust i { position: absolute; left: 0; top: 0; width: 0.07em; height: 0.07em; margin: -0.035em; border-radius: 50%; background: var(--pslam-hi); opacity: 0; }
`;
}
@@ -498,6 +559,20 @@ export function slamVars(fx, size) {
};
}
+/** The bar's inner HTML: its text, the part before " — " bold (as a caption's). */
+export function slamBarHtml(text) {
+ const esc = (v) => String(v).replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c] || c);
+ const t = String(text ?? "");
+ const cut = t.indexOf(" — ");
+ return cut > 0 ? `<b>${esc(t.slice(0, cut))}</b><span class="pslam-bar-rest"> — ${esc(t.slice(cut + 3))}</span>` : esc(t);
+}
+
+/** A slam's bar as mountSlams takes it (null without one): its HTML, style, colours and size at `k` (px per 1080). */
+export function slamBarOf(p, k = 1) {
+ if (typeof p?.fx?.bar !== "string" || !p.fx.bar.trim()) return null;
+ return { i: p.i, html: slamBarHtml(p.fx.bar), style: p.fx.barStyle ?? "dark", font: Math.round(SLAM_BAR.font * k), maxWidth: Math.round(SLAM_BAR.maxWidth * k), padX: Math.round(26 * k), padY: Math.round(9 * k), vars: slamVars(p.fx, 100) };
+}
+
/** The dust's directions (degrees): a fan up and out from the foot of the glyph. */
export const SLAM_DUST = Object.freeze([-170, -150, -128, -105, -80, -55, -32, -10, 200, 225]);
@@ -505,14 +580,15 @@ export const SLAM_DUST = Object.freeze([-170, -150, -128, -105, -80, -55, -32, -
* Mount the slams' units over the card page: `{ css, units: [{ i, k, text,
* size, face, vars }] }`. Returns each one's box at rest `[{ i, k, width,
* height }]` (its glyph's em box: line height 1).
- * @param {{ css?: string, units?: Array<{ i: number, k: number, text: string, size: number, face: string, vars: Record<string, string> }>, dust?: number[] } | null} arg
+ * `bars` (slamBarOf's): each slam's translation bar, measured too (its `k` is -1).
+ * @param {{ css?: string, units?: Array<{ i: number, k: number, text: string, size: number, face: string, vars: Record<string, string> }>, dust?: number[], bars?: Array<{ i: number, html: string, style: string, font: number, maxWidth: number, padX: number, padY: number, vars: Record<string, string> }> } | null} arg
* @param {Document} [doc]
* @returns {Array<{ i: number, k: number, width: number, height: number }>}
*/
export function mountSlams(arg, doc = document) {
doc.querySelectorAll("[data-post-fx-slams], style[data-post-fx-slams-css]").forEach((el) => el.remove());
const units = (arg && arg.units) || [];
- if (!units.length) return [];
+ if (!units.length && !(arg && arg.bars && arg.bars.length)) return [];
const style = doc.createElement("style");
style.setAttribute("data-post-fx-slams-css", "");
style.textContent = arg.css || "";
@@ -521,10 +597,29 @@ export function mountSlams(arg, doc = document) {
layer.setAttribute("data-post-fx-slams", "");
doc.body.appendChild(layer);
const dust = (arg && arg.dust) || [];
+ const bars = (arg && arg.bars) || [];
+ const barBoxes = bars.map((b) => {
+ const el = doc.createElement("div");
+ el.className = "pslam-bar";
+ el.setAttribute("data-post-fx-slam", `${b.i}:-1`);
+ el.setAttribute("data-style", b.style);
+ for (const [k, v] of Object.entries(b.vars || {})) el.style.setProperty(k, v);
+ el.style.fontSize = `${b.font}px`;
+ el.style.padding = `${b.padY}px ${b.padX}px`;
+ el.style.maxWidth = `${b.maxWidth}px`;
+ el.style.width = "max-content";
+ el.innerHTML = b.html;
+ layer.appendChild(el);
+ const r = el.getBoundingClientRect();
+ el.dataset.rw = String(r.width);
+ el.dataset.rh = String(r.height);
+ return { i: b.i, k: -1, width: Math.ceil(r.width), height: Math.ceil(r.height) };
+ });
const esc = (s) => String(s).replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c] || c);
return units.map((u) => {
const el = doc.createElement("div");
el.className = "pslam";
+ el.style.zIndex = "2";
el.setAttribute("data-post-fx-slam", `${u.i}:${u.k}`);
el.style.fontSize = `${u.size}px`;
el.style.fontFamily = u.face;
@@ -540,7 +635,7 @@ export function mountSlams(arg, doc = document) {
el.dataset.rw = String(b.width);
el.dataset.rh = String(b.height);
return { i: u.i, k: u.k, width: Math.ceil(b.width), height: Math.ceil(b.height) };
- });
+ }).concat(barBoxes);
}
/**
@@ -557,6 +652,18 @@ export function setSlamState(arg, doc = document) {
if (doc.body) doc.body.style.translate = shake && (shake.x || shake.y) ? `${Math.round(shake.x * 10) / 10}px ${Math.round(shake.y * 10) / 10}px` : "";
const layer = doc.querySelector("[data-post-fx-slams]");
if (!layer) return;
+ for (const el of Array.from(layer.querySelectorAll(".pslam-bar"))) {
+ const id = el.getAttribute("data-post-fx-slam") || "";
+ const st = list.find((x) => `${x.i}:${x.k}` === id);
+ if (!st) {
+ el.style.opacity = "0";
+ continue;
+ }
+ const w = Number(el.dataset.rw || 0);
+ const h = Number(el.dataset.rh || 0);
+ el.style.opacity = String(st.opacity);
+ el.style.transform = `translate(${Math.round((st.x - w / 2) * 10) / 10}px, ${Math.round((st.y - h / 2 + (st.rise || 0) * h) * 10) / 10}px)`;
+ }
for (const el of Array.from(layer.querySelectorAll(".pslam"))) {
const id = el.getAttribute("data-post-fx-slam") || "";
const st = list.find((x) => `${x.i}:${x.k}` === id);
@@ -611,5 +718,9 @@ export function setSlamState(arg, doc = document) {
export function slamListAt(p, s, dx = 0, dy = 0) {
const st = slamStateAt({ span: p.span, fromScale: p.fx.fromScale }, s);
if (!st) return [];
- return st.units.map((u) => ({ i: p.i, ...u, x: p.centers[u.k].x + dx, y: p.centers[u.k].y + dy }));
+ const out = st.units.map((u) => ({ i: p.i, ...u, x: p.centers[u.k].x + dx, y: p.centers[u.k].y + dy }));
+ // Its bar (slamLayout's `bar`), under the glyphs: drawn first.
+ const b = p.bar ? slamBarAt(p.span, s) : null;
+ if (b) out.unshift({ i: p.i, k: -1, x: p.bar.cx + dx, y: p.bar.cy + dy, opacity: b.opacity, rise: b.rise });
+ return out;
}
diff --git a/umtool/report-to-video/post-slam.test.mjs b/umtool/report-to-video/post-slam.test.mjs
@@ -6,7 +6,7 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import {
- SLAM_GAP, SLAM_MOTION, slamHits, slamLandings, slamLayout, slamPlan, slamShakeAt, slamShakeExpr, slamSpan, slamStateAt, slamTimes, slamUnitAt, slamUnits,
+ SLAM_BAR, SLAM_GAP, SLAM_MOTION, slamBarAt, slamBarHtml, slamHits, slamLandings, slamLayout, slamPlan, slamShakeAt, slamShakeExpr, slamSpan, slamStateAt, slamTimes, slamUnitAt, slamUnits,
} from "./post-slam.mjs";
import { TEASER_MOTION } from "./deck.mjs";
import { TRAILER_HIT_TIERS, trailerHitsGraph } from "./trailer-hits.mjs";
@@ -196,3 +196,44 @@ test("THE ENCODE (postSegmentArgs): the slam's frames laid over everything while
assert.match(fc, /\[apre\]\[sla\]amix=inputs=2:normalize=0:duration=first,alimiter=limit=0\.95/);
assert.ok(a.includes("/c/slam-1/frames.ffconcat"));
});
+
+test("THE BAR (operator, 4 Nov: \"have the characters appear above a bar with the translation\"): validated; the row lands ON it, the two placed as one block above the words; it rises in at the first hit and fades with the glyphs", () => {
+ assert.deepEqual(validatePostFx(base({ fx: [slam({ bar: 'fudōshin — "immovable mind"', barStyle: "gold" })] })), []);
+ const errs = validatePostFx(base({ fx: [slam({ bar: "x".repeat(141), barStyle: "neon" })] }));
+ assert.ok(errs.some((e) => /\.bar is longer than 140 characters/.test(e)), errs.join("\n"));
+ assert.ok(errs.some((e) => /\.barStyle must be one of dark, gold, plain/.test(e)));
+ assert.ok(validatePostFx(base({ fx: [slam({ barStyle: "gold" })] })).some((e) => /the slam has no bar/.test(e)));
+ assert.equal(slamBarHtml('fudōshin — "immovable mind"'), '<b>fudōshin</b><span class="pslam-bar-rest"> — "immovable mind"</span>');
+ const word = { x: 400, y: 400, width: 200, height: 40 };
+ const card = { x: 100, y: 100, width: 900, height: 800 };
+ const bounds = { x: 12, y: 12, width: 1896, height: 1056 };
+ const units = [{ width: 120, height: 120, k: 0 }, { width: 120, height: 120, k: 1 }, { width: 120, height: 120, k: 2 }, { width: 500, height: 50, k: -1 }];
+ const lay = slamLayout({ word, card, bounds, units, gap: 6, protect: [word] });
+ assert.equal(lay.where, "above");
+ // The block: 500 wide (the bar), 120 + 50 tall, its foot `gap` above the word; the row centred on the bar, standing on it.
+ assert.deepEqual([lay.x, lay.y, lay.width, lay.height], [250, 224, 500, 170]);
+ assert.deepEqual(lay.bar, { x: 250, y: 344, width: 500, height: 50, cx: 500, cy: 369 });
+ assert.deepEqual(lay.centers.map((c) => c.x), [380, 500, 620]);
+ assert.equal(lay.centers[0].y + 60, lay.bar.y - Math.round(120 * SLAM_BAR.overlap));
+ // Too tall above (the word near the frame's top): the block goes below.
+ assert.equal(slamLayout({ word: { ...word, y: 150 }, card, bounds, units, gap: 6, protect: [{ ...word, y: 150 }] }).where, "below");
+ // Without a bar: no bar box.
+ assert.equal(slamLayout({ word, card, bounds, units: units.slice(0, 3), gap: 6 }).bar, null);
+ const sp = slamSpan(slam(), [4, 4.5, 5]);
+ assert.equal(slamBarAt(sp, 3.9), null);
+ const b0 = slamBarAt(sp, 4 - SLAM_BAR.lead);
+ assert.deepEqual(b0, { opacity: 0, rise: SLAM_BAR.rise });
+ assert.deepEqual(slamBarAt(sp, 5), { opacity: 1, rise: 0 });
+ assert.ok(slamBarAt(sp, 6.8).opacity < 0.5);
+ assert.equal(slamBarAt(sp, 7), null);
+});
+
+test("THE SEGMENT KEY with a bar: a slam with one draws at the bar's version and carries its look; one without keeps its key", async () => {
+ const { postFxKeyFields, POST_SLAM_DRAW_V, POST_SLAM_BAR_DRAW_V } = await import("./post-render.mjs");
+ const plain = postFxKeyFields(base({ fx: [slam()] }), {});
+ assert.equal(plain.slam.v, POST_SLAM_DRAW_V);
+ assert.equal("bar" in plain.slam, false);
+ const barred = postFxKeyFields(base({ fx: [slam({ bar: "fudōshin" })] }), {});
+ assert.equal(barred.slam.v, POST_SLAM_BAR_DRAW_V);
+ assert.deepEqual(barred.slam.bar, SLAM_BAR);
+});
diff --git a/umtool/report-to-video/post-slurs.mjs b/umtool/report-to-video/post-slurs.mjs
@@ -85,7 +85,7 @@ function addedEntry(a) {
const x = typeof a === "string" ? { word: a } : a;
const word = lc(x?.word);
const forms = Array.isArray(x?.forms) && x.forms.length ? x.forms.map(lc) : [word];
- return { id: `add:${word}`, level: "strong", word, forms: forms.includes(word) ? forms : [word, ...forms], ...(x?.mask ? { mask: x.mask } : {}), say: str(x?.say).trim() || "slur", added: true };
+ return { id: `add:${word}`, level: "strong", word, forms: forms.includes(word) ? forms : [word, ...forms], mask: x?.mask ? x.mask : maskOfOwnWord(word), say: str(x?.say).trim() || "slur", added: true };
}
/**
@@ -212,6 +212,8 @@ export function slurMatches(text, s) {
export const slurEntryOf = (s, id) => (Array.isArray(s?.entries) ? s.entries.find((e) => e.id === id) ?? null : null);
/** A word's default masked form: its first letter, an asterisk for each other. */
+/** A project's own word (a name kept off the card, most often) is masked whole: no first letter to spell it. */
+export const maskOfOwnWord = (word) => "*".repeat(Math.max(1, str(word).length));
export const maskOfWord = (word) => (str(word) ? `${str(word)[0]}${"*".repeat(Math.max(1, str(word).length - 1))}` : "*");
/** The masked form a hit is drawn as: the slur's mask, its first letter in the case the text wrote it. */
diff --git a/umtool/report-to-video/post-slurs.test.mjs b/umtool/report-to-video/post-slurs.test.mjs
@@ -70,6 +70,8 @@ test("the level, the project's additions and exceptions", () => {
assert.equal(slurMatches(F, strong).length, 1);
const own = resolveSlurs({ add: ["zorbo", { word: "blerg", forms: ["blergs"], mask: "b***", say: "b-word" }], except: [FS, "r-word"] }, LIST);
assert.equal(slurMatches("a zorbo and two blergs", own).length, 2);
+ assert.equal(own.entries.find((e) => e.word === "zorbo").mask, "*****", "a project's own word is masked whole -- no first letter");
+ assert.equal(own.entries.find((e) => e.word === "blerg").mask, "b***", "its own mask, when it gives one");
assert.equal(slurMatches(FS, own).length, 0, "an excepted form");
assert.equal(slurMatches(F, own).length, 1, "the rest of its slur");
assert.equal(slurMatches(R, own).length, 0, "an excepted slur, by its id");