@softure-ai/marketing-kit 0.21.2 → 0.22.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 +22 -0
- package/NOTICE +11 -0
- package/README.md +35 -4
- package/dist/config/actions-schema.d.ts +35 -35
- package/dist/config/brand.d.ts.map +1 -1
- package/dist/config/brand.js +22 -1
- package/dist/config/brand.js.map +1 -1
- package/dist/config/colors.d.ts +12 -2
- package/dist/config/colors.d.ts.map +1 -1
- package/dist/config/colors.js +32 -0
- package/dist/config/colors.js.map +1 -1
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +2 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/schema.d.ts +181 -172
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +16 -4
- package/dist/config/schema.js.map +1 -1
- package/dist/config/shot-steps.d.ts +40 -40
- package/dist/footage/caption-highlight.d.ts +44 -0
- package/dist/footage/caption-highlight.d.ts.map +1 -0
- package/dist/footage/caption-highlight.js +29 -0
- package/dist/footage/caption-highlight.js.map +1 -0
- package/dist/footage/compose.d.ts +3 -0
- package/dist/footage/compose.d.ts.map +1 -1
- package/dist/footage/compose.js +33 -6
- package/dist/footage/compose.js.map +1 -1
- package/dist/footage/draft-color.d.ts +6 -0
- package/dist/footage/draft-color.d.ts.map +1 -0
- package/dist/footage/draft-color.js +14 -0
- package/dist/footage/draft-color.js.map +1 -0
- package/dist/footage/draft-overlays.d.ts +12 -0
- package/dist/footage/draft-overlays.d.ts.map +1 -0
- package/dist/footage/draft-overlays.js +83 -0
- package/dist/footage/draft-overlays.js.map +1 -0
- package/dist/footage/draft.d.ts +27 -9
- package/dist/footage/draft.d.ts.map +1 -1
- package/dist/footage/draft.js +99 -37
- package/dist/footage/draft.js.map +1 -1
- package/dist/footage/edl.d.ts +41 -0
- package/dist/footage/edl.d.ts.map +1 -1
- package/dist/footage/edl.js +10 -0
- package/dist/footage/edl.js.map +1 -1
- package/dist/footage/film.d.ts +14 -0
- package/dist/footage/film.d.ts.map +1 -1
- package/dist/footage/film.js +2 -0
- package/dist/footage/film.js.map +1 -1
- package/dist/footage/overlay-html.d.ts +29 -0
- package/dist/footage/overlay-html.d.ts.map +1 -0
- package/dist/footage/overlay-html.js +112 -0
- package/dist/footage/overlay-html.js.map +1 -0
- package/dist/footage/overlay-schema.d.ts +97 -0
- package/dist/footage/overlay-schema.d.ts.map +1 -0
- package/dist/footage/overlay-schema.js +104 -0
- package/dist/footage/overlay-schema.js.map +1 -0
- package/dist/footage/overlays.d.ts +112 -0
- package/dist/footage/overlays.d.ts.map +1 -0
- package/dist/footage/overlays.js +222 -0
- package/dist/footage/overlays.js.map +1 -0
- package/dist/footage/pipeline.d.ts.map +1 -1
- package/dist/footage/pipeline.js +10 -1
- package/dist/footage/pipeline.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/og/index.d.ts +1 -1
- package/dist/og/index.d.ts.map +1 -1
- package/dist/og/index.js +1 -1
- package/dist/og/index.js.map +1 -1
- package/dist/og/photo-cover.d.ts +18 -1
- package/dist/og/photo-cover.d.ts.map +1 -1
- package/dist/og/photo-cover.js +56 -28
- package/dist/og/photo-cover.js.map +1 -1
- package/dist/render/hyperframes.d.ts +1 -1
- package/dist/render/hyperframes.d.ts.map +1 -1
- package/dist/render/hyperframes.js +1 -1
- package/dist/render/hyperframes.js.map +1 -1
- package/package.json +3 -2
- package/schema/edl.schema.json +130 -0
- package/schema/marketing.schema.json +33 -0
- package/src/config/brand.ts +20 -1
- package/src/config/colors.ts +39 -2
- package/src/config/config.ts +2 -0
- package/src/config/schema.ts +19 -7
- package/src/footage/caption-highlight.ts +52 -0
- package/src/footage/compose.ts +40 -6
- package/src/footage/draft-color.ts +12 -0
- package/src/footage/draft-overlays.ts +91 -0
- package/src/footage/draft.ts +117 -39
- package/src/footage/edl.ts +17 -0
- package/src/footage/film.ts +16 -0
- package/src/footage/overlay-html.ts +127 -0
- package/src/footage/overlay-schema.ts +146 -0
- package/src/footage/overlays.ts +272 -0
- package/src/footage/pipeline.ts +8 -1
- package/src/index.ts +56 -1
- package/src/og/index.ts +2 -0
- package/src/og/photo-cover.ts +83 -33
- package/src/render/hyperframes.ts +1 -1
package/src/footage/draft.ts
CHANGED
|
@@ -6,8 +6,13 @@ import type { CaptionLayout, LayoutOverride } from "../compose/timeline.js";
|
|
|
6
6
|
import type { BrandColors } from "../config/colors.js";
|
|
7
7
|
import { err, ok } from "./failure.js";
|
|
8
8
|
import type { TimedWord } from "../voice/voiceover.js";
|
|
9
|
+
import { CAPTION_HIGHLIGHT_BOX_PADDING_EM, CAPTION_HIGHLIGHT_SECONDS, getCaptionHighlight, type CaptionHighlightLook } from "./caption-highlight.js";
|
|
9
10
|
import { getCaptionChunkLayouts, getCaptionSpans, getFootageCaptionChunks, getFootageCaptionLayout, isSameCaptionPlace, type CaptionWordsFilm } from "./captions.js";
|
|
10
11
|
import { getSegmentScales, getSegmentZoomEases } from "./compose.js";
|
|
12
|
+
import { toAssColor } from "./draft-color.js";
|
|
13
|
+
import { buildDraftOverlayEvents, getDraftOverlayStyles } from "./draft-overlays.js";
|
|
14
|
+
import type { OverlayColors } from "./overlay-html.js";
|
|
15
|
+
import { resolveEdlOverlays, type ResolvedOverlay } from "./overlays.js";
|
|
11
16
|
import { chooseFootageDraftFont } from "./draft-font.js";
|
|
12
17
|
import { getEdlDuration, getSegmentStarts, remapWords, type Edl } from "./edl.js";
|
|
13
18
|
import { declickSpeech, describeDeclick, type DeclickReport } from "./declick.js";
|
|
@@ -43,6 +48,8 @@ import { buildMusicArgs, buildSpeechArgs, getSpeechCutOptions } from "./render.j
|
|
|
43
48
|
* before the paid render.
|
|
44
49
|
*/
|
|
45
50
|
|
|
51
|
+
export { toAssColor } from "./draft-color.js";
|
|
52
|
+
|
|
46
53
|
/** The draft's default width: 540 makes a 540×960 draft of a 9:16 film. */
|
|
47
54
|
export const FOOTAGE_DRAFT_WIDTH = 540;
|
|
48
55
|
|
|
@@ -60,9 +67,17 @@ const DRAFT_CRF = 28;
|
|
|
60
67
|
const DRAFT_AUDIO_BITRATE = "128k";
|
|
61
68
|
|
|
62
69
|
/** The caption colours of a `highlight` draft made without a brand. */
|
|
63
|
-
export const FOOTAGE_DRAFT_CAPTION_COLORS = {
|
|
70
|
+
export const FOOTAGE_DRAFT_CAPTION_COLORS = {
|
|
71
|
+
captionBackground: "#111111",
|
|
72
|
+
captionText: "#ffffff",
|
|
73
|
+
captionHighlight: "#ffd400",
|
|
74
|
+
captionHighlightBox: "#ffd400",
|
|
75
|
+
captionHighlightText: "#111111",
|
|
76
|
+
} as const;
|
|
77
|
+
/** The overlays' colours in a draft made without a brand. */
|
|
78
|
+
export const FOOTAGE_DRAFT_OVERLAY_COLORS: OverlayColors = { background: "#111111", foreground: "#ffffff", accent: "#ffd400" };
|
|
64
79
|
/** How long the render keeps a spoken word lit in the `highlight` pill. */
|
|
65
|
-
const HIGHLIGHT_SECONDS =
|
|
80
|
+
const HIGHLIGHT_SECONDS = CAPTION_HIGHLIGHT_SECONDS;
|
|
66
81
|
/** The pill's padding around its text (`CAPTION_PILL_PADDING.y`): the opaque box's border in the film's frame. */
|
|
67
82
|
const HIGHLIGHT_BOX_PADDING = 16;
|
|
68
83
|
|
|
@@ -85,19 +100,6 @@ function toAssTime(seconds: number): string {
|
|
|
85
100
|
return `${hours}:${pad(minutes)}:${pad(secs)}.${pad(centiseconds % 100)}`;
|
|
86
101
|
}
|
|
87
102
|
|
|
88
|
-
/**
|
|
89
|
-
* A hex colour (`#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`) as an ASS colour, `&HAABBGGRR&`-style without the closing
|
|
90
|
-
* `&`: ASS writes blue first and counts alpha the other way round (00 is opaque).
|
|
91
|
-
*/
|
|
92
|
-
export function toAssColor(hex: string): string {
|
|
93
|
-
const digits = hex.replace(/^#/, "");
|
|
94
|
-
const full = digits.length <= 4 ? [...digits].map((digit) => digit + digit).join("") : digits;
|
|
95
|
-
if (!/^(?:[0-9a-f]{6}|[0-9a-f]{8})$/i.test(full)) throw new Error(`Not a hex colour: "${hex}".`);
|
|
96
|
-
const pair = (index: number): string => full.slice(index, index + 2).toUpperCase();
|
|
97
|
-
const alpha = full.length === 8 ? (255 - parseInt(full.slice(6, 8), 16)).toString(16).padStart(2, "0").toUpperCase() : "00";
|
|
98
|
-
return `&H${alpha}${pair(4)}${pair(2)}${pair(0)}`;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
103
|
/**
|
|
102
104
|
* Caption text as ASS dialogue: override braces and backslashes would be read as tags, line breaks end the line. A
|
|
103
105
|
* no-break space (U+00A0) becomes ASS's hard space `\h`, which libass never breaks a line at, as the render's HTML.
|
|
@@ -113,10 +115,10 @@ function toAssText(text: string): string {
|
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
/** The caption colours the draft paints with (`BrandColors`). */
|
|
116
|
-
export type FootageDraftCaptionColors = Pick<BrandColors, "captionBackground" | "captionText" | "captionHighlight">;
|
|
118
|
+
export type FootageDraftCaptionColors = Pick<BrandColors, "captionBackground" | "captionText" | "captionHighlight" | "captionHighlightBox" | "captionHighlightText">;
|
|
117
119
|
|
|
118
120
|
export interface FootageDraftCaptionsInput {
|
|
119
|
-
film: Pick<FootageFilm, "captions" | "captionStyle"> & CaptionWordsFilm;
|
|
121
|
+
film: Pick<FootageFilm, "captions" | "captionStyle" | "captionHighlightStyle"> & CaptionWordsFilm;
|
|
120
122
|
edl: Edl;
|
|
121
123
|
/** The film's words in film time (`remapWords`). */
|
|
122
124
|
words: TimedWord[];
|
|
@@ -128,6 +130,19 @@ export interface FootageDraftCaptionsInput {
|
|
|
128
130
|
fontFamily?: string;
|
|
129
131
|
/** The `highlight` pill's colours; default `FOOTAGE_DRAFT_CAPTION_COLORS`. A `phrase` caption is white, as in the render. */
|
|
130
132
|
colors?: FootageDraftCaptionColors;
|
|
133
|
+
/** The EDL's overlays, resolved (`resolveEdlOverlays`), drawn over the captions' layers; absent: none. */
|
|
134
|
+
overlays?: ResolvedOverlay[];
|
|
135
|
+
/** The overlays' card, text and accent colours; default `FOOTAGE_DRAFT_OVERLAY_COLORS`. */
|
|
136
|
+
overlayColors?: OverlayColors;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** The pieces of a `highlight` chunk's span: cut wherever a word lights up or goes out (in centiseconds), with the words lit in each. */
|
|
140
|
+
function getHighlightPieces(chunk: { words: TimedWord[] }, span: { start: number; end: number }): { from: number; to: number; lit: boolean[] }[] {
|
|
141
|
+
const cs = (seconds: number): number => Math.round(seconds * 100);
|
|
142
|
+
const [from, to] = [cs(span.start), cs(span.end)];
|
|
143
|
+
const lights = chunk.words.map((word) => ({ on: cs(word.start), off: cs(word.start + HIGHLIGHT_SECONDS) }));
|
|
144
|
+
const cuts = [...new Set([from, to, ...lights.flatMap((light) => [light.on, light.off])])].filter((at) => at >= from && at <= to).sort((a, b) => a - b);
|
|
145
|
+
return cuts.slice(0, -1).map((at, index) => ({ from: at, to: cuts[index + 1] as number, lit: lights.map((light) => light.on <= at && at < light.off) }));
|
|
131
146
|
}
|
|
132
147
|
|
|
133
148
|
/**
|
|
@@ -135,23 +150,36 @@ export interface FootageDraftCaptionsInput {
|
|
|
135
150
|
* with the words lit then in `highlight` (a word stays lit for the render's 0.32 s from its start).
|
|
136
151
|
*/
|
|
137
152
|
function buildHighlightEvents(chunk: { words: TimedWord[] }, span: { start: number; end: number }, colors: { text: string; highlight: string }, styleName: string): string[] {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const cuts = [...new Set([from, to, ...lights.flatMap((light) => [light.on, light.off])])].filter((at) => at >= from && at <= to).sort((a, b) => a - b);
|
|
142
|
-
const events: string[] = [];
|
|
143
|
-
cuts.slice(0, -1).forEach((at, index) => {
|
|
144
|
-
const next = cuts[index + 1] as number;
|
|
145
|
-
const text = chunk.words
|
|
146
|
-
.map((word, wordIndex) => {
|
|
147
|
-
const light = lights[wordIndex] as { on: number; off: number };
|
|
148
|
-
const shown = toAssText(word.text);
|
|
149
|
-
return light.on <= at && at < light.off ? `{\\1c${colors.highlight}&}${shown}{\\1c${colors.text}&}` : shown;
|
|
150
|
-
})
|
|
151
|
-
.join(" ");
|
|
152
|
-
events.push(`Dialogue: 0,${toAssTime(at / 100)},${toAssTime(next / 100)},${styleName},,0,0,0,,${text}`);
|
|
153
|
+
return getHighlightPieces(chunk, span).map((piece) => {
|
|
154
|
+
const text = chunk.words.map((word, wordIndex) => (piece.lit[wordIndex] === true ? `{\\1c${colors.highlight}&}${toAssText(word.text)}{\\1c${colors.text}&}` : toAssText(word.text))).join(" ");
|
|
155
|
+
return `Dialogue: 0,${toAssTime(piece.from / 100)},${toAssTime(piece.to / 100)},${styleName},,0,0,0,,${text}`;
|
|
153
156
|
});
|
|
154
|
-
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* A `box` highlight chunk as ASS events (issue #1199), three layers per piece of its span. libass draws a
|
|
161
|
+
* `BorderStyle 3` box per glyph, in each glyph's own `\3c` and `\3a`, so the layers share one layout: 0 is the pill
|
|
162
|
+
* (its text hidden), 1 the lit word's box (every other glyph's box transparent, grown by `boxPadding` instead of the
|
|
163
|
+
* pill's), 2 the text alone (no box) with the lit word in its box text colour.
|
|
164
|
+
*/
|
|
165
|
+
function buildHighlightBoxEvents(chunk: { words: TimedWord[] }, span: { start: number; end: number }, colors: { text: string; box: string; boxText: string }, boxPadding: number, styleName: string): string[] {
|
|
166
|
+
return getHighlightPieces(chunk, span).flatMap((piece) => {
|
|
167
|
+
const at = `${toAssTime(piece.from / 100)},${toAssTime(piece.to / 100)},${styleName},,0,0,0,,`;
|
|
168
|
+
const shown = chunk.words.map((word) => toAssText(word.text));
|
|
169
|
+
const pill = `{\\1a&HFF&}${shown.join(" ")}`;
|
|
170
|
+
const box = `{\\1a&HFF&\\bord${boxPadding}\\3a&HFF&}${shown.map((text, index) => (piece.lit[index] === true ? `{\\3c${colors.box}&\\3a&H00&}${text}{\\3a&HFF&}` : text)).join(" ")}`;
|
|
171
|
+
const text = `{\\3a&HFF&\\4a&HFF&}${shown.map((word, index) => (piece.lit[index] === true ? `{\\1c${colors.boxText}&}${word}{\\1c${colors.text}&}` : word)).join(" ")}`;
|
|
172
|
+
const isLit = piece.lit.some((lit) => lit);
|
|
173
|
+
return [`Dialogue: 0,${at}${pill}`, ...(isLit ? [`Dialogue: 1,${at}${box}`] : []), `Dialogue: 2,${at}${text}`];
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** The highlight look the draft draws: `text` for a `phrase` film; a `box` film without its colours is an input error. */
|
|
178
|
+
function getDraftHighlightLook(film: Pick<FootageFilm, "captionStyle" | "captionHighlightStyle">, colors: FootageDraftCaptionColors): CaptionHighlightLook {
|
|
179
|
+
if (film.captionStyle !== "highlight") return { style: "text", color: colors.captionHighlight };
|
|
180
|
+
const highlight = getCaptionHighlight(film, colors);
|
|
181
|
+
if (!highlight.ok) throw new Error(`buildFootageDraftCaptions: ${highlight.error}`);
|
|
182
|
+
return highlight.look;
|
|
155
183
|
}
|
|
156
184
|
|
|
157
185
|
/**
|
|
@@ -163,10 +191,11 @@ function buildHighlightEvents(chunk: { words: TimedWord[] }, span: { start: numb
|
|
|
163
191
|
* captions or nothing is said.
|
|
164
192
|
*/
|
|
165
193
|
export function buildFootageDraftCaptions(input: FootageDraftCaptionsInput): string | null {
|
|
166
|
-
|
|
194
|
+
const overlays = input.overlays ?? [];
|
|
167
195
|
const isHighlight = input.film.captionStyle === "highlight";
|
|
168
|
-
|
|
169
|
-
|
|
196
|
+
// No chunks without captions (`getFootageCaptionChunks`): then only the overlays, if any, make the file.
|
|
197
|
+
const chunks = input.film.captions ? getFootageCaptionChunks(input.film, input.words) : [];
|
|
198
|
+
if (chunks.length === 0 && overlays.length === 0) return null;
|
|
170
199
|
const spans = getCaptionSpans(chunks, getEdlDuration(input.edl));
|
|
171
200
|
const { caption, frame } = input;
|
|
172
201
|
const family = (input.fontFamily ?? FOOTAGE_DRAFT_FONT.family).replace(/,/g, " ");
|
|
@@ -223,9 +252,13 @@ export function buildFootageDraftCaptions(input: FootageDraftCaptionsInput): str
|
|
|
223
252
|
return `Caption${index + 2}`;
|
|
224
253
|
});
|
|
225
254
|
const highlight = { text: text.replace(/^&H../, "&H"), highlight: toAssColor(colors.captionHighlight).replace(/^&H../, "&H") };
|
|
255
|
+
const lit = getDraftHighlightLook(input.film, colors);
|
|
256
|
+
const boxColors = lit.style === "box" ? { text: highlight.text, box: toAssColor(lit.box).replace(/^&H../, "&H"), boxText: toAssColor(lit.text).replace(/^&H../, "&H") } : null;
|
|
257
|
+
const boxPadding = Math.max(1, Math.round(caption.fontSize * CAPTION_HIGHLIGHT_BOX_PADDING_EM));
|
|
226
258
|
const events = chunks.flatMap((chunk, index) => {
|
|
227
259
|
const span = spans[index] as { start: number; end: number };
|
|
228
260
|
const styleName = styleNames[index] ?? "Caption";
|
|
261
|
+
if (isHighlight && boxColors !== null) return buildHighlightBoxEvents(chunk, span, boxColors, boxPadding, styleName);
|
|
229
262
|
if (isHighlight) return buildHighlightEvents(chunk, span, highlight, styleName);
|
|
230
263
|
const line = toAssText(chunk.words.map((word) => word.text).join(" "));
|
|
231
264
|
return [`Dialogue: 0,${toAssTime(span.start)},${toAssTime(span.end)},${styleName},,0,0,0,,${line}`];
|
|
@@ -241,10 +274,12 @@ export function buildFootageDraftCaptions(input: FootageDraftCaptionsInput): str
|
|
|
241
274
|
"[V4+ Styles]",
|
|
242
275
|
"Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding",
|
|
243
276
|
...styles.map((style) => `Style: ${style}`),
|
|
277
|
+
...(overlays.length === 0 ? [] : getDraftOverlayStyles(family, input.overlayColors ?? FOOTAGE_DRAFT_OVERLAY_COLORS)),
|
|
244
278
|
"",
|
|
245
279
|
"[Events]",
|
|
246
280
|
"Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text",
|
|
247
281
|
...events,
|
|
282
|
+
...buildDraftOverlayEvents(overlays, input.overlayColors ?? FOOTAGE_DRAFT_OVERLAY_COLORS, input.frame),
|
|
248
283
|
"",
|
|
249
284
|
].join("\n");
|
|
250
285
|
}
|
|
@@ -269,6 +304,8 @@ export interface FootageDraftArgsInput {
|
|
|
269
304
|
width?: number;
|
|
270
305
|
/** The ASS captions file (`buildFootageDraftCaptions`), or null for none. */
|
|
271
306
|
captions: string | null;
|
|
307
|
+
/** The EDL's resolved overlays: their `punch_in` zooms are drawn into the picture (the rest is in the ASS file). */
|
|
308
|
+
overlays?: readonly ResolvedOverlay[];
|
|
272
309
|
/** The folder libass loads the captions' font from, or null for the system's fonts. */
|
|
273
310
|
fontsDir: string | null;
|
|
274
311
|
output: string;
|
|
@@ -297,13 +334,18 @@ export interface DraftSegmentPlan {
|
|
|
297
334
|
startScale: number;
|
|
298
335
|
/** The frames the zoom eases over (`getSegmentZoomEases`); 0: the segment starts at `scale`. */
|
|
299
336
|
easeFrames: number;
|
|
337
|
+
/**
|
|
338
|
+
* The EDL's `punch_in` overlays in this segment, in frames from its start: each multiplies the zoom by up to `scale`,
|
|
339
|
+
* rising over `ease` frames from `from` and falling over the last `ease` of its `frames` (linear, the render eases).
|
|
340
|
+
*/
|
|
341
|
+
punches: { from: number; frames: number; ease: number; scale: number }[];
|
|
300
342
|
}
|
|
301
343
|
|
|
302
344
|
/**
|
|
303
345
|
* How each segment plays in the draft. A `fade` cut lasts the film's `fadeFrames` (clamped to the incoming segment, so
|
|
304
346
|
* the cross-fade never outlasts it) and the outgoing segment runs on under it, as in the render.
|
|
305
347
|
*/
|
|
306
|
-
export function planFootageDraft(film: Pick<FootageFilm, "edit">, edl: Edl): DraftSegmentPlan[] {
|
|
348
|
+
export function planFootageDraft(film: Pick<FootageFilm, "edit">, edl: Edl, overlays: readonly ResolvedOverlay[] = []): DraftSegmentPlan[] {
|
|
307
349
|
const edit = getFootageEdit(film);
|
|
308
350
|
const fadeSeconds = r3(edit.fadeFrames / FOOTAGE_FPS);
|
|
309
351
|
const kenBurnsScale = 1 + (edit.kenBurnsPercent > 0 ? edit.kenBurnsPercent : HAND_KEN_BURNS_PERCENT) / 100;
|
|
@@ -322,6 +364,18 @@ export function planFootageDraft(film: Pick<FootageFilm, "edit">, edl: Edl): Dra
|
|
|
322
364
|
endScale: segment.motion === "kenburns" ? r4(scale * kenBurnsScale) : scale,
|
|
323
365
|
startScale: (eases[index] as number) > 0 ? (scales[index - 1] as number) : scale,
|
|
324
366
|
easeFrames: eases[index] as number,
|
|
367
|
+
punches: overlays.flatMap((overlay) =>
|
|
368
|
+
overlay.kind === "punch_in" && overlay.segment === index
|
|
369
|
+
? [
|
|
370
|
+
{
|
|
371
|
+
from: Math.round((overlay.start - (starts[index] as number)) * FOOTAGE_FPS),
|
|
372
|
+
frames: Math.round((overlay.end - overlay.start) * FOOTAGE_FPS),
|
|
373
|
+
ease: Math.max(1, Math.round(overlay.ease * FOOTAGE_FPS)),
|
|
374
|
+
scale: overlay.scale,
|
|
375
|
+
},
|
|
376
|
+
]
|
|
377
|
+
: [],
|
|
378
|
+
),
|
|
325
379
|
};
|
|
326
380
|
});
|
|
327
381
|
}
|
|
@@ -334,6 +388,18 @@ function buildPictureFilters(plan: DraftSegmentPlan, draft: Frame): string[] {
|
|
|
334
388
|
const size = `${draft.width}:${draft.height}`;
|
|
335
389
|
const zoompan = (zoom: string): string =>
|
|
336
390
|
`zoompan=z='${zoom}':x='(iw-iw/zoom)*${ZOOM_ORIGIN.x}':y='(ih-ih/zoom)*${ZOOM_ORIGIN.y}':d=1:s=${draft.width}x${draft.height}:fps=${FOOTAGE_FPS}`;
|
|
391
|
+
if (plan.punches.length > 0) {
|
|
392
|
+
// The segment's own zoom (an eased cut, Ken Burns or still) times each punch-in's rise, hold and fall.
|
|
393
|
+
const frames = Math.max(1, Math.round(plan.length * FOOTAGE_FPS));
|
|
394
|
+
const own =
|
|
395
|
+
plan.easeFrames > 0
|
|
396
|
+
? `${plan.startScale}+(${r4(plan.scale - plan.startScale)})*(1-pow(1-min(on/${plan.easeFrames},1),2))`
|
|
397
|
+
: plan.endScale !== plan.scale
|
|
398
|
+
? `${plan.scale}+${r4(plan.endScale - plan.scale)}*min(on/${frames},1)`
|
|
399
|
+
: `${plan.scale}`;
|
|
400
|
+
const lifts = plan.punches.map((punch) => `${r4(punch.scale - 1)}*max(0,min(min(1,(on-${punch.from})/${punch.ease}),(${punch.from + punch.frames}-on)/${punch.ease}))`);
|
|
401
|
+
return [zoompan(`(${own})*(1+${lifts.join("+")})`)];
|
|
402
|
+
}
|
|
337
403
|
if (plan.easeFrames > 0) {
|
|
338
404
|
return [zoompan(`${plan.startScale}+(${r4(plan.scale - plan.startScale)})*(1-pow(1-min(on/${plan.easeFrames},1),2))`)];
|
|
339
405
|
}
|
|
@@ -358,7 +424,7 @@ function buildPictureFilters(plan: DraftSegmentPlan, draft: Frame): string[] {
|
|
|
358
424
|
export function buildFootageDraftArgs(input: FootageDraftArgsInput): string[] {
|
|
359
425
|
const { edl } = input;
|
|
360
426
|
const draft = getFootageDraftFrame(input.frame, input.width);
|
|
361
|
-
const plans = planFootageDraft(input.film, edl);
|
|
427
|
+
const plans = planFootageDraft(input.film, edl, input.overlays ?? []);
|
|
362
428
|
const threads = getThreadArgs(input.threads, "draft.threads");
|
|
363
429
|
const inputs: string[] = [];
|
|
364
430
|
const parts: string[] = [];
|
|
@@ -453,7 +519,7 @@ export interface RenderFootageDraftOptions extends Pick<FootageRunOptions, "buil
|
|
|
453
519
|
* OpenType file; DejaVu Sans when it has none) and its caption colours. Without it, DejaVu Sans and
|
|
454
520
|
* `FOOTAGE_DRAFT_CAPTION_COLORS`.
|
|
455
521
|
*/
|
|
456
|
-
brand?: { colors: FootageDraftCaptionColors
|
|
522
|
+
brand?: { colors: FootageDraftCaptionColors & Partial<OverlayColors>; fonts: Pick<FootageBrand["fonts"], "body"> };
|
|
457
523
|
/**
|
|
458
524
|
* ffmpeg's threads for the draft's decoders, filter graph and encoder (`buildFootageDraftArgs`); by default ffmpeg's
|
|
459
525
|
* own choice, which follows the host's cores. Set it from a CPU-limited container's quota.
|
|
@@ -528,6 +594,8 @@ async function runRenderFootageDraft(
|
|
|
528
594
|
): Promise<FootageResult<FootageDraft>> {
|
|
529
595
|
const { log, signal } = options;
|
|
530
596
|
const aborting = signal === undefined ? {} : { signal };
|
|
597
|
+
const highlight = film.captions && film.captionStyle === "highlight" ? getCaptionHighlight(film, options.brand?.colors ?? FOOTAGE_DRAFT_CAPTION_COLORS) : null;
|
|
598
|
+
if (highlight !== null && !highlight.ok) return err(`footage film ${film.id}: ${highlight.error}`, { kind: "input" });
|
|
531
599
|
const seconds = getEdlDuration(edl);
|
|
532
600
|
const music = await findDraftMusic(film, edl, clips, options);
|
|
533
601
|
if (!music.ok) return music;
|
|
@@ -555,6 +623,14 @@ async function runRenderFootageDraft(
|
|
|
555
623
|
const { rawSpeechFile, declickedFile, speechFile } = getSpeechChainFiles(draftDir, { isDeclick: declickLevel !== "off", isLoudness: loudness !== null });
|
|
556
624
|
const words = remapWords(edl, transcript.words, film.cut.fillers);
|
|
557
625
|
const frame = getFrame(film);
|
|
626
|
+
const resolved = resolveEdlOverlays({ film, edl, words, frame, caption: getFootageCaptionLayout(film, options.layout ?? {}) });
|
|
627
|
+
if (!resolved.ok) return err(`footage film ${film.id}: the EDL's overlays cannot be drawn: ${resolved.problems.join("; ")}`, { kind: "input" });
|
|
628
|
+
const overlays = resolved.overlays;
|
|
629
|
+
const brandColors = options.brand?.colors;
|
|
630
|
+
const overlayColors =
|
|
631
|
+
brandColors?.background !== undefined && brandColors.foreground !== undefined && brandColors.accent !== undefined
|
|
632
|
+
? { background: brandColors.background, foreground: brandColors.foreground, accent: brandColors.accent }
|
|
633
|
+
: FOOTAGE_DRAFT_OVERLAY_COLORS;
|
|
558
634
|
const brandFont = chooseFootageDraftFont(options.brand?.fonts.body ?? null);
|
|
559
635
|
const font = brandFont ?? FOOTAGE_DRAFT_FONT;
|
|
560
636
|
const captions = buildFootageDraftCaptions({
|
|
@@ -565,6 +641,7 @@ async function runRenderFootageDraft(
|
|
|
565
641
|
frame,
|
|
566
642
|
fontFamily: font.family,
|
|
567
643
|
...(options.brand === undefined ? {} : { colors: options.brand.colors }),
|
|
644
|
+
...(overlays.length === 0 ? {} : { overlays, overlayColors }),
|
|
568
645
|
});
|
|
569
646
|
if (captions !== null) {
|
|
570
647
|
writeFileSync(join(draftDir, "captions.ass"), captions);
|
|
@@ -628,6 +705,7 @@ async function runRenderFootageDraft(
|
|
|
628
705
|
...(options.width === undefined ? {} : { width: options.width }),
|
|
629
706
|
...(options.threads === undefined ? {} : { threads: options.threads }),
|
|
630
707
|
captions: captions === null ? null : "captions.ass",
|
|
708
|
+
...(overlays.length === 0 ? {} : { overlays }),
|
|
631
709
|
fontsDir: captions === null ? null : "fonts",
|
|
632
710
|
output,
|
|
633
711
|
});
|
package/src/footage/edl.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
3
|
import type { TimedWord } from "../voice/voiceover.js";
|
|
4
|
+
import { overlaySchema, type EdlOverlay } from "./overlay-schema.js";
|
|
4
5
|
import { CUT_TRANSITIONS, type ClipRole, type CutOptions, type CutTransition, type FootageTransitions } from "./film.js";
|
|
5
6
|
import { splitFilmSentences, type Sentence } from "./sentences.js";
|
|
6
7
|
import { isFiller } from "./words.js";
|
|
@@ -57,6 +58,11 @@ export interface Edl {
|
|
|
57
58
|
version: 2;
|
|
58
59
|
film: string;
|
|
59
60
|
segments: EdlSegment[];
|
|
61
|
+
/**
|
|
62
|
+
* Small graphics and emphasis zooms on words of the transcript (`overlays.ts`, issue #1200); absent or empty: none,
|
|
63
|
+
* and the film is drawn as without the field.
|
|
64
|
+
*/
|
|
65
|
+
overlays?: EdlOverlay[];
|
|
60
66
|
}
|
|
61
67
|
|
|
62
68
|
const SEGMENT_ID_PATTERN = /^[A-Za-z0-9._-]+$/;
|
|
@@ -98,6 +104,13 @@ export const edlSchema = z
|
|
|
98
104
|
)
|
|
99
105
|
.min(1, "the cut needs at least one segment")
|
|
100
106
|
.describe("The kept parts of the clips, in film order."),
|
|
107
|
+
overlays: z
|
|
108
|
+
.array(overlaySchema)
|
|
109
|
+
.max(40)
|
|
110
|
+
.optional()
|
|
111
|
+
.describe(
|
|
112
|
+
"Small graphics and emphasis zooms placed on a word of the transcript (at_word) or a film second (at), one at a time, each inside one segment: punch_in, keyword, lower_third, list, arrow, highlight. Without it, none.",
|
|
113
|
+
),
|
|
101
114
|
})
|
|
102
115
|
.describe("The edit decision list of a footage film (edl.json).");
|
|
103
116
|
|
|
@@ -371,6 +384,10 @@ export function diffEdl(before: Edl, after: Edl): string[] {
|
|
|
371
384
|
if (previous === undefined || isSameCaption(previous.caption, segment.caption)) continue;
|
|
372
385
|
lines.push(isMovedCaption(segment.caption) ? `${segment.id} captions moved` : `${segment.id} captions back in the film's box`);
|
|
373
386
|
}
|
|
387
|
+
const [overlaysBefore, overlaysAfter] = [before.overlays ?? [], after.overlays ?? []];
|
|
388
|
+
if (JSON.stringify(overlaysBefore) !== JSON.stringify(overlaysAfter)) {
|
|
389
|
+
lines.push(`overlays: ${overlaysAfter.map((overlay) => overlay.kind.replace("_", " ")).join(", ") || "none"} (was ${overlaysBefore.length})`);
|
|
390
|
+
}
|
|
374
391
|
for (const segment of after.segments) {
|
|
375
392
|
const was = old.get(segment.id)?.audio;
|
|
376
393
|
const { audio } = segment;
|
package/src/footage/film.ts
CHANGED
|
@@ -125,6 +125,12 @@ export interface FootageFilm {
|
|
|
125
125
|
captions: boolean;
|
|
126
126
|
/** `phrase` (the default): 2-6 words of plain text with a soft shadow; `highlight`: a pill that lights each word as it is said. */
|
|
127
127
|
captionStyle?: CaptionStyle;
|
|
128
|
+
/**
|
|
129
|
+
* How a `highlight` caption lights the word being said: `text` (the default) colours its text `captionHighlight`;
|
|
130
|
+
* `box` puts it on a rounded box of `captionHighlightBox` with its text in `captionHighlightText` (both brand colours
|
|
131
|
+
* then required). Ignored by `phrase` captions.
|
|
132
|
+
*/
|
|
133
|
+
captionHighlightStyle?: CaptionHighlightStyle;
|
|
128
134
|
/** Places the 9:16 caption box inside a platform's safe zone (`CAPTION_SAFE_ZONES`); absent: the layout as it is. */
|
|
129
135
|
captionPreset?: CaptionPreset;
|
|
130
136
|
/**
|
|
@@ -138,6 +144,11 @@ export interface FootageFilm {
|
|
|
138
144
|
* empty: numbers only.
|
|
139
145
|
*/
|
|
140
146
|
captionKeepWithNext?: string[];
|
|
147
|
+
/**
|
|
148
|
+
* The least time between the starts of two EDL overlays, in seconds (the app's own budget, e.g. 8 for one in about
|
|
149
|
+
* 8 s); absent: only one overlay at a time.
|
|
150
|
+
*/
|
|
151
|
+
overlayMinSpacing?: number;
|
|
141
152
|
/** The cut's look: zoom size, fade length, Ken Burns, the end card's whoosh. Absent fields take `DEFAULT_EDIT`. */
|
|
142
153
|
edit?: Partial<FootageEdit>;
|
|
143
154
|
/** The closing card after the last segment (`FootageEndCard`); null: the film ends with its last segment. */
|
|
@@ -259,6 +270,11 @@ export const CAPTION_STYLES = ["phrase", "highlight"] as const;
|
|
|
259
270
|
|
|
260
271
|
export type CaptionStyle = (typeof CAPTION_STYLES)[number];
|
|
261
272
|
|
|
273
|
+
/** How a `highlight` caption lights the word being said: its text colour, or a box behind it (issue #1199). */
|
|
274
|
+
export const CAPTION_HIGHLIGHT_STYLES = ["text", "box"] as const;
|
|
275
|
+
|
|
276
|
+
export type CaptionHighlightStyle = (typeof CAPTION_HIGHLIGHT_STYLES)[number];
|
|
277
|
+
|
|
262
278
|
/** The smallest a caption line limit shrinks a card's font to, as a share of the caption box's size. */
|
|
263
279
|
export const CAPTION_MIN_FONT_SCALE = 0.7;
|
|
264
280
|
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { BrandColors } from "../config/colors.js";
|
|
2
|
+
import { escapeHtml } from "../compose/html.js";
|
|
3
|
+
import { OVERLAY_LINE_HEIGHT, OVERLAY_LIST_LINE_HEIGHT, OVERLAY_PADDING_EM, type ResolvedOverlay } from "./overlays.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The render's overlays (issue #1200): HTML, CSS and GSAP tweens for the HyperFrames composition, every look in the
|
|
7
|
+
* brand's colours and fonts and every element a local clip (no network at render time).
|
|
8
|
+
*
|
|
9
|
+
* The motion is adapted from HyperFrames registry blocks (Apache-2.0, https://github.com/heygen-com/hyperframes):
|
|
10
|
+
* `lt-soft-pill` (the lower third's scale-pop pill, dot and settling text), `marker-highlight` (the stroke drawn over
|
|
11
|
+
* its target), `hw-arrow` (the drawn-on arrow whose head arrives last) and `push-in` (the eased camera push, in
|
|
12
|
+
* `composeFootage`). They are rewritten for the kit's frame, timeline and brand tokens: see the package's NOTICE.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** The seconds an overlay takes to leave, ending with its clip. */
|
|
16
|
+
const EXIT_SECONDS = 0.3;
|
|
17
|
+
/** An arrow's or a highlight's stroke, in px of a 1080 px wide frame. */
|
|
18
|
+
const STROKE_WIDTH = 10;
|
|
19
|
+
/** The arrow head's length, in px of a 1080 px wide frame. */
|
|
20
|
+
const ARROW_HEAD = 46;
|
|
21
|
+
|
|
22
|
+
const r3 = (value: number): number => Math.round(value * 1000) / 1000 || 0;
|
|
23
|
+
|
|
24
|
+
export interface OverlayMarkup {
|
|
25
|
+
html: string[];
|
|
26
|
+
css: string[];
|
|
27
|
+
tweens: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The brand's colours an overlay paints with: its card, its text, its accent (the dot, the arrow, the marker). */
|
|
31
|
+
export type OverlayColors = Pick<BrandColors, "background" | "foreground" | "accent">;
|
|
32
|
+
|
|
33
|
+
/** The CSS every overlay kind shares, written once when the film has any drawn overlay. */
|
|
34
|
+
function getOverlayCss(colors: OverlayColors, headingFont: string): string[] {
|
|
35
|
+
return [
|
|
36
|
+
`.ov{position:absolute;display:flex;pointer-events:none}`,
|
|
37
|
+
`.ov.right{justify-content:flex-end}`,
|
|
38
|
+
`.ov-card{display:flex;align-items:center;gap:.45em;padding:${OVERLAY_PADDING_EM.y}em ${OVERLAY_PADDING_EM.x}em;border-radius:.42em;background:${colors.background};color:${colors.foreground};box-shadow:0 14px 44px rgba(0,0,0,.35);line-height:${OVERLAY_LINE_HEIGHT};font-weight:700;letter-spacing:-.015em;max-width:100%;overflow-wrap:anywhere;transform-origin:0% 100%}`,
|
|
39
|
+
`.ov.right .ov-card{transform-origin:100% 100%}`,
|
|
40
|
+
`.ov-keyword .ov-card{font-family:${headingFont};border-bottom:.12em solid ${colors.accent}}`,
|
|
41
|
+
`.ov-dot{flex:none;width:.36em;height:.36em;border-radius:50%;background:${colors.accent}}`,
|
|
42
|
+
`.ov-list .ov-card{flex-direction:column;align-items:flex-start;gap:0;line-height:${OVERLAY_LIST_LINE_HEIGHT};font-weight:650}`,
|
|
43
|
+
`.ov-list li{display:flex;align-items:center;gap:.45em;list-style:none}`,
|
|
44
|
+
`.ov-svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}`,
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The SVG path of an arrow from `from` to `to`: a gentle curve bowed to one side, and its head's two strokes. */
|
|
49
|
+
export function getArrowPaths(overlay: Extract<ResolvedOverlay, { kind: "arrow" }>, scale: number): { curve: string; head: string } {
|
|
50
|
+
const { from, to } = overlay;
|
|
51
|
+
const [dx, dy] = [to.x - from.x, to.y - from.y];
|
|
52
|
+
const length = Math.hypot(dx, dy) || 1;
|
|
53
|
+
// The control point sits off the middle by a fifth of the length, on the left of the travel (a hand-drawn bow).
|
|
54
|
+
const bow = 0.2 * length;
|
|
55
|
+
const control = { x: from.x + dx / 2 + (dy / length) * bow, y: from.y + dy / 2 - (dx / length) * bow };
|
|
56
|
+
const angle = Math.atan2(to.y - control.y, to.x - control.x);
|
|
57
|
+
const head = ARROW_HEAD * scale;
|
|
58
|
+
const wing = (turn: number) => ({ x: to.x - head * Math.cos(angle + turn), y: to.y - head * Math.sin(angle + turn) });
|
|
59
|
+
const [left, right] = [wing(Math.PI / 6), wing(-Math.PI / 6)];
|
|
60
|
+
const f = (value: number) => String(r3(value));
|
|
61
|
+
return {
|
|
62
|
+
curve: `M${f(from.x)} ${f(from.y)} Q${f(control.x)} ${f(control.y)} ${f(to.x)} ${f(to.y)}`,
|
|
63
|
+
head: `M${f(left.x)} ${f(left.y)} L${f(to.x)} ${f(to.y)} L${f(right.x)} ${f(right.y)}`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The drawn overlays' markup, CSS and tweens (a `punch_in` draws nothing: `composeFootage` zooms the picture). Each
|
|
69
|
+
* overlay is a clip shown for its own span, entering at its start and leaving over its last 0.3 s.
|
|
70
|
+
*/
|
|
71
|
+
export function getOverlayMarkup(overlays: readonly ResolvedOverlay[], input: { colors: OverlayColors; headingFont: string; frame: { width: number; height: number } }): OverlayMarkup {
|
|
72
|
+
const drawn = overlays.filter((overlay) => overlay.kind !== "punch_in");
|
|
73
|
+
if (drawn.length === 0) return { html: [], css: [], tweens: [] };
|
|
74
|
+
const { colors, frame } = input;
|
|
75
|
+
const scale = frame.width / 1080;
|
|
76
|
+
const stroke = r3(STROKE_WIDTH * scale);
|
|
77
|
+
const html: string[] = [];
|
|
78
|
+
const tweens: string[] = [];
|
|
79
|
+
for (const overlay of drawn) {
|
|
80
|
+
const id = `ov${overlay.index}`;
|
|
81
|
+
const duration = r3(overlay.end - overlay.start);
|
|
82
|
+
const exitAt = r3(overlay.end - EXIT_SECONDS);
|
|
83
|
+
const clip = (classes: string, style: string, body: string) =>
|
|
84
|
+
`<div id="${id}" class="clip ${classes}" data-start="${overlay.start}" data-duration="${duration}" style="${style}">${body}</div>`;
|
|
85
|
+
if (overlay.kind === "keyword" || overlay.kind === "lower_third" || overlay.kind === "list") {
|
|
86
|
+
const { box, fontSize, side } = overlay;
|
|
87
|
+
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"}`;
|
|
88
|
+
const body =
|
|
89
|
+
overlay.kind === "list"
|
|
90
|
+
? `<ul class="ov-card">${overlay.items.map((item, i) => `<li id="${id}i${i}"><i class="ov-dot"></i>${escapeHtml(item)}</li>`).join("")}</ul>`
|
|
91
|
+
: `<div class="ov-card">${overlay.kind === "lower_third" ? `<i class="ov-dot" id="${id}d"></i>` : ""}<span id="${id}t">${escapeHtml(overlay.text)}</span></div>`;
|
|
92
|
+
html.push(clip(`ov ov-${overlay.kind.replace("_", "-")}${side === "right" ? " right" : ""}`, style, body));
|
|
93
|
+
// The soft pill's entrance: the card pops up from its foot, then its dot and its text settle in.
|
|
94
|
+
tweens.push(`tl.fromTo("#${id} .ov-card", { scale: 0.88, y: 18, opacity: 0 }, { scale: 1, y: 0, opacity: 1, duration: 0.45, ease: "back.out(1.7)", immediateRender: false }, ${overlay.start});`);
|
|
95
|
+
if (overlay.kind === "lower_third") {
|
|
96
|
+
tweens.push(`tl.fromTo("#${id}d", { scale: 0 }, { scale: 1, duration: 0.35, ease: "back.out(3)", immediateRender: false }, ${r3(overlay.start + 0.25)});`);
|
|
97
|
+
tweens.push(`tl.fromTo("#${id}t", { opacity: 0, x: -10 }, { opacity: 1, x: 0, duration: 0.4, ease: "power3.out", immediateRender: false }, ${r3(overlay.start + 0.3)});`);
|
|
98
|
+
}
|
|
99
|
+
if (overlay.kind === "list") {
|
|
100
|
+
overlay.items.forEach((_item, i) => {
|
|
101
|
+
tweens.push(`tl.fromTo("#${id}i${i}", { opacity: 0, y: 14 }, { opacity: 1, y: 0, duration: 0.35, ease: "power3.out", immediateRender: false }, ${r3(overlay.start + 0.2 + 0.12 * i)});`);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
tweens.push(`tl.to("#${id} .ov-card", { scale: 0.94, y: 14, opacity: 0, duration: ${EXIT_SECONDS}, ease: "power2.in" }, ${exitAt});`);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const view = `viewBox="0 0 ${frame.width} ${frame.height}"`;
|
|
108
|
+
if (overlay.kind === "arrow") {
|
|
109
|
+
const paths = getArrowPaths(overlay, scale);
|
|
110
|
+
const body = `<svg class="ov-svg" ${view}><path id="${id}c" d="${paths.curve}" fill="none" stroke="${colors.accent}" stroke-width="${stroke}" stroke-linecap="round" pathLength="1" stroke-dasharray="1" stroke-dashoffset="1"/><path id="${id}h" d="${paths.head}" fill="none" stroke="${colors.accent}" stroke-width="${stroke}" stroke-linecap="round" stroke-linejoin="round" opacity="0"/></svg>`;
|
|
111
|
+
html.push(clip("ov ov-arrow", "inset:0", body));
|
|
112
|
+
// Drawn on from the tail; the head arrives as the stroke reaches the point.
|
|
113
|
+
tweens.push(`tl.fromTo("#${id}c", { attr: { "stroke-dashoffset": 1 } }, { attr: { "stroke-dashoffset": 0 }, duration: 0.45, ease: "power2.out", immediateRender: false }, ${overlay.start});`);
|
|
114
|
+
tweens.push(`tl.fromTo("#${id}h", { opacity: 0 }, { opacity: 1, duration: 0.12, ease: "none", immediateRender: false }, ${r3(overlay.start + 0.38)});`);
|
|
115
|
+
} else if (overlay.kind === "highlight") {
|
|
116
|
+
const { rect } = overlay;
|
|
117
|
+
const radius = r3(18 * scale);
|
|
118
|
+
const body = `<svg class="ov-svg" ${view}><rect x="${rect.left}" y="${rect.top}" width="${rect.width}" height="${rect.height}" rx="${radius}" fill="${colors.accent}" fill-opacity="0.18" stroke="none" id="${id}f" opacity="0"/><rect id="${id}s" x="${rect.left}" y="${rect.top}" width="${rect.width}" height="${rect.height}" rx="${radius}" fill="none" stroke="${colors.accent}" stroke-width="${stroke}" pathLength="1" stroke-dasharray="1" stroke-dashoffset="1"/></svg>`;
|
|
119
|
+
html.push(clip("ov ov-highlight", "inset:0", body));
|
|
120
|
+
// The marker's stroke drawn round its target, the tint settling in behind it.
|
|
121
|
+
tweens.push(`tl.fromTo("#${id}s", { attr: { "stroke-dashoffset": 1 } }, { attr: { "stroke-dashoffset": 0 }, duration: 0.5, ease: "power2.inOut", immediateRender: false }, ${overlay.start});`);
|
|
122
|
+
tweens.push(`tl.fromTo("#${id}f", { opacity: 0 }, { opacity: 1, duration: 0.3, ease: "none", immediateRender: false }, ${r3(overlay.start + 0.3)});`);
|
|
123
|
+
}
|
|
124
|
+
tweens.push(`tl.to("#${id} .ov-svg", { opacity: 0, duration: ${EXIT_SECONDS}, ease: "power2.in" }, ${exitAt});`);
|
|
125
|
+
}
|
|
126
|
+
return { html, css: getOverlayCss(colors, input.headingFont), tweens };
|
|
127
|
+
}
|