@softure-ai/marketing-kit 0.33.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/NOTICE +6 -0
- package/README.md +39 -0
- package/dist/config/schema.d.ts +8 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +1 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/footage/camera.d.ts +67 -0
- package/dist/footage/camera.d.ts.map +1 -0
- package/dist/footage/camera.js +89 -0
- package/dist/footage/camera.js.map +1 -0
- package/dist/footage/compose.d.ts +7 -1
- package/dist/footage/compose.d.ts.map +1 -1
- package/dist/footage/compose.js +45 -10
- package/dist/footage/compose.js.map +1 -1
- package/dist/footage/draft-overlays.d.ts +6 -0
- package/dist/footage/draft-overlays.d.ts.map +1 -1
- package/dist/footage/draft-overlays.js +194 -9
- package/dist/footage/draft-overlays.js.map +1 -1
- package/dist/footage/draft.d.ts +21 -2
- package/dist/footage/draft.d.ts.map +1 -1
- package/dist/footage/draft.js +70 -31
- package/dist/footage/draft.js.map +1 -1
- package/dist/footage/drawn-transitions.d.ts +63 -0
- package/dist/footage/drawn-transitions.d.ts.map +1 -0
- package/dist/footage/drawn-transitions.js +177 -0
- package/dist/footage/drawn-transitions.js.map +1 -0
- package/dist/footage/edl.d.ts +39 -0
- package/dist/footage/edl.d.ts.map +1 -1
- package/dist/footage/edl.js +48 -1
- package/dist/footage/edl.js.map +1 -1
- package/dist/footage/film.d.ts +4 -3
- package/dist/footage/film.d.ts.map +1 -1
- package/dist/footage/film.js +3 -2
- package/dist/footage/film.js.map +1 -1
- package/dist/footage/hand-font.d.ts +16 -0
- package/dist/footage/hand-font.d.ts.map +1 -0
- package/dist/footage/hand-font.js +43 -0
- package/dist/footage/hand-font.js.map +1 -0
- package/dist/footage/overlay-html.d.ts +1 -0
- package/dist/footage/overlay-html.d.ts.map +1 -1
- package/dist/footage/overlay-html.js +138 -9
- package/dist/footage/overlay-html.js.map +1 -1
- package/dist/footage/overlay-motion.d.ts +35 -0
- package/dist/footage/overlay-motion.d.ts.map +1 -1
- package/dist/footage/overlay-motion.js +45 -0
- package/dist/footage/overlay-motion.js.map +1 -1
- package/dist/footage/overlay-schema.d.ts +57 -8
- package/dist/footage/overlay-schema.d.ts.map +1 -1
- package/dist/footage/overlay-schema.js +87 -21
- package/dist/footage/overlay-schema.js.map +1 -1
- package/dist/footage/overlays.d.ts +127 -1
- package/dist/footage/overlays.d.ts.map +1 -1
- package/dist/footage/overlays.js +277 -12
- package/dist/footage/overlays.js.map +1 -1
- package/dist/footage/picture.d.ts +8 -2
- package/dist/footage/picture.d.ts.map +1 -1
- package/dist/footage/picture.js +41 -15
- package/dist/footage/picture.js.map +1 -1
- package/dist/footage/pipeline.d.ts.map +1 -1
- package/dist/footage/pipeline.js +7 -1
- package/dist/footage/pipeline.js.map +1 -1
- package/dist/footage/tools.d.ts +1 -1
- package/dist/footage/tools.d.ts.map +1 -1
- package/dist/footage/tools.js +1 -1
- package/dist/footage/tools.js.map +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/fonts/Caveat-SemiBold-Latin.ttf +0 -0
- package/fonts/LICENSE-Caveat.txt +93 -0
- package/fonts/README.md +14 -0
- package/package.json +1 -1
- package/schema/edl.schema.json +108 -13
- package/schema/marketing.schema.json +10 -2
- package/src/config/schema.ts +1 -1
- package/src/footage/camera.ts +129 -0
- package/src/footage/compose.ts +42 -11
- package/src/footage/draft-overlays.ts +223 -7
- package/src/footage/draft.ts +83 -32
- package/src/footage/drawn-transitions.ts +214 -0
- package/src/footage/edl.ts +45 -1
- package/src/footage/film.ts +3 -2
- package/src/footage/hand-font.ts +47 -0
- package/src/footage/overlay-html.ts +145 -8
- package/src/footage/overlay-motion.ts +49 -0
- package/src/footage/overlay-schema.ts +100 -23
- package/src/footage/overlays.ts +332 -15
- package/src/footage/picture.ts +48 -17
- package/src/footage/pipeline.ts +7 -1
- package/src/footage/tools.ts +1 -1
- package/src/index.ts +56 -0
|
@@ -2,7 +2,15 @@ import type { BrandColors } from "../config/colors.js";
|
|
|
2
2
|
import { escapeHtml } from "../compose/html.js";
|
|
3
3
|
import { getCornerRadiusCss, getStyleBorderCss, getStyleShadowCss, type BrandStyle } from "./brand-style.js";
|
|
4
4
|
import type { OverlayEntrance } from "./overlay-schema.js";
|
|
5
|
+
import { HAND_FONT } from "./hand-font.js";
|
|
5
6
|
import {
|
|
7
|
+
DROP_FROM_EM,
|
|
8
|
+
DROP_LETTER_GAP,
|
|
9
|
+
DROP_LETTER_SECONDS,
|
|
10
|
+
NOTE_GROW_FROM_SCALE,
|
|
11
|
+
NOTE_GROW_SECONDS,
|
|
12
|
+
NOTE_TICK_SECONDS,
|
|
13
|
+
getDropLetterTurns,
|
|
6
14
|
PIN_DROP_SECONDS,
|
|
7
15
|
PIN_DROP_SHARE,
|
|
8
16
|
PIN_TITLE_LEAD,
|
|
@@ -15,6 +23,7 @@ import {
|
|
|
15
23
|
type OverlayMotionOffset,
|
|
16
24
|
} from "./overlay-motion.js";
|
|
17
25
|
import {
|
|
26
|
+
NOTE_LINE_HEIGHT,
|
|
18
27
|
OVERLAY_LINE_HEIGHT,
|
|
19
28
|
OVERLAY_LIST_LINE_HEIGHT,
|
|
20
29
|
OVERLAY_PADDING_EM,
|
|
@@ -26,7 +35,13 @@ import {
|
|
|
26
35
|
getPlaceCardPinSize,
|
|
27
36
|
getListCardsByItem,
|
|
28
37
|
getListItemTimes,
|
|
38
|
+
getNoteColors,
|
|
39
|
+
getNotePaperPoints,
|
|
40
|
+
getNoteTextBox,
|
|
41
|
+
getNoteTickPoints,
|
|
42
|
+
getNoteWordsByLine,
|
|
29
43
|
getTitleContentBox,
|
|
44
|
+
isHandFontNeeded,
|
|
30
45
|
type OverlayBox,
|
|
31
46
|
type ResolvedOverlay,
|
|
32
47
|
} from "./overlays.js";
|
|
@@ -99,6 +114,8 @@ function getOverlayCss(colors: OverlayColors, fonts: { heading: string; interfac
|
|
|
99
114
|
`.ov-list .ov-card.cen{align-items:center;text-align:center}`,
|
|
100
115
|
`.ov-list li{white-space:nowrap}`,
|
|
101
116
|
`.ov.center .ov-card{transform-origin:50% 100%}`,
|
|
117
|
+
// A centred keyword (style.align center) centres a line that wraps too.
|
|
118
|
+
`.ov-keyword.center .ov-card{justify-content:center;text-align:center}`,
|
|
102
119
|
`.ov-list .ov-chip{position:absolute;box-sizing:border-box;flex-direction:row;align-items:center;justify-content:center;white-space:nowrap;line-height:${OVERLAY_LINE_HEIGHT};transform-origin:50% 100%}`,
|
|
103
120
|
`.ov-svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}`,
|
|
104
121
|
`.ov-search,.ov-counter .ov-card,.ov-date .ov-card,.ov-place,.ov-sub,.ov-line{white-space:nowrap}`,
|
|
@@ -131,6 +148,22 @@ function getOverlayCss(colors: OverlayColors, fonts: { heading: string; interfac
|
|
|
131
148
|
`.pd .ov-pinrow svg,.pl .ov-line,.sd .ov-sub{opacity:0}`,
|
|
132
149
|
// An underlined keyword keeps only its drawn bar: the card's own accent edge would be a second line under it.
|
|
133
150
|
`.ov-keyword.ul .ov-card{border-bottom-color:transparent}`,
|
|
151
|
+
// Dropped letters: each its own box, hidden until it starts falling.
|
|
152
|
+
`.dl{display:inline-block;opacity:0}`,
|
|
153
|
+
// A highlight backdrop: no card, each line on its own tight box that grows with the typed letters.
|
|
154
|
+
`.ov-mark{padding:.04em .22em;border-radius:.14em;-webkit-box-decoration-break:clone;box-decoration-break:clone}`,
|
|
155
|
+
`.ty .hl .ch{display:none}`,
|
|
156
|
+
// A typed line's mark waits for its first letter: an empty mark would show as a bare block of padding.
|
|
157
|
+
`.ty .hl .ov-mark{display:none}`,
|
|
158
|
+
// A note: its paper (an SVG outline with a torn edge and a soft shadow), its lines placed in px, its words hidden until said.
|
|
159
|
+
`.ov-note .nb{position:absolute;inset:0;transform-origin:50% 50%}`,
|
|
160
|
+
`.ov-note .paper{position:absolute;inset:0;overflow:visible;filter:drop-shadow(0 6px 14px rgba(0,0,0,.28))}`,
|
|
161
|
+
`.ov-note .nt{position:absolute;white-space:nowrap;line-height:${NOTE_LINE_HEIGHT}}`,
|
|
162
|
+
`.ov-note .nw{opacity:0}`,
|
|
163
|
+
`.ov-note .tick{position:absolute;inset:0;overflow:visible}`,
|
|
164
|
+
`.ov-strip .nt{font-family:${fonts.heading};font-weight:800;letter-spacing:.02em}`,
|
|
165
|
+
`.ov-hand{font-family:"${HAND_FONT.family}",cursive;font-weight:400}`,
|
|
166
|
+
`.ov-endword{white-space:nowrap;line-height:${OVERLAY_LINE_HEIGHT};text-shadow:0 3px 10px rgba(0,0,0,.45)}`,
|
|
134
167
|
// The brand's style (after the kinds' own rules, so it wins over them; the search bar stays a pill).
|
|
135
168
|
...(style === undefined
|
|
136
169
|
? []
|
|
@@ -139,6 +172,30 @@ function getOverlayCss(colors: OverlayColors, fonts: { heading: string; interfac
|
|
|
139
172
|
`.ov-search{border-radius:999px}`,
|
|
140
173
|
...(style.border === "none" ? [] : [`.ov-keyword .ov-card{border-bottom:.12em solid ${colors.accent}}`]),
|
|
141
174
|
]),
|
|
175
|
+
// After the brand's style, so a highlight backdrop never draws the card under its marks.
|
|
176
|
+
`.ov .ov-card.hl{background:transparent;box-shadow:none;border:none}`,
|
|
177
|
+
];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** The hand font's face, when a note card or an end word is drawn: the kit's file, copied to `src` by the render. */
|
|
181
|
+
function getHandFontCss(overlays: readonly ResolvedOverlay[], src: string): string[] {
|
|
182
|
+
return isHandFontNeeded(overlays) ? [`@font-face{font-family:"${HAND_FONT.family}";src:url("${src}") format("truetype");font-weight:400;font-style:normal}`] : [];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** A text whose letters drop in: each letter its own box (spaces stay text, so the line breaks and spaces as before). */
|
|
186
|
+
function toDropHtml(text: string): string {
|
|
187
|
+
return [...text].map((char) => (char.trim() === "" ? " " : `<span class="dl">${escapeHtml(char)}</span>`)).join("");
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* The tweens of dropped letters under `target`: each falls from `DROP_FROM_EM` above with its turn and lands eased out
|
|
192
|
+
* (`power2.out`, never past its place), `DROP_LETTER_GAP` after the one before, fading in over its first half.
|
|
193
|
+
*/
|
|
194
|
+
function getDropTweens(target: string, text: string, start: number, fontSize: number): string[] {
|
|
195
|
+
const turns = getDropLetterTurns([...text].filter((char) => char.trim() !== "").join(""));
|
|
196
|
+
return [
|
|
197
|
+
`tl.fromTo("${target} .dl", { y: ${r3(-DROP_FROM_EM * fontSize)}, rotation: (i) => ${JSON.stringify(turns)}[i] }, { y: 0, rotation: 0, duration: ${DROP_LETTER_SECONDS}, ease: "power2.out", stagger: ${DROP_LETTER_GAP}, immediateRender: false }, ${r3(start)});`,
|
|
198
|
+
`tl.fromTo("${target} .dl", { opacity: 0 }, { opacity: 1, duration: ${r3(DROP_LETTER_SECONDS / 2)}, ease: "none", stagger: ${DROP_LETTER_GAP}, immediateRender: false }, ${r3(start)});`,
|
|
142
199
|
];
|
|
143
200
|
}
|
|
144
201
|
|
|
@@ -180,7 +237,8 @@ function toTypedHtml(text: string): string {
|
|
|
180
237
|
function getCardStyle(overlay: ResolvedOverlay, colors: OverlayColors, scale = 1): string {
|
|
181
238
|
if (overlay.kind === "punch_in") return "";
|
|
182
239
|
const own = overlay.colors;
|
|
183
|
-
const
|
|
240
|
+
const isMarked = (overlay.kind === "hook_title" || overlay.kind === "keyword") && overlay.backdrop === "highlight";
|
|
241
|
+
const parts = [own.card === undefined || isMarked ? "" : `background:${colors.background}`, own.text === undefined ? "" : `color:${colors.foreground}`];
|
|
184
242
|
if (overlay.cornerRadius !== undefined && overlay.cornerRadius !== null) parts.push(`border-radius:${getCornerRadiusCss(overlay.cornerRadius, scale)}`);
|
|
185
243
|
if (overlay.kind === "hook_title" || overlay.kind === "place_card") {
|
|
186
244
|
// The text block sits where the draft draws it: the card's padding is what its fitted box leaves round it.
|
|
@@ -252,6 +310,19 @@ function getTypingTweens(id: string, overlay: { start: number; typing: number |
|
|
|
252
310
|
return [`tl.to("#${id} .ch", { opacity: 1, display: "inline", duration: 0.01, ease: "none", stagger: ${r3(1 / overlay.typing)} }, ${r3(overlay.start + OVERLAY_TYPING_DELAY)});`];
|
|
253
311
|
}
|
|
254
312
|
|
|
313
|
+
/** Shows each typed line's highlight mark (`#<id>m<line>`, a keyword's `#<id>t`) with the line's first letter. */
|
|
314
|
+
function getMarkRevealTweens(ids: readonly string[], overlay: { start: number; typing: number | null }, lines: readonly string[]): string[] {
|
|
315
|
+
const { typing } = overlay;
|
|
316
|
+
if (typing === null) return [];
|
|
317
|
+
let offset = 0;
|
|
318
|
+
return lines.flatMap((line, index) => {
|
|
319
|
+
const at = overlay.start + OVERLAY_TYPING_DELAY + offset / typing;
|
|
320
|
+
offset += [...line].length;
|
|
321
|
+
const target = ids[index];
|
|
322
|
+
return line === "" || target === undefined ? [] : [`tl.set("#${target}", { display: "inline" }, ${r3(at)});`];
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
255
326
|
/** Each new kind's own entrance when the overlay names none. */
|
|
256
327
|
const DEFAULT_ENTRANCES = { hook_title: "slide", search_bar: "fade", place_card: "slide", counter: "fade", date_stamp: "fade" } as const;
|
|
257
328
|
|
|
@@ -265,19 +336,25 @@ interface MarkupContext {
|
|
|
265
336
|
/** A keyword or a lower third, entering as the soft pill (or by its own entrance). */
|
|
266
337
|
function addSideText(overlay: Extract<ResolvedOverlay, { kind: "keyword" | "lower_third" }>, id: string, context: MarkupContext, out: OverlayMarkup): void {
|
|
267
338
|
const { box, fontSize, side } = overlay;
|
|
339
|
+
const isCentred = overlay.kind === "keyword" && overlay.isCentred === true;
|
|
268
340
|
const colors = getOverlayColors(overlay, context.colors);
|
|
269
341
|
const cardStyle = getCardStyle(overlay, colors, context.scale);
|
|
270
342
|
const dotStyle = overlay.colors.accent === undefined ? "" : ` style="background:${colors.accent}"`;
|
|
271
343
|
const isTyped = overlay.typing !== null;
|
|
272
344
|
const style = `left:${box.left}px;top:${box.top}px;width:${box.width}px;height:${box.height}px;font-size:${fontSize}px;align-items:${overlay.kind === "lower_third" ? "flex-end" : "flex-start"}`;
|
|
273
|
-
const
|
|
345
|
+
const isDrop = overlay.kind === "keyword" && overlay.entrance === "drop";
|
|
346
|
+
const text = isTyped ? toTypedHtml(overlay.text) : isDrop ? toDropHtml(overlay.text) : escapeHtml(overlay.text);
|
|
347
|
+
const isMarked = overlay.kind === "keyword" && overlay.backdrop === "highlight";
|
|
274
348
|
const wipe = overlay.entrance === "wipe" ? `<i class="ov-wipe" id="${id}w"></i>` : "";
|
|
275
349
|
const underline = overlay.kind === "keyword" && overlay.underline === true ? `<i class="ov-ul" id="${id}u" style="${getUnderlineStyle(overlay)}"></i>` : "";
|
|
276
|
-
const
|
|
277
|
-
|
|
350
|
+
const mark = isMarked ? ` class="ov-mark" style="background:${colors.background}"` : "";
|
|
351
|
+
const body = `<div class="ov-card${isMarked ? " hl" : ""}"${cardStyle}>${wipe}${overlay.kind === "lower_third" ? `<i class="ov-dot" id="${id}d"${dotStyle}></i>` : ""}<span id="${id}t"${mark}>${text}</span>${underline}</div>`;
|
|
352
|
+
out.html.push(clipDiv(overlay, id, `ov ov-${overlay.kind.replace("_", "-")}${isCentred ? " center" : side === "right" ? " right" : ""}${isTyped ? " ty" : ""}${underline === "" ? "" : " ul"}`, style, body));
|
|
278
353
|
if (overlay.entrance !== null) {
|
|
279
354
|
out.tweens.push(...getMotionTweens(`#${id} .ov-card`, getEntranceMotion(overlay.entrance, overlay.easing ?? "smooth", context.frame), overlay.start));
|
|
280
355
|
out.tweens.push(...getTypingTweens(id, overlay, [...overlay.text].length));
|
|
356
|
+
if (isMarked) out.tweens.push(...getMarkRevealTweens([`${id}t`], overlay, [[...overlay.text].join("")]));
|
|
357
|
+
if (isDrop) out.tweens.push(...getDropTweens(`#${id}`, overlay.text, overlay.start, overlay.fontSize));
|
|
281
358
|
} else {
|
|
282
359
|
// The soft pill's entrance: the card rises from its foot, then its dot and its text settle in, eased out without
|
|
283
360
|
// overshoot (RV-133 of an adopting app: nothing grows past its size).
|
|
@@ -371,8 +448,14 @@ function getCardBody(overlay: CardOverlay, id: string, colors: OverlayColors, lo
|
|
|
371
448
|
const typedOrPlain = (text: string) => (overlay.typing === null ? escapeHtml(text) : toTypedHtml(text));
|
|
372
449
|
if (overlay.kind === "hook_title") {
|
|
373
450
|
const place = overlay.place === null ? "" : `<div class="ov-place" style="font-size:${overlay.placeFontSize}px">${getPinSvg(colors.accent)}<span>${escapeHtml(overlay.place)}</span></div>`;
|
|
374
|
-
const
|
|
375
|
-
|
|
451
|
+
const isMarked = overlay.backdrop === "highlight";
|
|
452
|
+
const draw = (line: string) => (overlay.entrance === "drop" ? toDropHtml(line) : typedOrPlain(line));
|
|
453
|
+
const lines = overlay.lines.map((line, index) => `<div class="ov-line">${isMarked ? `<span class="ov-mark" id="${id}m${String(index)}" style="background:${colors.background}">${draw(line)}</span>` : draw(line)}</div>`).join("");
|
|
454
|
+
return {
|
|
455
|
+
classes: "ov-hook-title center",
|
|
456
|
+
body: `<div class="ov-card ov-stack${overlay.align === "left" ? " left" : ""}${isMarked ? " hl" : ""}"__STYLE__>__WIPE__${place}${lines}</div>`,
|
|
457
|
+
typed: overlay.lines.join("").length,
|
|
458
|
+
};
|
|
376
459
|
}
|
|
377
460
|
if (overlay.kind === "place_card") {
|
|
378
461
|
const subtitle = overlay.subtitle === null ? "" : `<div class="ov-sub" style="font-size:${overlay.subtitleFontSize}px">${escapeHtml(overlay.subtitle)}</div>`;
|
|
@@ -404,6 +487,8 @@ function addCard(overlay: CardOverlay, id: string, context: MarkupContext, out:
|
|
|
404
487
|
const entrance = overlay.entrance ?? (overlay.typing !== null ? "type" : DEFAULT_ENTRANCES[overlay.kind]);
|
|
405
488
|
out.tweens.push(...getEntranceTweens(`#${id} .ov-card`, entrance, overlay.start, { ...(overlay.easing === undefined ? {} : { easing: overlay.easing }), frame: context.frame }));
|
|
406
489
|
out.tweens.push(...getTypingTweens(id, overlay, typed));
|
|
490
|
+
if (overlay.kind === "hook_title" && overlay.backdrop === "highlight") out.tweens.push(...getMarkRevealTweens(overlay.lines.map((_, index) => `${id}m${String(index)}`), overlay, overlay.lines));
|
|
491
|
+
if (overlay.kind === "hook_title" && overlay.entrance === "drop") out.tweens.push(...getDropTweens(`#${id}`, overlay.lines.join(""), overlay.start, overlay.fontSize));
|
|
407
492
|
if (overlay.kind === "place_card") out.tweens.push(...getPlaceCardPartTweens(overlay, id, context));
|
|
408
493
|
if (overlay.kind === "counter") {
|
|
409
494
|
const count = getCounterSeconds(overlay);
|
|
@@ -460,6 +545,55 @@ function toScriptString(value: string): string {
|
|
|
460
545
|
return JSON.stringify(value).replace(/</g, "\\u003c");
|
|
461
546
|
}
|
|
462
547
|
|
|
548
|
+
/**
|
|
549
|
+
* A note: its paper (the torn outline of `getNotePaperPoints`) turned by its tilt about its middle; a card's words
|
|
550
|
+
* handwritten and shown each on its said second, the card there (empty) just before; a strip growing in from
|
|
551
|
+
* `NOTE_GROW_FROM_SCALE` (eased out, never past its size) and typing its capitals; the tick drawn after the last word.
|
|
552
|
+
*/
|
|
553
|
+
function addNote(overlay: Extract<ResolvedOverlay, { kind: "note" }>, id: string, context: MarkupContext, out: OverlayMarkup): void {
|
|
554
|
+
const { box, fontSize } = overlay;
|
|
555
|
+
const colors = getNoteColors(overlay);
|
|
556
|
+
const isStrip = overlay.noteStyle === "strip";
|
|
557
|
+
const local = (point: { x: number; y: number }) => `${r3(point.x - box.left)},${r3(point.y - box.top)}`;
|
|
558
|
+
const paper = `<svg class="paper" viewBox="0 0 ${box.width} ${box.height}"><polygon points="${getNotePaperPoints(overlay).map(local).join(" ")}" fill="${colors.paper}"/></svg>`;
|
|
559
|
+
const text = getNoteTextBox(overlay);
|
|
560
|
+
const lineHeight = fontSize * NOTE_LINE_HEIGHT;
|
|
561
|
+
const place = (index: number) => `left:${r3(text.left - box.left)}px;top:${r3(text.top - box.top + index * lineHeight)}px`;
|
|
562
|
+
let word = 0;
|
|
563
|
+
const lines = isStrip
|
|
564
|
+
? overlay.lines.map((line, index) => `<div class="nt" style="${place(index)}">${toTypedHtml(line)}</div>`)
|
|
565
|
+
: getNoteWordsByLine(overlay).map((words, index) => `<div class="nt" style="${place(index)}">${words.map((entry) => `<span class="nw" id="${id}w${word++}">${escapeHtml(entry.text)}</span>`).join(" ")}</div>`);
|
|
566
|
+
const tick = overlay.tickAt === null ? "" : `<svg class="tick" viewBox="0 0 ${box.width} ${box.height}"><polyline id="${id}k" points="${getNoteTickPoints(overlay).map(local).join(" ")}" fill="none" stroke="${colors.tick}" stroke-width="${r3(fontSize * 0.12)}" stroke-linecap="round" stroke-linejoin="round" pathLength="1" stroke-dasharray="1" stroke-dashoffset="1"/></svg>`;
|
|
567
|
+
const style = `left:${box.left}px;top:${box.top}px;width:${box.width}px;height:${box.height}px;font-size:${fontSize}px;color:${colors.ink};transform:rotate(${r3(-overlay.tilt)}deg)`;
|
|
568
|
+
out.html.push(clipDiv(overlay, id, `ov ov-note ${isStrip ? "ov-strip ty" : "ov-hand"}`, style, `<div class="nb">${paper}${lines.join("")}${tick}</div>`));
|
|
569
|
+
const look = { ...(overlay.easing === undefined ? {} : { easing: overlay.easing }), frame: context.frame };
|
|
570
|
+
if (isStrip && overlay.entrance === null) {
|
|
571
|
+
out.tweens.push(`tl.fromTo("#${id} .nb", { scale: ${NOTE_GROW_FROM_SCALE} }, { scale: 1, duration: ${NOTE_GROW_SECONDS}, ease: "power2.out", immediateRender: false }, ${overlay.start});`);
|
|
572
|
+
} else out.tweens.push(...getEntranceTweens(`#${id} .nb`, overlay.entrance ?? "none", overlay.start, look));
|
|
573
|
+
if (isStrip) out.tweens.push(...getTypingTweens(id, overlay, overlay.lines.join("").length));
|
|
574
|
+
else {
|
|
575
|
+
getNoteWordsByLine(overlay)
|
|
576
|
+
.flat()
|
|
577
|
+
.forEach((entry, index) => out.tweens.push(`tl.fromTo("#${id}w${index}", { opacity: 0 }, { opacity: 1, duration: 0.1, ease: "none", immediateRender: false }, ${entry.at});`));
|
|
578
|
+
}
|
|
579
|
+
if (overlay.tickAt !== null) {
|
|
580
|
+
out.tweens.push(`tl.fromTo("#${id}k", { attr: { "stroke-dashoffset": 1 } }, { attr: { "stroke-dashoffset": 0 }, duration: ${NOTE_TICK_SECONDS}, ease: "power2.out", immediateRender: false }, ${overlay.tickAt});`);
|
|
581
|
+
}
|
|
582
|
+
out.tweens.push(...getExitTweens(`#${id} .nb`, overlay, context.frame, `tl.to("#${id} .nb", { opacity: 0, duration: ${EXIT_SECONDS}, ease: "power2.in" }, ${r3(overlay.end - EXIT_SECONDS)});`));
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/** An end word: one big handwritten line, no card, its letters dropping in (or its own entrance), fading out at the end. */
|
|
586
|
+
function addEndWord(overlay: Extract<ResolvedOverlay, { kind: "end_word" }>, id: string, context: MarkupContext, out: OverlayMarkup): void {
|
|
587
|
+
const { box, fontSize } = overlay;
|
|
588
|
+
const entrance = overlay.entrance ?? "drop";
|
|
589
|
+
const text = entrance === "drop" ? toDropHtml(overlay.text) : escapeHtml(overlay.text);
|
|
590
|
+
const style = `left:${box.left}px;top:${box.top}px;width:${box.width}px;height:${box.height}px;font-size:${fontSize}px;justify-content:center;align-items:flex-start`;
|
|
591
|
+
out.html.push(clipDiv(overlay, id, "ov ov-end-word", style, `<div class="ov-endword ov-hand nb" style="color:${overlay.colors.text ?? "#ffffff"}">${text}</div>`));
|
|
592
|
+
if (entrance === "drop") out.tweens.push(...getDropTweens(`#${id}`, overlay.text, overlay.start, fontSize));
|
|
593
|
+
else out.tweens.push(...getEntranceTweens(`#${id} .nb`, entrance, overlay.start, { ...(overlay.easing === undefined ? {} : { easing: overlay.easing }), frame: context.frame }));
|
|
594
|
+
out.tweens.push(...getExitTweens(`#${id} .nb`, overlay, context.frame, `tl.to("#${id} .nb", { opacity: 0, duration: ${EXIT_SECONDS}, ease: "power2.in" }, ${r3(overlay.end - EXIT_SECONDS)});`));
|
|
595
|
+
}
|
|
596
|
+
|
|
463
597
|
/** An overlay's clip: shown for its own span. */
|
|
464
598
|
function clipDiv(overlay: ResolvedOverlay, id: string, classes: string, style: string, body: string): string {
|
|
465
599
|
return `<div id="${id}" class="clip ${classes}" data-start="${overlay.start}" data-duration="${r3(overlay.end - overlay.start)}" style="${style}">${body}</div>`;
|
|
@@ -505,17 +639,20 @@ function addMark(overlay: Extract<ResolvedOverlay, { kind: "arrow" | "highlight"
|
|
|
505
639
|
*/
|
|
506
640
|
export function getOverlayMarkup(
|
|
507
641
|
overlays: readonly ResolvedOverlay[],
|
|
508
|
-
input: { colors: OverlayColors; headingFont: string; interfaceFont?: string; locale?: string; frame: { width: number; height: number }; style?: BrandStyle },
|
|
642
|
+
input: { colors: OverlayColors; headingFont: string; interfaceFont?: string; locale?: string; frame: { width: number; height: number }; style?: BrandStyle; handFontSrc?: string },
|
|
509
643
|
): OverlayMarkup {
|
|
510
644
|
const drawn = overlays.filter((overlay): overlay is Exclude<ResolvedOverlay, { kind: "punch_in" }> => overlay.kind !== "punch_in");
|
|
511
645
|
if (drawn.length === 0) return { html: [], css: [], tweens: [] };
|
|
512
646
|
const context: MarkupContext = { colors: input.colors, scale: input.frame.width / 1080, locale: input.locale ?? "en-US", frame: input.frame };
|
|
513
|
-
const
|
|
647
|
+
const css = [...getHandFontCss(drawn, input.handFontSrc ?? HAND_FONT.asset), ...getOverlayCss(input.colors, { heading: input.headingFont, interface: input.interfaceFont ?? "inherit" }, input.style, context.scale)];
|
|
648
|
+
const out: OverlayMarkup = { html: [], css, tweens: [] };
|
|
514
649
|
for (const overlay of drawn) {
|
|
515
650
|
const id = `ov${overlay.index}`;
|
|
516
651
|
if (overlay.kind === "list") addList(overlay, id, context, out);
|
|
517
652
|
else if (overlay.kind === "keyword" || overlay.kind === "lower_third") addSideText(overlay, id, context, out);
|
|
518
653
|
else if (overlay.kind === "arrow" || overlay.kind === "highlight") addMark(overlay, id, context, out);
|
|
654
|
+
else if (overlay.kind === "note") addNote(overlay, id, context, out);
|
|
655
|
+
else if (overlay.kind === "end_word") addEndWord(overlay, id, context, out);
|
|
519
656
|
else addCard(overlay, id, context, out);
|
|
520
657
|
}
|
|
521
658
|
return out;
|
|
@@ -62,6 +62,8 @@ function getSmoothEntrance(entrance: Exclude<OverlayEntrance, "none" | "wipe">,
|
|
|
62
62
|
switch (entrance) {
|
|
63
63
|
case "fade":
|
|
64
64
|
return { from: { ...REST, opacity: 0 }, seconds: 0.4, ease: "power2.out" };
|
|
65
|
+
// A dropped text's card (or highlight) fades in quickly; its letters fall in on their own (`getDropOffsetAt`).
|
|
66
|
+
case "drop":
|
|
65
67
|
case "type":
|
|
66
68
|
return { from: { ...REST, opacity: 0 }, seconds: 0.25, ease: "power2.out" };
|
|
67
69
|
case "slide":
|
|
@@ -108,6 +110,7 @@ export function getExitMotion(input: { exit: OverlayExit; entrance: OverlayEntra
|
|
|
108
110
|
return { kind: "own" };
|
|
109
111
|
case "fade":
|
|
110
112
|
case "type":
|
|
113
|
+
case "drop":
|
|
111
114
|
return tween(fade);
|
|
112
115
|
case "slide":
|
|
113
116
|
return tween(slide);
|
|
@@ -155,3 +158,49 @@ export function getListItemStarts(input: { start: number; end: number; count: nu
|
|
|
155
158
|
const gap = Math.min(0.6, Math.max(0.25, ((end - start) * 0.4) / count));
|
|
156
159
|
return Array.from({ length: count }, (_item, index) => r3(Math.min(latest, start + 0.2 + index * gap)));
|
|
157
160
|
}
|
|
161
|
+
|
|
162
|
+
/** A dropped letter falls from this share of its line's type size above its place. */
|
|
163
|
+
export const DROP_FROM_EM = 0.3;
|
|
164
|
+
/** The seconds one letter falls, and the seconds between two letters' starts (2 frames at 30 fps). */
|
|
165
|
+
export const DROP_LETTER_SECONDS = 0.3;
|
|
166
|
+
export const DROP_LETTER_GAP = 0.067;
|
|
167
|
+
/** The most a letter is turned when it starts falling, in degrees; it turns back to straight as it lands. */
|
|
168
|
+
export const DROP_MAX_TURN = 8;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* The film seconds each letter of a dropped text starts falling at (a space takes no turn of its own): the first at
|
|
172
|
+
* `start`, each next one `DROP_LETTER_GAP` later.
|
|
173
|
+
*/
|
|
174
|
+
export function getDropLetterTimes(start: number, text: string): number[] {
|
|
175
|
+
let letter = 0;
|
|
176
|
+
return [...text].map((char) => {
|
|
177
|
+
const at = r3(start + letter * DROP_LETTER_GAP);
|
|
178
|
+
if (char.trim() !== "") letter += 1;
|
|
179
|
+
return at;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** The turn each letter starts with, in degrees: alternating sides, between half and all of `DROP_MAX_TURN`. */
|
|
184
|
+
export function getDropLetterTurns(text: string): number[] {
|
|
185
|
+
return [...text].map((_char, index) => r3((index % 2 === 0 ? -1 : 1) * DROP_MAX_TURN * (0.5 + 0.5 * (((index * 7) % 5) / 4))));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* A dropped letter `seconds` after it starts falling: px above its place (negative y, up), its turn and its opacity.
|
|
190
|
+
* The fall eases out along `power2.out`, so the letter slows into its place and never passes it: y stays at or above 0
|
|
191
|
+
* (screen y grows down), and the turn shrinks to 0 without changing sides.
|
|
192
|
+
*/
|
|
193
|
+
export function getDropOffsetAt(seconds: number, input: { fontSize: number; turn: number }): { y: number; turn: number; opacity: number } {
|
|
194
|
+
const progress = Math.min(1, Math.max(0, seconds / DROP_LETTER_SECONDS));
|
|
195
|
+
const eased = OVERLAY_EASES["power2.out"](progress);
|
|
196
|
+
return { y: r3(-DROP_FROM_EM * input.fontSize * (1 - eased)), turn: r3(input.turn * (1 - eased)), opacity: r3(Math.min(1, progress * 2)) };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** A note strip grows from this share of its size over these seconds (8 frames at 30 fps), eased out. */
|
|
200
|
+
export const NOTE_GROW_FROM_SCALE = 0.3;
|
|
201
|
+
export const NOTE_GROW_SECONDS = 0.267;
|
|
202
|
+
/** A note's tick is drawn over these seconds, this long after its last word. */
|
|
203
|
+
export const NOTE_TICK_SECONDS = 0.3;
|
|
204
|
+
export const NOTE_TICK_DELAY = 0.15;
|
|
205
|
+
/** A note card is there, empty, this long before its first word (one frame at 30 fps). */
|
|
206
|
+
export const NOTE_FIRST_WORD_LEAD = 0.034;
|
|
@@ -15,9 +15,11 @@ import { CORNER_RADII, type CornerRadius } from "./brand-style.js";
|
|
|
15
15
|
* hook's question or title at the top of the frame, one or two lines, with an optional place label (a drawn pin and
|
|
16
16
|
* "City, Country") above it; it may stay across cuts. `search_bar`: a rounded search field whose text types in.
|
|
17
17
|
* `place_card`: a big place title with a one-line subtitle. `counter`: a number with a unit counting up to its value.
|
|
18
|
-
* `date_stamp`: a day or a date with a place, small, in a corner of the top band.
|
|
18
|
+
* `date_stamp`: a day or a date with a place, small, in a corner of the top band. `note`: a paper note (a handwritten
|
|
19
|
+
* card whose words appear as they are said, or a torn strip that grows in and types its text). `end_word`: one big
|
|
20
|
+
* handwritten word at the top over the film's last moment.
|
|
19
21
|
*/
|
|
20
|
-
export const OVERLAY_KINDS = ["punch_in", "keyword", "lower_third", "list", "arrow", "highlight", "hook_title", "search_bar", "place_card", "counter", "date_stamp"] as const;
|
|
22
|
+
export const OVERLAY_KINDS = ["punch_in", "keyword", "lower_third", "list", "arrow", "highlight", "hook_title", "search_bar", "place_card", "counter", "date_stamp", "note", "end_word"] as const;
|
|
21
23
|
|
|
22
24
|
export type OverlayKind = (typeof OVERLAY_KINDS)[number];
|
|
23
25
|
|
|
@@ -41,6 +43,11 @@ export const OVERLAY_ALIGNS = ["center", "left"] as const;
|
|
|
41
43
|
|
|
42
44
|
export type OverlayAlign = (typeof OVERLAY_ALIGNS)[number];
|
|
43
45
|
|
|
46
|
+
/** Where a keyword's card sits across the room it may take: on the left, in the middle or on the right. */
|
|
47
|
+
export const OVERLAY_KEYWORD_ALIGNS = ["left", "center", "right"] as const;
|
|
48
|
+
|
|
49
|
+
export type OverlayKeywordAlign = (typeof OVERLAY_KEYWORD_ALIGNS)[number];
|
|
50
|
+
|
|
44
51
|
/** The kinds whose lines take an `align`: the two stacked title cards. */
|
|
45
52
|
export const OVERLAY_ALIGNED_KINDS: readonly OverlayKind[] = ["hook_title", "place_card"];
|
|
46
53
|
|
|
@@ -49,9 +56,10 @@ export const OVERLAY_ALIGNED_KINDS: readonly OverlayKind[] = ["hook_title", "pla
|
|
|
49
56
|
* simply there), `pop` (grows from 92 % to 100 % while it fades in, eased out, never past its size), `rise` (up from
|
|
50
57
|
* 5 % of the frame's height while it fades in), `blur` (from a slight blur to sharp) or `wipe` (its card revealed from
|
|
51
58
|
* the left in the accent colour, then its text). Without one, the kind's own entrance. Never a bounce or an overshoot:
|
|
52
|
-
* the reel stays natural (`overlay-motion.ts`).
|
|
59
|
+
* the reel stays natural (`overlay-motion.ts`). `drop` (a hook title, a keyword, an end word): its letters fall into
|
|
60
|
+
* place one by one, eased out, never below their line.
|
|
53
61
|
*/
|
|
54
|
-
export const OVERLAY_ENTRANCES = ["fade", "slide", "type", "none", "pop", "rise", "blur", "wipe"] as const;
|
|
62
|
+
export const OVERLAY_ENTRANCES = ["fade", "slide", "type", "none", "pop", "rise", "blur", "wipe", "drop"] as const;
|
|
55
63
|
|
|
56
64
|
export type OverlayEntrance = (typeof OVERLAY_ENTRANCES)[number];
|
|
57
65
|
|
|
@@ -83,11 +91,33 @@ export const OVERLAY_LIST_LAYOUTS = ["stack", "chips", "auto"] as const;
|
|
|
83
91
|
|
|
84
92
|
export type OverlayListLayout = (typeof OVERLAY_LIST_LAYOUTS)[number];
|
|
85
93
|
|
|
94
|
+
/**
|
|
95
|
+
* What a hook title's or a keyword's text sits on: `card` (its card, the default) or `highlight` (each line on its own
|
|
96
|
+
* tight box in the card colour, without shadow; typed in, the box grows with the letters).
|
|
97
|
+
*/
|
|
98
|
+
export const OVERLAY_BACKDROPS = ["card", "highlight"] as const;
|
|
99
|
+
|
|
100
|
+
export type OverlayBackdrop = (typeof OVERLAY_BACKDROPS)[number];
|
|
101
|
+
|
|
102
|
+
/** The kinds that take a `backdrop`. */
|
|
103
|
+
export const OVERLAY_BACKDROP_KINDS: readonly OverlayKind[] = ["hook_title", "keyword"];
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* A note's shape: `card` (a slightly tilted paper card with a torn foot, its words handwritten as they are said) or
|
|
107
|
+
* `strip` (a paper strip with a torn top that grows in, then types its text in capitals).
|
|
108
|
+
*/
|
|
109
|
+
export const OVERLAY_NOTE_STYLES = ["card", "strip"] as const;
|
|
110
|
+
|
|
111
|
+
export type OverlayNoteStyle = (typeof OVERLAY_NOTE_STYLES)[number];
|
|
112
|
+
|
|
86
113
|
/** The longest a place card's subtitle waits after its title, in seconds. */
|
|
87
114
|
export const MAX_OVERLAY_SUBTITLE_DELAY = 0.6;
|
|
88
115
|
|
|
89
116
|
/** The shortest an overlay stays on screen: shorter does not read. */
|
|
90
117
|
export const MIN_OVERLAY_SECONDS = 1;
|
|
118
|
+
/** The shortest and longest an `end_word` stays: the film's last moment. */
|
|
119
|
+
export const MIN_END_WORD_SECONDS = 0.5;
|
|
120
|
+
export const MAX_END_WORD_SECONDS = 2;
|
|
91
121
|
/** The longest an overlay stays on screen (a `hook_title` may stay up to `MAX_HOOK_TITLE_SECONDS`). */
|
|
92
122
|
export const MAX_OVERLAY_SECONDS = 8;
|
|
93
123
|
/** The longest a `hook_title` stays on screen: up to a whole short film. */
|
|
@@ -110,6 +140,10 @@ export const MAX_OVERLAY_PLACE_TITLE_LENGTH = 28;
|
|
|
110
140
|
export const MAX_OVERLAY_SUBTITLE_LENGTH = 40;
|
|
111
141
|
/** The longest `date_stamp` text. */
|
|
112
142
|
export const MAX_OVERLAY_DATE_LENGTH = 24;
|
|
143
|
+
/** The longest `note` text. */
|
|
144
|
+
export const MAX_OVERLAY_NOTE_LENGTH = 72;
|
|
145
|
+
/** The longest `end_word` text. */
|
|
146
|
+
export const MAX_OVERLAY_END_WORD_LENGTH = 16;
|
|
113
147
|
/** The longest `counter` unit. */
|
|
114
148
|
export const MAX_OVERLAY_UNIT_LENGTH = 12;
|
|
115
149
|
/** The largest `counter` value. */
|
|
@@ -151,8 +185,11 @@ export interface EdlOverlayStyle {
|
|
|
151
185
|
colors?: EdlOverlayColors;
|
|
152
186
|
/** Its card's corner in place of the brand style's (`BrandStyle.cornerRadius`); not on a punch_in, arrow or highlight. */
|
|
153
187
|
corner_radius?: CornerRadius;
|
|
154
|
-
/**
|
|
155
|
-
|
|
188
|
+
/**
|
|
189
|
+
* How a hook title's or a place card's lines sit in the card (`center` or `left`, `center` without it), or where a
|
|
190
|
+
* keyword's card sits across its room (`left`, `center` or `right`, in place of `side`).
|
|
191
|
+
*/
|
|
192
|
+
align?: OverlayKeywordAlign;
|
|
156
193
|
/** A place card's subtitle size: `s`, `m` (about 55 % of the title, the default) or `l`. */
|
|
157
194
|
subtitle_size?: OverlaySize;
|
|
158
195
|
/** How it leaves (`auto` without it: mirrors the entrance). */
|
|
@@ -169,6 +206,12 @@ export interface EdlOverlayStyle {
|
|
|
169
206
|
pin?: OverlayPin;
|
|
170
207
|
/** A keyword's accent bar drawn under the word after it enters. */
|
|
171
208
|
underline?: boolean;
|
|
209
|
+
/** What a hook title's or a keyword's text sits on (`card` without it). */
|
|
210
|
+
backdrop?: OverlayBackdrop;
|
|
211
|
+
/** A note's shape (`card` without it). */
|
|
212
|
+
note_style?: OverlayNoteStyle;
|
|
213
|
+
/** A note's hand-drawn tick after its last word. */
|
|
214
|
+
tick?: boolean;
|
|
172
215
|
}
|
|
173
216
|
|
|
174
217
|
export interface EdlOverlay {
|
|
@@ -179,7 +222,7 @@ export interface EdlOverlay {
|
|
|
179
222
|
at?: number;
|
|
180
223
|
/** Seconds on screen (`MIN_OVERLAY_SECONDS` to `MAX_OVERLAY_SECONDS`; a `hook_title` up to `MAX_HOOK_TITLE_SECONDS`). */
|
|
181
224
|
duration: number;
|
|
182
|
-
/** The text of a `keyword`, `lower_third`, `hook_title`, `search_bar`, `place_card` (its title) or `
|
|
225
|
+
/** The text of a `keyword`, `lower_third`, `hook_title`, `search_bar`, `place_card` (its title), `date_stamp`, `note` or `end_word`. */
|
|
183
226
|
text?: string;
|
|
184
227
|
/** The `list` points (2 to 4). */
|
|
185
228
|
items?: string[];
|
|
@@ -229,6 +272,8 @@ const KIND_FIELDS: Record<OverlayKind, KindFields> = {
|
|
|
229
272
|
place_card: { ...TEXT_ONLY, subtitle: true },
|
|
230
273
|
counter: { ...NO_FIELDS, counter: true },
|
|
231
274
|
date_stamp: { ...TEXT_ONLY, place: true },
|
|
275
|
+
note: TEXT_ONLY,
|
|
276
|
+
end_word: TEXT_ONLY,
|
|
232
277
|
};
|
|
233
278
|
|
|
234
279
|
const TEXT_LIMITS: Partial<Record<OverlayKind, number>> = {
|
|
@@ -238,10 +283,12 @@ const TEXT_LIMITS: Partial<Record<OverlayKind, number>> = {
|
|
|
238
283
|
search_bar: MAX_OVERLAY_SEARCH_LENGTH,
|
|
239
284
|
place_card: MAX_OVERLAY_PLACE_TITLE_LENGTH,
|
|
240
285
|
date_stamp: MAX_OVERLAY_DATE_LENGTH,
|
|
286
|
+
note: MAX_OVERLAY_NOTE_LENGTH,
|
|
287
|
+
end_word: MAX_OVERLAY_END_WORD_LENGTH,
|
|
241
288
|
};
|
|
242
289
|
|
|
243
290
|
/** The kinds that take a side. */
|
|
244
|
-
export const OVERLAY_SIDED_KINDS: readonly OverlayKind[] = ["keyword", "lower_third", "list", "date_stamp"];
|
|
291
|
+
export const OVERLAY_SIDED_KINDS: readonly OverlayKind[] = ["keyword", "lower_third", "list", "date_stamp", "note"];
|
|
245
292
|
|
|
246
293
|
/** The positions a kind may take (none: its place is fixed). */
|
|
247
294
|
export const OVERLAY_POSITIONS_BY_KIND: Partial<Record<OverlayKind, readonly OverlayPosition[]>> = {
|
|
@@ -251,6 +298,7 @@ export const OVERLAY_POSITIONS_BY_KIND: Partial<Record<OverlayKind, readonly Ove
|
|
|
251
298
|
search_bar: ["top", "middle", "bottom"],
|
|
252
299
|
place_card: ["top", "middle", "bottom"],
|
|
253
300
|
counter: ["top", "middle", "bottom"],
|
|
301
|
+
note: ["top", "middle"],
|
|
254
302
|
};
|
|
255
303
|
|
|
256
304
|
const TEXT_ENTRANCES: readonly OverlayEntrance[] = ["fade", "slide", "type", "none", "pop", "rise", "blur", "wipe"];
|
|
@@ -259,22 +307,24 @@ const BLOCK_ENTRANCES: readonly OverlayEntrance[] = ["fade", "slide", "none", "p
|
|
|
259
307
|
/** The entrances a kind may take (none listed: it takes no entrance). */
|
|
260
308
|
export const OVERLAY_ENTRANCES_BY_KIND: Record<OverlayKind, readonly OverlayEntrance[]> = {
|
|
261
309
|
punch_in: [],
|
|
262
|
-
keyword: TEXT_ENTRANCES,
|
|
310
|
+
keyword: [...TEXT_ENTRANCES, "drop"],
|
|
263
311
|
lower_third: TEXT_ENTRANCES,
|
|
264
312
|
list: BLOCK_ENTRANCES,
|
|
265
313
|
arrow: ["fade", "none"],
|
|
266
314
|
highlight: ["fade", "none"],
|
|
267
|
-
hook_title: TEXT_ENTRANCES,
|
|
315
|
+
hook_title: [...TEXT_ENTRANCES, "drop"],
|
|
268
316
|
search_bar: TEXT_ENTRANCES,
|
|
269
317
|
place_card: TEXT_ENTRANCES,
|
|
270
318
|
counter: BLOCK_ENTRANCES,
|
|
271
319
|
date_stamp: TEXT_ENTRANCES,
|
|
320
|
+
note: ["fade", "pop", "none"],
|
|
321
|
+
end_word: ["drop", "pop", "fade", "rise", "none"],
|
|
272
322
|
};
|
|
273
323
|
|
|
274
|
-
/** Whether an overlay types its text in: the `type` entrance,
|
|
324
|
+
/** Whether an overlay types its text in: the `type` entrance, a search bar without another entrance, or a note strip. */
|
|
275
325
|
export function isTypedOverlay(overlay: Pick<EdlOverlay, "kind" | "style">): boolean {
|
|
276
326
|
const entrance = overlay.style?.entrance;
|
|
277
|
-
return entrance === "type" || (overlay.kind === "search_bar" && entrance === undefined);
|
|
327
|
+
return entrance === "type" || (overlay.kind === "search_bar" && entrance === undefined) || (overlay.kind === "note" && overlay.style?.note_style === "strip");
|
|
278
328
|
}
|
|
279
329
|
|
|
280
330
|
const overlayText = z.string().trim().min(1, "is empty");
|
|
@@ -288,7 +338,11 @@ function checkOverlayFields(overlay: EdlOverlay, issue: (path: string[], message
|
|
|
288
338
|
const { kind } = overlay;
|
|
289
339
|
const fields = KIND_FIELDS[kind];
|
|
290
340
|
if ((overlay.at_word === undefined) === (overlay.at === undefined)) issue([], "needs exactly one of at_word and at");
|
|
291
|
-
if (kind
|
|
341
|
+
if (kind === "end_word") {
|
|
342
|
+
// Below MIN_END_WORD_SECONDS the field's own minimum refuses it.
|
|
343
|
+
if (overlay.duration > MAX_END_WORD_SECONDS) issue(["duration"], `an end_word stays ${MIN_END_WORD_SECONDS} to ${MAX_END_WORD_SECONDS} s`);
|
|
344
|
+
} else if (overlay.duration < MIN_OVERLAY_SECONDS) issue(["duration"], `${article(kind)} stays at least ${MIN_OVERLAY_SECONDS} s (only an end_word stays shorter)`);
|
|
345
|
+
else if (kind !== "hook_title" && overlay.duration > MAX_OVERLAY_SECONDS) issue(["duration"], `${article(kind)} stays at most ${MAX_OVERLAY_SECONDS} s (only a hook_title stays longer)`);
|
|
292
346
|
if (fields.text === "required" && overlay.text === undefined) issue(["text"], `${article(kind)} needs its text`);
|
|
293
347
|
if (fields.text === "none" && overlay.text !== undefined) issue(["text"], `${article(kind)} draws no text; leave it out`);
|
|
294
348
|
const limit = TEXT_LIMITS[kind];
|
|
@@ -331,15 +385,24 @@ function checkOverlayStyle(overlay: EdlOverlay, issue: (path: string[], message:
|
|
|
331
385
|
if (style.entrance !== undefined && !entrances.includes(style.entrance)) {
|
|
332
386
|
issue(["style", "entrance"], entrances.length === 0 ? `${article(kind)} has no entrance; leave it out` : `${article(kind)} enters by ${entrances.join(", ")}`);
|
|
333
387
|
}
|
|
334
|
-
if (style.typing_speed !== undefined && !isTypedOverlay(overlay)) issue(["style", "typing_speed"], "only a typed entrance
|
|
388
|
+
if (style.typing_speed !== undefined && !isTypedOverlay(overlay)) issue(["style", "typing_speed"], "only a typed entrance, a search bar or a note strip has a typing speed");
|
|
335
389
|
if (style.corner_radius !== undefined && (kind === "punch_in" || kind === "arrow" || kind === "highlight")) issue(["style", "corner_radius"], `${article(kind)} draws no card; leave corner_radius out`);
|
|
336
|
-
if (style.align !== undefined
|
|
390
|
+
if (style.align !== undefined) {
|
|
391
|
+
if (kind === "keyword") {
|
|
392
|
+
if (style.side !== undefined) issue(["style", "align"], "give a keyword align or side, not both");
|
|
393
|
+
} else if (!OVERLAY_ALIGNED_KINDS.includes(kind)) issue(["style", "align"], "only a hook_title, a place_card or a keyword takes align; leave it out");
|
|
394
|
+
else if (!(OVERLAY_ALIGNS as readonly string[]).includes(style.align)) issue(["style", "align"], `${article(kind)} aligns its lines ${OVERLAY_ALIGNS.join(" or ")}`);
|
|
395
|
+
}
|
|
337
396
|
if (style.subtitle_size !== undefined && kind !== "place_card") issue(["style", "subtitle_size"], "only a place_card has a subtitle; leave subtitle_size out");
|
|
338
397
|
if (style.subtitle_delay !== undefined && kind !== "place_card") issue(["style", "subtitle_delay"], "only a place_card has a subtitle; leave subtitle_delay out");
|
|
339
398
|
if (style.pin !== undefined && kind !== "place_card") issue(["style", "pin"], "only a place_card draws a pin; leave pin out");
|
|
340
399
|
if (style.stagger !== undefined && kind !== "list") issue(["style", "stagger"], "only a list has points to stagger; leave stagger out");
|
|
341
400
|
if (style.list_layout !== undefined && kind !== "list") issue(["style", "list_layout"], "only a list lays out points; leave list_layout out");
|
|
342
401
|
if (style.underline !== undefined && kind !== "keyword") issue(["style", "underline"], "only a keyword is underlined; leave underline out");
|
|
402
|
+
if (style.backdrop !== undefined && !OVERLAY_BACKDROP_KINDS.includes(kind)) issue(["style", "backdrop"], "only a hook_title or a keyword takes a backdrop; leave it out");
|
|
403
|
+
if (style.backdrop === "highlight" && style.underline === true) issue(["style", "backdrop"], "a highlighted keyword draws no underline; give backdrop highlight or underline, not both");
|
|
404
|
+
if (style.note_style !== undefined && kind !== "note") issue(["style", "note_style"], "only a note has a note_style; leave it out");
|
|
405
|
+
if (style.tick !== undefined && kind !== "note") issue(["style", "tick"], "only a note draws a tick; leave it out");
|
|
343
406
|
if ((style.exit !== undefined || style.easing !== undefined) && kind === "punch_in") issue(["style", style.exit === undefined ? "easing" : "exit"], "a punch_in eases the picture itself; leave exit and easing out");
|
|
344
407
|
if (style.colors === undefined) return;
|
|
345
408
|
if (kind === "punch_in") issue(["style", "colors"], "a punch_in draws nothing to colour; leave colors out");
|
|
@@ -352,7 +415,7 @@ export const overlaySchema = z
|
|
|
352
415
|
.strictObject({
|
|
353
416
|
kind: z
|
|
354
417
|
.enum(OVERLAY_KINDS)
|
|
355
|
-
.describe("punch_in (an emphasis zoom on a word), keyword, lower_third, list, arrow, highlight, hook_title, search_bar, place_card, counter or
|
|
418
|
+
.describe("punch_in (an emphasis zoom on a word), keyword, lower_third, list, arrow, highlight, hook_title, search_bar, place_card, counter, date_stamp, note or end_word."),
|
|
356
419
|
at_word: z
|
|
357
420
|
.strictObject({
|
|
358
421
|
text: overlayText.describe("The word as the transcript has it; compared without case and punctuation."),
|
|
@@ -363,13 +426,13 @@ export const overlaySchema = z
|
|
|
363
426
|
at: z.number().min(0).optional().describe("The film second the overlay starts at; give this or at_word."),
|
|
364
427
|
duration: z
|
|
365
428
|
.number()
|
|
366
|
-
.min(
|
|
429
|
+
.min(MIN_END_WORD_SECONDS)
|
|
367
430
|
.max(MAX_HOOK_TITLE_SECONDS)
|
|
368
|
-
.describe(`Seconds on screen (${MIN_OVERLAY_SECONDS}-${MAX_OVERLAY_SECONDS}; a hook_title up to ${MAX_HOOK_TITLE_SECONDS}).`),
|
|
431
|
+
.describe(`Seconds on screen (${MIN_OVERLAY_SECONDS}-${MAX_OVERLAY_SECONDS}; a hook_title up to ${MAX_HOOK_TITLE_SECONDS}; an end_word ${MIN_END_WORD_SECONDS}-${MAX_END_WORD_SECONDS}).`),
|
|
369
432
|
text: overlayText
|
|
370
433
|
.optional()
|
|
371
434
|
.describe(
|
|
372
|
-
`The text: keyword (up to ${MAX_OVERLAY_KEYWORD_LENGTH} characters), lower_third (${MAX_OVERLAY_LOWER_THIRD_LENGTH}), hook_title (${MAX_OVERLAY_HOOK_TITLE_LENGTH}, one or two lines), search_bar (${MAX_OVERLAY_SEARCH_LENGTH}), place_card title (${MAX_OVERLAY_PLACE_TITLE_LENGTH})
|
|
435
|
+
`The text: keyword (up to ${MAX_OVERLAY_KEYWORD_LENGTH} characters), lower_third (${MAX_OVERLAY_LOWER_THIRD_LENGTH}), hook_title (${MAX_OVERLAY_HOOK_TITLE_LENGTH}, one or two lines), search_bar (${MAX_OVERLAY_SEARCH_LENGTH}), place_card title (${MAX_OVERLAY_PLACE_TITLE_LENGTH}), date_stamp (${MAX_OVERLAY_DATE_LENGTH}), note (${MAX_OVERLAY_NOTE_LENGTH}) or end_word (${MAX_OVERLAY_END_WORD_LENGTH}, one line).`,
|
|
373
436
|
),
|
|
374
437
|
items: z
|
|
375
438
|
.array(overlayText.max(MAX_OVERLAY_LIST_ITEM_LENGTH, `is longer than ${MAX_OVERLAY_LIST_ITEM_LENGTH} characters`))
|
|
@@ -420,16 +483,16 @@ export const overlaySchema = z
|
|
|
420
483
|
style: z
|
|
421
484
|
.strictObject({
|
|
422
485
|
size: z.enum(OVERLAY_SIZES).optional().describe("s, m (the default) or l: the punch-in's zoom (108, 112, 115 %) or the type size."),
|
|
423
|
-
side: z.enum(OVERLAY_SIDES).optional().describe("The side a keyword, lower third, list
|
|
486
|
+
side: z.enum(OVERLAY_SIDES).optional().describe("The side a keyword, lower third, list, date stamp or note sits on."),
|
|
424
487
|
position: z
|
|
425
488
|
.enum(OVERLAY_POSITIONS)
|
|
426
489
|
.optional()
|
|
427
|
-
.describe("top, middle or bottom of the room above the captions: keyword, search_bar, place_card, counter (any), lower_third (top or bottom), list (top or middle)."),
|
|
490
|
+
.describe("top, middle or bottom of the room above the captions: keyword, search_bar, place_card, counter (any), lower_third (top or bottom), list and note (top or middle)."),
|
|
428
491
|
entrance: z
|
|
429
492
|
.enum(OVERLAY_ENTRANCES)
|
|
430
493
|
.optional()
|
|
431
494
|
.describe(
|
|
432
|
-
"fade, slide, type (text typed in letter by letter), none, pop (92 % to 100 %, no overshoot), rise (up from 5 % of the height), blur (blurred to sharp)
|
|
495
|
+
"fade, slide, type (text typed in letter by letter), none, pop (92 % to 100 %, no overshoot), rise (up from 5 % of the height), blur (blurred to sharp), wipe (card revealed from the left in the accent, then the text) or drop (hook_title, keyword, end_word: letters fall into place one by one, never below their line); without it the kind's own. Never a bounce.",
|
|
433
496
|
),
|
|
434
497
|
exit: z.enum(OVERLAY_EXITS).optional().describe("auto (the default: mirrors the entrance), fade, slide (down and out) or none."),
|
|
435
498
|
easing: z.enum(OVERLAY_EASINGS).optional().describe("smooth (the default) or snappy: the curve of the entrance and the exit."),
|
|
@@ -451,7 +514,12 @@ export const overlaySchema = z
|
|
|
451
514
|
.enum(CORNER_RADII)
|
|
452
515
|
.optional()
|
|
453
516
|
.describe("The card's corner: none, s, m, l or pill; the brand style's without it (no punch_in, arrow or highlight)."),
|
|
454
|
-
align: z
|
|
517
|
+
align: z
|
|
518
|
+
.enum(OVERLAY_KEYWORD_ALIGNS)
|
|
519
|
+
.optional()
|
|
520
|
+
.describe(
|
|
521
|
+
"center (the default) or left: how a hook_title's or a place_card's lines sit in their card; left, center or right: where a keyword's card sits across its room (in place of side).",
|
|
522
|
+
),
|
|
455
523
|
subtitle_size: z.enum(OVERLAY_SIZES).optional().describe("s, m (the default, about 55 % of the title) or l: a place_card's subtitle size."),
|
|
456
524
|
stagger: z.boolean().optional().describe("A list only: its points come in one by one (on item_words when given, else spaced automatically)."),
|
|
457
525
|
list_layout: z
|
|
@@ -468,6 +536,15 @@ export const overlaySchema = z
|
|
|
468
536
|
.describe(`A place_card only: seconds its subtitle waits after its title (0-${MAX_OVERLAY_SUBTITLE_DELAY}).`),
|
|
469
537
|
pin: z.enum(OVERLAY_PINS).optional().describe("A place_card only: none (the default), static or drop (an accent pin above the title that falls a little and stops)."),
|
|
470
538
|
underline: z.boolean().optional().describe("A keyword only: an accent bar drawn under the word after it enters."),
|
|
539
|
+
backdrop: z
|
|
540
|
+
.enum(OVERLAY_BACKDROPS)
|
|
541
|
+
.optional()
|
|
542
|
+
.describe("A hook_title or keyword only: card (the default) or highlight (each line on its own tight box in the card colour; typed in, the box grows with the letters)."),
|
|
543
|
+
note_style: z
|
|
544
|
+
.enum(OVERLAY_NOTE_STYLES)
|
|
545
|
+
.optional()
|
|
546
|
+
.describe("A note only: card (the default: a tilted paper card, handwritten words appearing as they are said) or strip (a torn paper strip that grows in, then types its text in capitals)."),
|
|
547
|
+
tick: z.boolean().optional().describe("A note only: a hand-drawn tick after its last word."),
|
|
471
548
|
})
|
|
472
549
|
.optional()
|
|
473
550
|
.describe("The overlay's look: size, side, position, entrance, typing speed and colours; fonts are the brand's."),
|