@softure-ai/marketing-kit 0.22.0 → 0.24.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 +27 -0
- package/README.md +21 -1
- package/dist/cli/failure.d.ts.map +1 -1
- package/dist/cli/failure.js.map +1 -1
- package/dist/cli/films.js.map +1 -1
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/options.d.ts.map +1 -1
- package/dist/compose/timeline.d.ts +22 -1
- package/dist/compose/timeline.d.ts.map +1 -1
- package/dist/compose/timeline.js +52 -14
- package/dist/compose/timeline.js.map +1 -1
- package/dist/config/actions-schema.d.ts +85 -85
- package/dist/config/actions-schema.d.ts.map +1 -1
- package/dist/config/colors.d.ts +24 -2
- package/dist/config/colors.d.ts.map +1 -1
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +3 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/placeholders.d.ts.map +1 -1
- package/dist/config/placeholders.js.map +1 -1
- package/dist/config/schema.d.ts +469 -466
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +15 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/config/shot-steps.d.ts +96 -96
- package/dist/film.d.ts.map +1 -1
- package/dist/footage/audio.js.map +1 -1
- package/dist/footage/captions.d.ts +22 -6
- package/dist/footage/captions.d.ts.map +1 -1
- package/dist/footage/captions.js +24 -14
- package/dist/footage/captions.js.map +1 -1
- package/dist/footage/clip-sound.d.ts.map +1 -1
- package/dist/footage/clip-sound.js.map +1 -1
- package/dist/footage/compose.d.ts +2 -0
- package/dist/footage/compose.d.ts.map +1 -1
- package/dist/footage/compose.js +3 -2
- package/dist/footage/compose.js.map +1 -1
- package/dist/footage/cuts.d.ts.map +1 -1
- package/dist/footage/cuts.js.map +1 -1
- package/dist/footage/declick.d.ts.map +1 -1
- package/dist/footage/disk.js.map +1 -1
- package/dist/footage/draft-font.js.map +1 -1
- package/dist/footage/draft-overlays.d.ts +24 -4
- package/dist/footage/draft-overlays.d.ts.map +1 -1
- package/dist/footage/draft-overlays.js +232 -34
- package/dist/footage/draft-overlays.js.map +1 -1
- package/dist/footage/draft.d.ts +7 -2
- package/dist/footage/draft.d.ts.map +1 -1
- package/dist/footage/draft.js +13 -2
- package/dist/footage/draft.js.map +1 -1
- package/dist/footage/edl.d.ts +46 -19
- package/dist/footage/edl.d.ts.map +1 -1
- package/dist/footage/edl.js +1 -1
- package/dist/footage/edl.js.map +1 -1
- package/dist/footage/elevenlabs.d.ts.map +1 -1
- package/dist/footage/failure.js.map +1 -1
- package/dist/footage/fake.js.map +1 -1
- package/dist/footage/ffmpeg-failure.d.ts.map +1 -1
- package/dist/footage/ffmpeg-failure.js.map +1 -1
- package/dist/footage/film.d.ts +9 -0
- package/dist/footage/film.d.ts.map +1 -1
- package/dist/footage/film.js.map +1 -1
- package/dist/footage/hyperframes-capture.d.ts.map +1 -1
- package/dist/footage/keyterms.d.ts.map +1 -1
- package/dist/footage/loudness.d.ts.map +1 -1
- package/dist/footage/loudness.js.map +1 -1
- package/dist/footage/mouth-clicks.d.ts.map +1 -1
- package/dist/footage/normalize.d.ts.map +1 -1
- package/dist/footage/normalize.js.map +1 -1
- package/dist/footage/overlay-html.d.ts +21 -1
- package/dist/footage/overlay-html.d.ts.map +1 -1
- package/dist/footage/overlay-html.js +217 -56
- package/dist/footage/overlay-html.js.map +1 -1
- package/dist/footage/overlay-schema.d.ts +104 -12
- package/dist/footage/overlay-schema.d.ts.map +1 -1
- package/dist/footage/overlay-schema.js +215 -45
- package/dist/footage/overlay-schema.js.map +1 -1
- package/dist/footage/overlays.d.ts +109 -16
- package/dist/footage/overlays.d.ts.map +1 -1
- package/dist/footage/overlays.js +303 -52
- package/dist/footage/overlays.js.map +1 -1
- package/dist/footage/paid.d.ts.map +1 -1
- package/dist/footage/pipeline.d.ts +5 -0
- package/dist/footage/pipeline.d.ts.map +1 -1
- package/dist/footage/pipeline.js +3 -2
- package/dist/footage/pipeline.js.map +1 -1
- package/dist/footage/probe.js.map +1 -1
- package/dist/footage/process.js.map +1 -1
- package/dist/footage/publish.js.map +1 -1
- package/dist/footage/render.js.map +1 -1
- package/dist/footage/sound-analysis.d.ts.map +1 -1
- package/dist/footage/speech-ranges.js.map +1 -1
- package/dist/footage/tonemap-lut.d.ts.map +1 -1
- package/dist/footage/tonemap-lut.js.map +1 -1
- package/dist/footage/tools.d.ts.map +1 -1
- package/dist/footage/tools.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/messages/en.d.ts.map +1 -1
- package/dist/messages/index.js.map +1 -1
- package/dist/og/font-file.d.ts.map +1 -1
- package/dist/og/fonts.d.ts.map +1 -1
- package/dist/og/fonts.js.map +1 -1
- package/dist/og/photo-cover.d.ts.map +1 -1
- package/dist/og/result.d.ts.map +1 -1
- package/dist/og/templates/schemas.d.ts.map +1 -1
- package/dist/platforms.d.ts.map +1 -1
- package/dist/render/hyperframes.js.map +1 -1
- package/dist/render/render.d.ts +4 -1
- package/dist/render/render.d.ts.map +1 -1
- package/dist/render/render.js +2 -1
- package/dist/render/render.js.map +1 -1
- package/dist/screenshot/gates.d.ts.map +1 -1
- package/dist/voice/fake.js.map +1 -1
- package/dist/voice/provider.d.ts.map +1 -1
- package/package.json +2 -2
- package/schema/edl.schema.json +90 -8
- package/schema/marketing.schema.json +18 -0
- package/src/compose/timeline.ts +62 -13
- package/src/config/config.ts +3 -0
- package/src/config/schema.ts +15 -0
- package/src/footage/captions.ts +39 -16
- package/src/footage/compose.ts +5 -3
- package/src/footage/draft-overlays.ts +276 -35
- package/src/footage/draft.ts +20 -4
- package/src/footage/edl.ts +1 -1
- package/src/footage/film.ts +9 -0
- package/src/footage/overlay-html.ts +239 -59
- package/src/footage/overlay-schema.ts +245 -40
- package/src/footage/overlays.ts +364 -55
- package/src/footage/pipeline.ts +8 -3
- package/src/index.ts +28 -0
- package/src/render/render.ts +3 -2
package/src/footage/draft.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { getSegmentScales, getSegmentZoomEases } from "./compose.js";
|
|
|
12
12
|
import { toAssColor } from "./draft-color.js";
|
|
13
13
|
import { buildDraftOverlayEvents, getDraftOverlayStyles } from "./draft-overlays.js";
|
|
14
14
|
import type { OverlayColors } from "./overlay-html.js";
|
|
15
|
-
import { resolveEdlOverlays, type ResolvedOverlay } from "./overlays.js";
|
|
15
|
+
import { resolveEdlOverlays, type OverlayFontRole, type ResolvedOverlay } from "./overlays.js";
|
|
16
16
|
import { chooseFootageDraftFont } from "./draft-font.js";
|
|
17
17
|
import { getEdlDuration, getSegmentStarts, remapWords, type Edl } from "./edl.js";
|
|
18
18
|
import { declickSpeech, describeDeclick, type DeclickReport } from "./declick.js";
|
|
@@ -134,6 +134,10 @@ export interface FootageDraftCaptionsInput {
|
|
|
134
134
|
overlays?: ResolvedOverlay[];
|
|
135
135
|
/** The overlays' card, text and accent colours; default `FOOTAGE_DRAFT_OVERLAY_COLORS`. */
|
|
136
136
|
overlayColors?: OverlayColors;
|
|
137
|
+
/** The overlays' heading and interface font families where they are not `fontFamily` (as the font files name them). */
|
|
138
|
+
overlayFonts?: Partial<Record<OverlayFontRole, string>>;
|
|
139
|
+
/** How a counter groups its number (BCP 47); default `en-US`. */
|
|
140
|
+
locale?: string;
|
|
137
141
|
}
|
|
138
142
|
|
|
139
143
|
/** 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. */
|
|
@@ -279,7 +283,10 @@ export function buildFootageDraftCaptions(input: FootageDraftCaptionsInput): str
|
|
|
279
283
|
"[Events]",
|
|
280
284
|
"Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text",
|
|
281
285
|
...events,
|
|
282
|
-
...buildDraftOverlayEvents(overlays, input.overlayColors ?? FOOTAGE_DRAFT_OVERLAY_COLORS, input.frame
|
|
286
|
+
...buildDraftOverlayEvents(overlays, input.overlayColors ?? FOOTAGE_DRAFT_OVERLAY_COLORS, input.frame, {
|
|
287
|
+
...(input.overlayFonts === undefined ? {} : { fonts: input.overlayFonts }),
|
|
288
|
+
...(input.locale === undefined ? {} : { locale: input.locale }),
|
|
289
|
+
}),
|
|
283
290
|
"",
|
|
284
291
|
].join("\n");
|
|
285
292
|
}
|
|
@@ -519,7 +526,7 @@ export interface RenderFootageDraftOptions extends Pick<FootageRunOptions, "buil
|
|
|
519
526
|
* OpenType file; DejaVu Sans when it has none) and its caption colours. Without it, DejaVu Sans and
|
|
520
527
|
* `FOOTAGE_DRAFT_CAPTION_COLORS`.
|
|
521
528
|
*/
|
|
522
|
-
brand?: { colors: FootageDraftCaptionColors & Partial<OverlayColors>; fonts: Pick<FootageBrand["fonts"], "body"> };
|
|
529
|
+
brand?: { colors: FootageDraftCaptionColors & Partial<OverlayColors>; fonts: Pick<FootageBrand["fonts"], "body"> & Partial<Pick<FootageBrand["fonts"], "heading" | "interface">>; locale?: string };
|
|
523
530
|
/**
|
|
524
531
|
* ffmpeg's threads for the draft's decoders, filter graph and encoder (`buildFootageDraftArgs`); by default ffmpeg's
|
|
525
532
|
* own choice, which follows the host's cores. Set it from a CPU-limited container's quota.
|
|
@@ -633,6 +640,13 @@ async function runRenderFootageDraft(
|
|
|
633
640
|
: FOOTAGE_DRAFT_OVERLAY_COLORS;
|
|
634
641
|
const brandFont = chooseFootageDraftFont(options.brand?.fonts.body ?? null);
|
|
635
642
|
const font = brandFont ?? FOOTAGE_DRAFT_FONT;
|
|
643
|
+
// The overlays' heading and interface fonts, where the brand has a TrueType or OpenType file for them.
|
|
644
|
+
const roleFonts = Object.fromEntries(
|
|
645
|
+
(["heading", "interface"] as const).flatMap((role) => {
|
|
646
|
+
const chosen = overlays.length === 0 ? null : chooseFootageDraftFont(options.brand?.fonts[role] ?? null);
|
|
647
|
+
return chosen === null || chosen.family === font.family ? [] : [[role, chosen]];
|
|
648
|
+
}),
|
|
649
|
+
) as Partial<Record<OverlayFontRole, { family: string; file: string }>>;
|
|
636
650
|
const captions = buildFootageDraftCaptions({
|
|
637
651
|
film,
|
|
638
652
|
edl,
|
|
@@ -642,11 +656,13 @@ async function runRenderFootageDraft(
|
|
|
642
656
|
fontFamily: font.family,
|
|
643
657
|
...(options.brand === undefined ? {} : { colors: options.brand.colors }),
|
|
644
658
|
...(overlays.length === 0 ? {} : { overlays, overlayColors }),
|
|
659
|
+
...(Object.keys(roleFonts).length === 0 ? {} : { overlayFonts: Object.fromEntries(Object.entries(roleFonts).map(([role, chosen]) => [role, chosen.family])) }),
|
|
660
|
+
...(options.brand?.locale === undefined ? {} : { locale: options.brand.locale }),
|
|
645
661
|
});
|
|
646
662
|
if (captions !== null) {
|
|
647
663
|
writeFileSync(join(draftDir, "captions.ass"), captions);
|
|
648
664
|
mkdirSync(join(draftDir, "fonts"));
|
|
649
|
-
|
|
665
|
+
for (const file of new Set([font.file, ...Object.values(roleFonts).map((chosen) => chosen.file)])) copyFileSync(file, join(draftDir, "fonts", basename(file)));
|
|
650
666
|
if (brandFont === null && options.brand?.fonts.body != null) {
|
|
651
667
|
log(`draft: the brand's body font ${options.brand.fonts.body.family} has no TrueType or OpenType file ffmpeg can read; the captions use ${FOOTAGE_DRAFT_FONT.family}.`);
|
|
652
668
|
}
|
package/src/footage/edl.ts
CHANGED
|
@@ -109,7 +109,7 @@ export const edlSchema = z
|
|
|
109
109
|
.max(40)
|
|
110
110
|
.optional()
|
|
111
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.",
|
|
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, search_bar, place_card, counter, date_stamp; and a hook_title at the top, which may stay across cuts beside the others. Without it, none.",
|
|
113
113
|
),
|
|
114
114
|
})
|
|
115
115
|
.describe("The edit decision list of a footage film (edl.json).");
|
package/src/footage/film.ts
CHANGED
|
@@ -144,6 +144,15 @@ export interface FootageFilm {
|
|
|
144
144
|
* empty: numbers only.
|
|
145
145
|
*/
|
|
146
146
|
captionKeepWithNext?: string[];
|
|
147
|
+
/** The words a caption card aims at (a brand's words per caption); absent: 4 for `highlight`, 6 for `phrase`. */
|
|
148
|
+
captionMaxWords?: number;
|
|
149
|
+
/**
|
|
150
|
+
* The fewest words a caption card shows (2: never a one-word card): a short card joins the one before it when the
|
|
151
|
+
* join fits, otherwise takes words from it (`balanceCaptionGroups`). Absent: cards stay as they are cut.
|
|
152
|
+
*/
|
|
153
|
+
captionMinWords?: number;
|
|
154
|
+
/** The most characters a short card's join may make (what fits the caption's width); absent: no limit. */
|
|
155
|
+
captionMaxCharacters?: number;
|
|
147
156
|
/**
|
|
148
157
|
* 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
158
|
* 8 s); absent: only one overlay at a time.
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { BrandColors } from "../config/colors.js";
|
|
2
2
|
import { escapeHtml } from "../compose/html.js";
|
|
3
|
-
import {
|
|
3
|
+
import type { OverlayEntrance } from "./overlay-schema.js";
|
|
4
|
+
import { OVERLAY_LINE_HEIGHT, OVERLAY_LIST_LINE_HEIGHT, OVERLAY_PADDING_EM, OVERLAY_TITLE_LINE_HEIGHT, SEARCH_BAR_PADDING_EM, formatOverlayNumber, type ResolvedOverlay } from "./overlays.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* 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
|
+
* brand's colours and fonts (or the overlay's own colours) and every element a local clip (no network at render time).
|
|
8
9
|
*
|
|
9
10
|
* The motion is adapted from HyperFrames registry blocks (Apache-2.0, https://github.com/heygen-com/hyperframes):
|
|
10
11
|
* `lt-soft-pill` (the lower third's scale-pop pill, dot and settling text), `marker-highlight` (the stroke drawn over
|
|
11
12
|
* 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
|
+
* `composeFootage`). They are rewritten for the kit's frame, timeline and brand tokens: see the package's NOTICE. The
|
|
14
|
+
* entrances (`fade`, `slide`, `type`, `none`), the typed search field, the counting number and the drawn pin are the
|
|
15
|
+
* kit's own, eased without overshoot.
|
|
13
16
|
*/
|
|
14
17
|
|
|
15
18
|
/** The seconds an overlay takes to leave, ending with its clip. */
|
|
@@ -18,6 +21,10 @@ const EXIT_SECONDS = 0.3;
|
|
|
18
21
|
const STROKE_WIDTH = 10;
|
|
19
22
|
/** The arrow head's length, in px of a 1080 px wide frame. */
|
|
20
23
|
const ARROW_HEAD = 46;
|
|
24
|
+
/** When a typed overlay starts typing, after its card has faded in, in seconds from its start. */
|
|
25
|
+
export const OVERLAY_TYPING_DELAY = 0.3;
|
|
26
|
+
/** When a counter starts counting, in seconds from its start. */
|
|
27
|
+
const COUNT_DELAY = 0.15;
|
|
21
28
|
|
|
22
29
|
const r3 = (value: number): number => Math.round(value * 1000) / 1000 || 0;
|
|
23
30
|
|
|
@@ -30,18 +37,50 @@ export interface OverlayMarkup {
|
|
|
30
37
|
/** The brand's colours an overlay paints with: its card, its text, its accent (the dot, the arrow, the marker). */
|
|
31
38
|
export type OverlayColors = Pick<BrandColors, "background" | "foreground" | "accent">;
|
|
32
39
|
|
|
40
|
+
/** An overlay's colours: its own where it sets them, else the brand's. */
|
|
41
|
+
export function getOverlayColors(overlay: ResolvedOverlay, brand: OverlayColors): OverlayColors {
|
|
42
|
+
const own = overlay.kind === "punch_in" ? {} : overlay.colors;
|
|
43
|
+
return { background: own.card ?? brand.background, foreground: own.text ?? brand.foreground, accent: own.accent ?? brand.accent };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The seconds a counter counts over (from `COUNT_DELAY` after its start): half its span, between 0.6 and 1.6 s. */
|
|
47
|
+
export function getCounterSeconds(overlay: { start: number; end: number }): { start: number; duration: number } {
|
|
48
|
+
return { start: r3(overlay.start + COUNT_DELAY), duration: r3(Math.min(1.6, Math.max(0.6, (overlay.end - overlay.start) * 0.5))) };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The film seconds each character of a typed text appears at, from `OVERLAY_TYPING_DELAY` after the overlay's start. */
|
|
52
|
+
export function getTypingTimes(start: number, text: string, speed: number): number[] {
|
|
53
|
+
return [...text].map((_char, index) => r3(start + OVERLAY_TYPING_DELAY + index / speed));
|
|
54
|
+
}
|
|
55
|
+
|
|
33
56
|
/** The CSS every overlay kind shares, written once when the film has any drawn overlay. */
|
|
34
|
-
function getOverlayCss(colors: OverlayColors,
|
|
57
|
+
function getOverlayCss(colors: OverlayColors, fonts: { heading: string; interface: string }): string[] {
|
|
35
58
|
return [
|
|
36
59
|
`.ov{position:absolute;display:flex;pointer-events:none}`,
|
|
37
60
|
`.ov.right{justify-content:flex-end}`,
|
|
38
|
-
`.ov
|
|
61
|
+
`.ov.center{justify-content:center}`,
|
|
62
|
+
`.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-family:${fonts.interface};font-weight:700;letter-spacing:-.015em;max-width:100%;overflow-wrap:anywhere;transform-origin:0% 100%}`,
|
|
39
63
|
`.ov.right .ov-card{transform-origin:100% 100%}`,
|
|
40
|
-
`.ov-keyword .ov-card{font-family:${
|
|
64
|
+
`.ov-keyword .ov-card{font-family:${fonts.heading};border-bottom:.12em solid ${colors.accent}}`,
|
|
41
65
|
`.ov-dot{flex:none;width:.36em;height:.36em;border-radius:50%;background:${colors.accent}}`,
|
|
42
66
|
`.ov-list .ov-card{flex-direction:column;align-items:flex-start;gap:0;line-height:${OVERLAY_LIST_LINE_HEIGHT};font-weight:650}`,
|
|
43
67
|
`.ov-list li{display:flex;align-items:center;gap:.45em;list-style:none}`,
|
|
44
68
|
`.ov-svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}`,
|
|
69
|
+
`.ov-search,.ov-counter .ov-card,.ov-date .ov-card,.ov-place,.ov-sub,.ov-line{white-space:nowrap}`,
|
|
70
|
+
`.ov-stack{flex-direction:column;gap:0;text-align:center;transform-origin:50% 0%}`,
|
|
71
|
+
`.ov-hook-title .ov-line{font-family:${fonts.heading};font-weight:800;letter-spacing:-.02em}`,
|
|
72
|
+
`.ov-place{display:flex;align-items:center;justify-content:center;gap:.25em;font-weight:650;opacity:.92;margin-bottom:.12em}`,
|
|
73
|
+
`.ov-pin{flex:none;width:1.05em;height:1.05em}`,
|
|
74
|
+
`.ov-place-card .ov-line{font-family:${fonts.heading};font-weight:800;line-height:${OVERLAY_TITLE_LINE_HEIGHT};letter-spacing:-.025em}`,
|
|
75
|
+
`.ov-sub{font-weight:600;opacity:.88;margin-top:.12em}`,
|
|
76
|
+
`.ov-search{width:100%;border-radius:999px;padding:${SEARCH_BAR_PADDING_EM.y}em ${SEARCH_BAR_PADDING_EM.x}em;gap:.5em;font-weight:600;letter-spacing:0;justify-content:flex-start;transform-origin:50% 50%}`,
|
|
77
|
+
`.ov-glass{flex:none;width:1em;height:1em}`,
|
|
78
|
+
`.ov-counter .ov-card{font-family:${fonts.heading};font-weight:800;align-items:baseline;gap:.3em;font-variant-numeric:tabular-nums;transform-origin:50% 50%}`,
|
|
79
|
+
`.ov-date .ov-card{flex-direction:column;gap:0;font-weight:800}`,
|
|
80
|
+
`.ov-date.right .ov-card{align-items:flex-end}`,
|
|
81
|
+
`.ov-date:not(.right) .ov-card{align-items:flex-start}`,
|
|
82
|
+
`.ov-date .ov-sub{font-weight:600;margin-top:0}`,
|
|
83
|
+
`.ty .ch{opacity:0}`,
|
|
45
84
|
];
|
|
46
85
|
}
|
|
47
86
|
|
|
@@ -64,64 +103,205 @@ export function getArrowPaths(overlay: Extract<ResolvedOverlay, { kind: "arrow"
|
|
|
64
103
|
};
|
|
65
104
|
}
|
|
66
105
|
|
|
106
|
+
/** A map pin drawn in the accent: a rounded drop with a hole, one line of the label tall. */
|
|
107
|
+
function getPinSvg(accent: string): string {
|
|
108
|
+
return `<svg class="ov-pin" viewBox="0 0 24 24"><path fill="${accent}" fill-rule="evenodd" d="M12 1.5c-4.3 0-7.75 3.4-7.75 7.6 0 5.6 7.75 13.4 7.75 13.4s7.75-7.8 7.75-13.4c0-4.2-3.45-7.6-7.75-7.6zm0 10.6a3 3 0 1 1 0-6 3 3 0 0 1 0 6z"/></svg>`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** A magnifier drawn in the accent. */
|
|
112
|
+
function getGlassSvg(accent: string): string {
|
|
113
|
+
return `<svg class="ov-glass" viewBox="0 0 24 24"><circle cx="10" cy="10" r="6.6" fill="none" stroke="${accent}" stroke-width="2.6"/><path d="M15 15l6 6" stroke="${accent}" stroke-width="2.6" stroke-linecap="round"/></svg>`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** A text as one span per character, for the typed entrance (spaces kept). */
|
|
117
|
+
function toTypedHtml(text: string): string {
|
|
118
|
+
return [...text].map((char) => `<span class="ch">${char === " " ? " " : escapeHtml(char)}</span>`).join("");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** The inline colours of a card that has its own. */
|
|
122
|
+
function getCardStyle(overlay: ResolvedOverlay, colors: OverlayColors): string {
|
|
123
|
+
if (overlay.kind === "punch_in") return "";
|
|
124
|
+
const own = overlay.colors;
|
|
125
|
+
const parts = [own.card === undefined ? "" : `background:${colors.background}`, own.text === undefined ? "" : `color:${colors.foreground}`];
|
|
126
|
+
if (overlay.kind === "keyword" && own.accent !== undefined) parts.push(`border-bottom-color:${colors.accent}`);
|
|
127
|
+
const style = parts.filter((part) => part !== "").join(";");
|
|
128
|
+
return style === "" ? "" : ` style="${style}"`;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** The entrance tweens of a card: fade, slide, a typed card's fade, or nothing. */
|
|
132
|
+
function getEntranceTweens(target: string, entrance: OverlayEntrance, start: number): string[] {
|
|
133
|
+
if (entrance === "none") return [];
|
|
134
|
+
if (entrance === "slide") return [`tl.fromTo("${target}", { opacity: 0, y: 28 }, { opacity: 1, y: 0, duration: 0.5, ease: "power3.out", immediateRender: false }, ${start});`];
|
|
135
|
+
const duration = entrance === "type" ? 0.25 : 0.4;
|
|
136
|
+
return [`tl.fromTo("${target}", { opacity: 0 }, { opacity: 1, duration: ${duration}, ease: "power2.out", immediateRender: false }, ${start});`];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** The typing tweens: each character of `#<id>` shown at its time. */
|
|
140
|
+
function getTypingTweens(id: string, overlay: { start: number; typing: number | null }, length: number): string[] {
|
|
141
|
+
if (overlay.typing === null || length === 0) return [];
|
|
142
|
+
return [`tl.to("#${id} .ch", { opacity: 1, duration: 0.01, ease: "none", stagger: ${r3(1 / overlay.typing)} }, ${r3(overlay.start + OVERLAY_TYPING_DELAY)});`];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Each new kind's own entrance when the overlay names none. */
|
|
146
|
+
const DEFAULT_ENTRANCES = { hook_title: "slide", search_bar: "fade", place_card: "slide", counter: "fade", date_stamp: "fade" } as const;
|
|
147
|
+
|
|
148
|
+
interface MarkupContext {
|
|
149
|
+
colors: OverlayColors;
|
|
150
|
+
scale: number;
|
|
151
|
+
locale: string;
|
|
152
|
+
frame: { width: number; height: number };
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** A keyword, a lower third or a list, entering as the soft pill (or by its own entrance). */
|
|
156
|
+
function addSideText(overlay: Extract<ResolvedOverlay, { kind: "keyword" | "lower_third" | "list" }>, id: string, context: MarkupContext, out: OverlayMarkup): void {
|
|
157
|
+
const { box, fontSize, side } = overlay;
|
|
158
|
+
const colors = getOverlayColors(overlay, context.colors);
|
|
159
|
+
const cardStyle = getCardStyle(overlay, colors);
|
|
160
|
+
const dotStyle = overlay.colors.accent === undefined ? "" : ` style="background:${colors.accent}"`;
|
|
161
|
+
const isTyped = overlay.typing !== null && overlay.kind !== "list";
|
|
162
|
+
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"}`;
|
|
163
|
+
const text = overlay.kind === "list" ? "" : isTyped ? toTypedHtml(overlay.text) : escapeHtml(overlay.text);
|
|
164
|
+
const body =
|
|
165
|
+
overlay.kind === "list"
|
|
166
|
+
? `<ul class="ov-card"${cardStyle}>${overlay.items.map((item, i) => `<li id="${id}i${i}"><i class="ov-dot"${dotStyle}></i>${escapeHtml(item)}</li>`).join("")}</ul>`
|
|
167
|
+
: `<div class="ov-card"${cardStyle}>${overlay.kind === "lower_third" ? `<i class="ov-dot" id="${id}d"${dotStyle}></i>` : ""}<span id="${id}t">${text}</span></div>`;
|
|
168
|
+
out.html.push(clipDiv(overlay, id, `ov ov-${overlay.kind.replace("_", "-")}${side === "right" ? " right" : ""}${isTyped ? " ty" : ""}`, style, body));
|
|
169
|
+
if (overlay.entrance !== null) {
|
|
170
|
+
out.tweens.push(...getEntranceTweens(`#${id} .ov-card`, overlay.entrance, overlay.start));
|
|
171
|
+
if (overlay.kind !== "list") out.tweens.push(...getTypingTweens(id, overlay, [...overlay.text].length));
|
|
172
|
+
} else {
|
|
173
|
+
// The soft pill's entrance: the card rises from its foot, then its dot and its text settle in.
|
|
174
|
+
out.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});`);
|
|
175
|
+
if (overlay.kind === "lower_third") {
|
|
176
|
+
out.tweens.push(`tl.fromTo("#${id}d", { scale: 0 }, { scale: 1, duration: 0.35, ease: "back.out(3)", immediateRender: false }, ${r3(overlay.start + 0.25)});`);
|
|
177
|
+
out.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)});`);
|
|
178
|
+
}
|
|
179
|
+
if (overlay.kind === "list") {
|
|
180
|
+
overlay.items.forEach((_item, i) => {
|
|
181
|
+
out.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)});`);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
out.tweens.push(`tl.to("#${id} .ov-card", { scale: 0.94, y: 14, opacity: 0, duration: ${EXIT_SECONDS}, ease: "power2.in" }, ${r3(overlay.end - EXIT_SECONDS)});`);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
type CardOverlay = Extract<ResolvedOverlay, { kind: "hook_title" | "search_bar" | "place_card" | "counter" | "date_stamp" }>;
|
|
189
|
+
|
|
190
|
+
/** The inner HTML of a card kind, and how many characters it types in. */
|
|
191
|
+
function getCardBody(overlay: CardOverlay, id: string, colors: OverlayColors, locale: string): { classes: string; body: string; typed: number } {
|
|
192
|
+
const typedOrPlain = (text: string) => (overlay.typing === null ? escapeHtml(text) : toTypedHtml(text));
|
|
193
|
+
if (overlay.kind === "hook_title") {
|
|
194
|
+
const place = overlay.place === null ? "" : `<div class="ov-place" style="font-size:${overlay.placeFontSize}px">${getPinSvg(colors.accent)}<span>${escapeHtml(overlay.place)}</span></div>`;
|
|
195
|
+
const lines = overlay.lines.map((line) => `<div class="ov-line">${typedOrPlain(line)}</div>`).join("");
|
|
196
|
+
return { classes: "ov-hook-title center", body: `<div class="ov-card ov-stack"__STYLE__>${place}${lines}</div>`, typed: overlay.lines.join("").length };
|
|
197
|
+
}
|
|
198
|
+
if (overlay.kind === "place_card") {
|
|
199
|
+
const subtitle = overlay.subtitle === null ? "" : `<div class="ov-sub" style="font-size:${overlay.subtitleFontSize}px">${escapeHtml(overlay.subtitle)}</div>`;
|
|
200
|
+
const lines = overlay.lines.map((line) => `<div class="ov-line">${typedOrPlain(line)}</div>`).join("");
|
|
201
|
+
return { classes: "ov-place-card center", body: `<div class="ov-card ov-stack"__STYLE__>${lines}${subtitle}</div>`, typed: overlay.lines.join("").length };
|
|
202
|
+
}
|
|
203
|
+
if (overlay.kind === "search_bar") {
|
|
204
|
+
return { classes: "ov-search-bar center", body: `<div class="ov-card ov-search"__STYLE__>${getGlassSvg(colors.accent)}<span id="${id}t">${typedOrPlain(overlay.text)}</span></div>`, typed: [...overlay.text].length };
|
|
205
|
+
}
|
|
206
|
+
if (overlay.kind === "counter") {
|
|
207
|
+
const unit = overlay.unit === null ? "" : `<span class="ov-unit" style="font-size:${overlay.unitFontSize}px">${escapeHtml(overlay.unit)}</span>`;
|
|
208
|
+
return { classes: "ov-counter center", body: `<div class="ov-card"__STYLE__><span id="${id}n">${escapeHtml(formatOverlayNumber(overlay.from, overlay.decimals, locale))}</span>${unit}</div>`, typed: 0 };
|
|
209
|
+
}
|
|
210
|
+
const place = overlay.place === null ? "" : `<div class="ov-sub" style="font-size:${overlay.placeFontSize}px">${escapeHtml(overlay.place)}</div>`;
|
|
211
|
+
return { classes: `ov-date${overlay.side === "right" ? " right" : ""}`, body: `<div class="ov-card"__STYLE__><span>${typedOrPlain(overlay.text)}</span>${place}</div>`, typed: [...overlay.text].length };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** A hook title, a search bar, a place card, a counter or a date stamp. */
|
|
215
|
+
function addCard(overlay: CardOverlay, id: string, context: MarkupContext, out: OverlayMarkup): void {
|
|
216
|
+
const colors = getOverlayColors(overlay, context.colors);
|
|
217
|
+
const { box, fontSize } = overlay;
|
|
218
|
+
const { classes, body, typed } = getCardBody(overlay, id, colors, context.locale);
|
|
219
|
+
const style = `left:${box.left}px;top:${box.top}px;width:${box.width}px;height:${box.height}px;font-size:${fontSize}px;align-items:flex-start`;
|
|
220
|
+
out.html.push(clipDiv(overlay, id, `ov ${classes}${overlay.typing === null ? "" : " ty"}`, style, body.replace("__STYLE__", getCardStyle(overlay, colors))));
|
|
221
|
+
const entrance = overlay.entrance ?? (overlay.typing !== null ? "type" : DEFAULT_ENTRANCES[overlay.kind]);
|
|
222
|
+
out.tweens.push(...getEntranceTweens(`#${id} .ov-card`, entrance, overlay.start));
|
|
223
|
+
out.tweens.push(...getTypingTweens(id, overlay, typed));
|
|
224
|
+
if (overlay.kind === "counter") {
|
|
225
|
+
const count = getCounterSeconds(overlay);
|
|
226
|
+
const format = `new Intl.NumberFormat(${toScriptString(getScriptLocale(context.locale))}, { minimumFractionDigits: ${overlay.decimals}, maximumFractionDigits: ${overlay.decimals} })`;
|
|
227
|
+
// The number eases up to its value; the timeline renders it on every seek, so each frame shows its own count.
|
|
228
|
+
out.tweens.push(
|
|
229
|
+
`(function () { const el = document.getElementById("${id}n"); const nf = ${format}; const n = { v: ${overlay.from} }; tl.fromTo(n, { v: ${overlay.from} }, { v: ${overlay.value}, duration: ${count.duration}, ease: "power2.out", immediateRender: false, onUpdate: () => { el.textContent = nf.format(n.v).replace(/[\\u00a0\\u202f]/g, " "); } }, ${count.start}); })();`,
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
out.tweens.push(`tl.to("#${id} .ov-card", { y: 10, opacity: 0, duration: ${EXIT_SECONDS}, ease: "power2.in" }, ${r3(overlay.end - EXIT_SECONDS)});`);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** The brand's locale as a canonical BCP 47 tag (letters, digits and dashes only), `en-US` when it is not one. */
|
|
236
|
+
export function getScriptLocale(locale: string | undefined): string {
|
|
237
|
+
try {
|
|
238
|
+
return Intl.getCanonicalLocales(locale ?? "en-US")[0] ?? "en-US";
|
|
239
|
+
} catch {
|
|
240
|
+
return "en-US";
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** A string as a script literal that cannot close the `<script>` element it sits in. */
|
|
245
|
+
function toScriptString(value: string): string {
|
|
246
|
+
return JSON.stringify(value).replace(/</g, "\\u003c");
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** An overlay's clip: shown for its own span. */
|
|
250
|
+
function clipDiv(overlay: ResolvedOverlay, id: string, classes: string, style: string, body: string): string {
|
|
251
|
+
return `<div id="${id}" class="clip ${classes}" data-start="${overlay.start}" data-duration="${r3(overlay.end - overlay.start)}" style="${style}">${body}</div>`;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** An arrow drawn on from its tail, or a highlight's marker drawn round its target (or faded in, or simply there). */
|
|
255
|
+
function addMark(overlay: Extract<ResolvedOverlay, { kind: "arrow" | "highlight" }>, id: string, context: MarkupContext, out: OverlayMarkup): void {
|
|
256
|
+
const { frame, scale } = context;
|
|
257
|
+
const { accent } = getOverlayColors(overlay, context.colors);
|
|
258
|
+
const stroke = r3(STROKE_WIDTH * scale);
|
|
259
|
+
const view = `viewBox="0 0 ${frame.width} ${frame.height}"`;
|
|
260
|
+
const isDrawn = overlay.entrance === null;
|
|
261
|
+
const dash = isDrawn ? ` pathLength="1" stroke-dasharray="1" stroke-dashoffset="1"` : "";
|
|
262
|
+
if (overlay.kind === "arrow") {
|
|
263
|
+
const paths = getArrowPaths(overlay, scale);
|
|
264
|
+
const body = `<svg class="ov-svg" ${view}><path id="${id}c" d="${paths.curve}" fill="none" stroke="${accent}" stroke-width="${stroke}" stroke-linecap="round"${dash}/><path id="${id}h" d="${paths.head}" fill="none" stroke="${accent}" stroke-width="${stroke}" stroke-linecap="round" stroke-linejoin="round"${isDrawn ? ` opacity="0"` : ""}/></svg>`;
|
|
265
|
+
out.html.push(clipDiv(overlay, id, "ov ov-arrow", "inset:0", body));
|
|
266
|
+
if (isDrawn) {
|
|
267
|
+
// Drawn on from the tail; the head arrives as the stroke reaches the point.
|
|
268
|
+
out.tweens.push(`tl.fromTo("#${id}c", { attr: { "stroke-dashoffset": 1 } }, { attr: { "stroke-dashoffset": 0 }, duration: 0.45, ease: "power2.out", immediateRender: false }, ${overlay.start});`);
|
|
269
|
+
out.tweens.push(`tl.fromTo("#${id}h", { opacity: 0 }, { opacity: 1, duration: 0.12, ease: "none", immediateRender: false }, ${r3(overlay.start + 0.38)});`);
|
|
270
|
+
}
|
|
271
|
+
} else {
|
|
272
|
+
const { rect } = overlay;
|
|
273
|
+
const radius = r3(18 * scale);
|
|
274
|
+
const body = `<svg class="ov-svg" ${view}><rect x="${rect.left}" y="${rect.top}" width="${rect.width}" height="${rect.height}" rx="${radius}" fill="${accent}" fill-opacity="0.18" stroke="none" id="${id}f"${isDrawn ? ` opacity="0"` : ""}/><rect id="${id}s" x="${rect.left}" y="${rect.top}" width="${rect.width}" height="${rect.height}" rx="${radius}" fill="none" stroke="${accent}" stroke-width="${stroke}"${dash}/></svg>`;
|
|
275
|
+
out.html.push(clipDiv(overlay, id, "ov ov-highlight", "inset:0", body));
|
|
276
|
+
if (isDrawn) {
|
|
277
|
+
// The marker's stroke drawn round its target, the tint settling in behind it.
|
|
278
|
+
out.tweens.push(`tl.fromTo("#${id}s", { attr: { "stroke-dashoffset": 1 } }, { attr: { "stroke-dashoffset": 0 }, duration: 0.5, ease: "power2.inOut", immediateRender: false }, ${overlay.start});`);
|
|
279
|
+
out.tweens.push(`tl.fromTo("#${id}f", { opacity: 0 }, { opacity: 1, duration: 0.3, ease: "none", immediateRender: false }, ${r3(overlay.start + 0.3)});`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (overlay.entrance === "fade") out.tweens.push(...getEntranceTweens(`#${id} .ov-svg`, "fade", overlay.start));
|
|
283
|
+
out.tweens.push(`tl.to("#${id} .ov-svg", { opacity: 0, duration: ${EXIT_SECONDS}, ease: "power2.in" }, ${r3(overlay.end - EXIT_SECONDS)});`);
|
|
284
|
+
}
|
|
285
|
+
|
|
67
286
|
/**
|
|
68
287
|
* 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.
|
|
288
|
+
* overlay is a clip shown for its own span, entering at its start and leaving over its last 0.3 s. Titles, numbers and
|
|
289
|
+
* keywords are drawn in `headingFont`, labels, lists, the search query and the stamp in `interfaceFont` (the body font
|
|
290
|
+
* without one); a counter's number is grouped as `locale` writes numbers.
|
|
70
291
|
*/
|
|
71
|
-
export function getOverlayMarkup(
|
|
72
|
-
|
|
292
|
+
export function getOverlayMarkup(
|
|
293
|
+
overlays: readonly ResolvedOverlay[],
|
|
294
|
+
input: { colors: OverlayColors; headingFont: string; interfaceFont?: string; locale?: string; frame: { width: number; height: number } },
|
|
295
|
+
): OverlayMarkup {
|
|
296
|
+
const drawn = overlays.filter((overlay): overlay is Exclude<ResolvedOverlay, { kind: "punch_in" }> => overlay.kind !== "punch_in");
|
|
73
297
|
if (drawn.length === 0) return { html: [], css: [], tweens: [] };
|
|
74
|
-
const { colors, frame
|
|
75
|
-
const
|
|
76
|
-
const stroke = r3(STROKE_WIDTH * scale);
|
|
77
|
-
const html: string[] = [];
|
|
78
|
-
const tweens: string[] = [];
|
|
298
|
+
const context: MarkupContext = { colors: input.colors, scale: input.frame.width / 1080, locale: input.locale ?? "en-US", frame: input.frame };
|
|
299
|
+
const out: OverlayMarkup = { html: [], css: getOverlayCss(input.colors, { heading: input.headingFont, interface: input.interfaceFont ?? "inherit" }), tweens: [] };
|
|
79
300
|
for (const overlay of drawn) {
|
|
80
301
|
const id = `ov${overlay.index}`;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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});`);
|
|
302
|
+
if (overlay.kind === "keyword" || overlay.kind === "lower_third" || overlay.kind === "list") addSideText(overlay, id, context, out);
|
|
303
|
+
else if (overlay.kind === "arrow" || overlay.kind === "highlight") addMark(overlay, id, context, out);
|
|
304
|
+
else addCard(overlay, id, context, out);
|
|
125
305
|
}
|
|
126
|
-
return
|
|
306
|
+
return out;
|
|
127
307
|
}
|