agentcut 0.2.25 → 0.2.27
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/README.md +177 -148
- package/dist/config.d.ts +0 -1
- package/dist/config.js +0 -5
- package/dist/config.js.map +1 -1
- package/dist/studio/agents/claude.js +3 -2
- package/dist/studio/agents/claude.js.map +1 -1
- package/dist/studio/chat.js +1 -1
- package/dist/studio/chat.js.map +1 -1
- package/dist/studio/cli.js +40 -21
- package/dist/studio/cli.js.map +1 -1
- package/dist/studio/download.d.ts +24 -0
- package/dist/studio/download.js +234 -0
- package/dist/studio/download.js.map +1 -0
- package/dist/studio/host.d.ts +1 -2
- package/dist/studio/host.js +36 -8
- package/dist/studio/host.js.map +1 -1
- package/dist/studio/housekeeping.d.ts +2 -2
- package/dist/studio/housekeeping.js +18 -17
- package/dist/studio/housekeeping.js.map +1 -1
- package/dist/studio/mcp-guides.js +1 -18
- package/dist/studio/mcp-guides.js.map +1 -1
- package/dist/studio/proc.js +16 -6
- package/dist/studio/proc.js.map +1 -1
- package/dist/studio/proxies.d.ts +4 -0
- package/dist/studio/proxies.js +15 -6
- package/dist/studio/proxies.js.map +1 -1
- package/dist/studio/release-cursor.js +21 -21
- package/dist/studio/release-video.js +10 -10
- package/dist/studio/schema.d.ts +0 -1
- package/dist/studio/schema.js +0 -1
- package/dist/studio/schema.js.map +1 -1
- package/dist/studio/tools.d.ts +0 -4
- package/dist/studio/tools.js +32 -31
- package/dist/studio/tools.js.map +1 -1
- package/dist/studio/voice/kokoro-catalog.d.ts +56 -28
- package/dist/studio/voice/kokoro-catalog.js +56 -28
- package/dist/studio/voice/kokoro-catalog.js.map +1 -1
- package/dist/studio/voice/ming-catalog.d.ts +19 -0
- package/dist/studio/voice/ming-catalog.js +40 -0
- package/dist/studio/voice/ming-catalog.js.map +1 -0
- package/dist/studio/voice/ming.d.ts +12 -0
- package/dist/studio/voice/ming.js +397 -0
- package/dist/studio/voice/ming.js.map +1 -0
- package/dist/studio/voice/previews.d.ts +5 -0
- package/dist/studio/voice/previews.js +50 -0
- package/dist/studio/voice/previews.js.map +1 -0
- package/dist/studio/voice/registry.js +2 -0
- package/dist/studio/voice/registry.js.map +1 -1
- package/dist/studio/voice.d.ts +1 -1
- package/dist/studio/voice.js +5 -6
- package/dist/studio/voice.js.map +1 -1
- package/package.json +56 -56
- package/template/AGENTS.md +14 -14
- package/template/components/README.md +70 -70
- package/template/components/before-after/BeforeAfter.tsx +89 -89
- package/template/components/catalog.ts +107 -107
- package/template/components/cinematic/Device3D.tsx +324 -324
- package/template/components/cinematic/devices3d/display-model.ts +184 -184
- package/template/components/cinematic/devices3d/iphone-model.ts +643 -643
- package/template/components/cinematic/devices3d/macbook-model.ts +608 -608
- package/template/components/cinematic/devices3d/models.ts +657 -657
- package/template/components/cinematic/devices3d/runtime.ts +267 -267
- package/template/components/cinematic/math.ts +100 -100
- package/template/components/color/grade-effect.ts +650 -650
- package/template/components/color/grade.ts +512 -512
- package/template/components/color/looks.ts +154 -154
- package/template/components/countdown/Countdown.tsx +166 -166
- package/template/components/dot-trace-title/DotTraceTitle.tsx +181 -181
- package/template/components/dot-trace-title/meta.json +51 -51
- package/template/components/generate/GenerateReveal.tsx +381 -381
- package/template/components/hook-card/HookCard.tsx +554 -554
- package/template/components/index.ts +199 -199
- package/template/components/lib.ts +191 -191
- package/template/components/line-diagram/LineDiagram.tsx +205 -205
- package/template/components/line-diagram/meta.json +215 -215
- package/template/components/list-card/ListCard.tsx +104 -104
- package/template/components/live-clip.ts +75 -75
- package/template/components/looks.tsx +1447 -1447
- package/template/components/loops/LoopCanvas.tsx +132 -132
- package/template/components/loops/engine.ts +184 -184
- package/template/components/loops/library.ts +667 -667
- package/template/components/loops/library2.ts +777 -777
- package/template/components/motion-loop/MotionLoop.tsx +37 -37
- package/template/components/motion-loop/meta.json +311 -311
- package/template/components/props.ts +73 -73
- package/template/components/quote-card/QuoteCard.tsx +71 -71
- package/template/components/style-layer.tsx +233 -233
- package/template/components/styles.ts +113 -113
- package/template/components/types.ts +66 -66
- package/template/components/word-pop/WordPop.tsx +59 -59
- package/template/components/word-stack/WordStack.tsx +122 -122
- package/template/presets/charcoal-sketch/PROMPT.md +48 -48
- package/template/presets/charcoal-sketch/scripts/duck_music.py +34 -34
- package/template/presets/punk-cut-paper/scenes/Motif.tsx +376 -376
- package/template/presets/punk-cut-paper/scenes/Photo.tsx +73 -73
- package/template/presets/punk-cut-paper/scenes/Ransom.tsx +119 -119
- package/template/runtime/composition.tsx +1189 -1185
- package/template/runtime/helpers.tsx +230 -230
- package/template/runtime/index.tsx +22 -22
- package/template/runtime/types.ts +315 -315
- package/template/skill/SKILL.md +186 -351
- package/template/skill/references/broll.md +44 -44
- package/template/skill/references/browser-export.md +61 -61
- package/template/skill/references/cinematic.md +206 -206
- package/template/skill/references/color.md +79 -79
- package/template/skill/references/craft.md +54 -10
- package/template/skill/references/editing-styles.md +57 -57
- package/template/skill/references/feature-launch.md +5 -1
- package/template/skill/references/footage.md +72 -72
- package/template/skill/references/format.md +142 -142
- package/template/skill/references/how-to.md +0 -15
- package/template/skill/references/launch-direction.md +89 -0
- package/template/skill/references/loops.md +151 -151
- package/template/skill/references/mcp-external.md +19 -0
- package/template/skill/references/performance.md +93 -93
- package/template/skill/references/person-cutout.md +19 -19
- package/template/skill/references/presets.md +60 -60
- package/template/skill/references/product-launch.md +4 -1
- package/template/skill/references/release-capture.md +53 -0
- package/template/skill/references/sound.md +167 -155
- package/template/skill/references/style-spy.md +160 -160
- package/template/skill/references/website-howto.md +45 -45
- package/template/starter/.studio/chat.json +1 -1
- package/template/starter/layers.json +46 -46
- package/template/starter/notes.md +4 -4
- package/template/starter/project.json +13 -13
- package/template/starter/scenes/Title.tsx +38 -38
|
@@ -1,233 +1,233 @@
|
|
|
1
|
-
// What a project style does to the whole video, beyond the component props: camera moves on the
|
|
2
|
-
// footage, a texture over everything, and captions drawn in the style's look. The studio runtime
|
|
3
|
-
// calls these (when the page provides them), so a new or changed style ships with the page.
|
|
4
|
-
import type { CSSProperties } from "react";
|
|
5
|
-
import { AbsoluteFill, useCurrentFrame, useVideoConfig } from "remotion";
|
|
6
|
-
import { FONTS, alpha, unit } from "./lib";
|
|
7
|
-
import { Chip, Grain, Scanlines, Vignette, hash, lookKit, type LookProps } from "./looks";
|
|
8
|
-
import { getMotionStyle, type MotionStyle } from "./styles";
|
|
9
|
-
|
|
10
|
-
/** The style's tokens as look props (the first of its fonts the library has). */
|
|
11
|
-
export function styleLookProps(style: MotionStyle): LookProps {
|
|
12
|
-
const font = style.tokens.font.split(",").map((f) => f.trim()).find((f) => f in FONTS) ?? "archivo";
|
|
13
|
-
return {
|
|
14
|
-
look: style.look,
|
|
15
|
-
accent: style.tokens.accent,
|
|
16
|
-
panel: style.tokens.panel,
|
|
17
|
-
panelText: style.tokens.panelText,
|
|
18
|
-
line: style.tokens.line,
|
|
19
|
-
backdrop: style.tokens.backdrop,
|
|
20
|
-
onVideo: style.tokens.text,
|
|
21
|
-
font,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* The style's camera on a footage clip at `frame` (clip-local): jump-cut punch-ins with a shake,
|
|
27
|
-
* stop-motion snaps, a slow drift or glitch jumps. Null when the style keeps the camera still.
|
|
28
|
-
*/
|
|
29
|
-
export function styleCamera(
|
|
30
|
-
styleId: string | null | undefined,
|
|
31
|
-
{ frame, durationInFrames, width, height }: { frame: number; durationInFrames: number; width: number; height: number },
|
|
32
|
-
): CSSProperties | null {
|
|
33
|
-
const style = getMotionStyle(styleId);
|
|
34
|
-
const cam = style?.camera;
|
|
35
|
-
if (!cam) return null;
|
|
36
|
-
const moved = moveCamera(cam, { frame, durationInFrames, width, height });
|
|
37
|
-
if (!cam.grade) return moved;
|
|
38
|
-
return { ...moved, filter: cam.grade };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function moveCamera(
|
|
42
|
-
cam: NonNullable<ReturnType<typeof getMotionStyle>>["camera"],
|
|
43
|
-
{ frame, durationInFrames, width, height }: { frame: number; durationInFrames: number; width: number; height: number },
|
|
44
|
-
): CSSProperties | null {
|
|
45
|
-
if (cam.mode === "still") return null;
|
|
46
|
-
const u = unit(width, height);
|
|
47
|
-
const every = Math.max(8, cam.every);
|
|
48
|
-
const seg = Math.floor(frame / every);
|
|
49
|
-
const t = frame - seg * every;
|
|
50
|
-
const origin = "50% 38%";
|
|
51
|
-
switch (cam.mode) {
|
|
52
|
-
case "punch": {
|
|
53
|
-
// Cut to a tighter or wider framing every beat, with a short shake on the cut.
|
|
54
|
-
const levels = [1, cam.zoom, 1.04, cam.zoom * 1.05];
|
|
55
|
-
const scale = levels[seg % levels.length];
|
|
56
|
-
const kick = seg > 0 && t < 8 ? (1 - t / 8) * cam.shake * 18 * u : 0;
|
|
57
|
-
const x = (hash(seg, t) - 0.5) * 2 * kick;
|
|
58
|
-
const y = (hash(seg + 3, t) - 0.5) * 2 * kick;
|
|
59
|
-
return { transform: `translate(${x.toFixed(1)}px, ${y.toFixed(1)}px) scale(${scale})`, transformOrigin: origin };
|
|
60
|
-
}
|
|
61
|
-
case "snap": {
|
|
62
|
-
// Stop-motion: held on twos, a little hand jitter, framing steps with a 2-frame overshoot.
|
|
63
|
-
const held = frame - (frame % 2);
|
|
64
|
-
const levels = [1, cam.zoom, 1.05];
|
|
65
|
-
const over = seg > 0 && t < 2 ? 1.03 : 1;
|
|
66
|
-
const scale = levels[seg % levels.length] * over;
|
|
67
|
-
const x = (hash(7, held) - 0.5) * cam.shake * 6 * u;
|
|
68
|
-
const y = (hash(11, held) - 0.5) * cam.shake * 6 * u;
|
|
69
|
-
const r = (hash(13, held) - 0.5) * cam.shake * 0.5;
|
|
70
|
-
return { transform: `translate(${x.toFixed(1)}px, ${y.toFixed(1)}px) rotate(${r.toFixed(2)}deg) scale(${scale})`, transformOrigin: origin };
|
|
71
|
-
}
|
|
72
|
-
case "drift": {
|
|
73
|
-
// A slow push-in across the clip with a gentle sideways sway.
|
|
74
|
-
const p = Math.min(1, frame / Math.max(1, durationInFrames));
|
|
75
|
-
const scale = 1 + (cam.zoom - 1) * p;
|
|
76
|
-
const x = Math.sin(frame / (every * 0.9)) * cam.shake * 10 * u;
|
|
77
|
-
return { transform: `translate(${x.toFixed(1)}px, 0px) scale(${scale.toFixed(4)})`, transformOrigin: origin };
|
|
78
|
-
}
|
|
79
|
-
case "tape": {
|
|
80
|
-
// Worn tape: a slight wobble on twos, and a tracking hiccup (a sideways tear and a roll) every beat.
|
|
81
|
-
const held = frame - (frame % 2);
|
|
82
|
-
const wobble = (hash(5, held) - 0.5) * cam.shake * 3 * u;
|
|
83
|
-
if (seg > 0 && t < 4) {
|
|
84
|
-
const x = (hash(seg, t) - 0.5) * cam.shake * 40 * u;
|
|
85
|
-
const y = -(4 - t) * cam.shake * 6 * u;
|
|
86
|
-
return { transform: `translate(${x.toFixed(1)}px, ${y.toFixed(1)}px) scale(${cam.zoom})`, transformOrigin: origin };
|
|
87
|
-
}
|
|
88
|
-
return { transform: `translate(${wobble.toFixed(1)}px, 0px) scale(${cam.zoom})`, transformOrigin: origin };
|
|
89
|
-
}
|
|
90
|
-
case "glitch": {
|
|
91
|
-
// Still, except a 3-frame jump every beat.
|
|
92
|
-
if (seg > 0 && t < 3) {
|
|
93
|
-
const x = (hash(seg, t) - 0.5) * cam.shake * 60 * u;
|
|
94
|
-
return { transform: `translate(${x.toFixed(1)}px, 0px) scale(${cam.zoom})`, transformOrigin: origin };
|
|
95
|
-
}
|
|
96
|
-
return { transform: "scale(1.02)", transformOrigin: origin };
|
|
97
|
-
}
|
|
98
|
-
default:
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/** The style's texture over the whole frame: paper grain and copier edges, scanlines, or a vignette. */
|
|
104
|
-
export function StyleOverlay({ styleId }: { styleId: string | null | undefined }) {
|
|
105
|
-
const frame = useCurrentFrame();
|
|
106
|
-
const { width, height, fps } = useVideoConfig();
|
|
107
|
-
const style = getMotionStyle(styleId);
|
|
108
|
-
const overlay = style?.overlay;
|
|
109
|
-
if (!style || !overlay || overlay.kind === "none") return null;
|
|
110
|
-
const u = unit(width, height);
|
|
111
|
-
const amount = overlay.amount;
|
|
112
|
-
return (
|
|
113
|
-
<AbsoluteFill style={{ pointerEvents: "none" }}>
|
|
114
|
-
{overlay.kind === "grain" ? (
|
|
115
|
-
<>
|
|
116
|
-
<Grain opacity={amount} seed={Math.floor(frame / 2) % 12} />
|
|
117
|
-
<Vignette color="#2a1a08" amount={amount * 0.9} />
|
|
118
|
-
</>
|
|
119
|
-
) : null}
|
|
120
|
-
{overlay.kind === "scanlines" ? (
|
|
121
|
-
<>
|
|
122
|
-
<Scanlines u={u} opacity={amount} />
|
|
123
|
-
<div style={{ position: "absolute", inset: 0, background: style.tokens.accent, opacity: 0.035 + hash(frame, 2) * 0.02 }} />
|
|
124
|
-
<Vignette amount={amount * 1.2} />
|
|
125
|
-
</>
|
|
126
|
-
) : null}
|
|
127
|
-
{overlay.kind === "neon" ? (
|
|
128
|
-
<>
|
|
129
|
-
<Scanlines u={u} opacity={amount * 0.5} />
|
|
130
|
-
<div style={{ position: "absolute", inset: 0, background: `linear-gradient(180deg, ${alpha(style.tokens.accent, amount)} 0%, ${alpha(style.tokens.accent, 0)} 18%, ${alpha(style.tokens.line, 0)} 82%, ${alpha(style.tokens.line, amount)} 100%)` }} />
|
|
131
|
-
<Vignette color="#0a0418" amount={amount * 1.6} />
|
|
132
|
-
</>
|
|
133
|
-
) : null}
|
|
134
|
-
{overlay.kind === "vhs" ? <VhsOverlay frame={frame} fps={fps} width={width} height={height} amount={amount} /> : null}
|
|
135
|
-
{overlay.kind === "vignette" ? <Vignette amount={amount} /> : null}
|
|
136
|
-
</AbsoluteFill>
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/** Home-video tape: noise, a tracking band rolling down, a dark TV edge and the camcorder's on-screen text. */
|
|
141
|
-
function VhsOverlay({ frame, fps, width, height, amount }: { frame: number; fps: number; width: number; height: number; amount: number }) {
|
|
142
|
-
const u = unit(width, height);
|
|
143
|
-
const band = ((frame * 9 * u) % (height * 1.6)) - height * 0.3;
|
|
144
|
-
const seconds = Math.floor(frame / fps);
|
|
145
|
-
const counter = `${Math.floor(seconds / 3600)}:${String(Math.floor(seconds / 60) % 60).padStart(2, "0")}:${String(seconds % 60).padStart(2, "0")}`;
|
|
146
|
-
const osd: CSSProperties = {
|
|
147
|
-
position: "absolute",
|
|
148
|
-
fontFamily: FONTS.pixel,
|
|
149
|
-
fontSize: 48 * u,
|
|
150
|
-
lineHeight: 1,
|
|
151
|
-
color: "#ffffff",
|
|
152
|
-
textShadow: `0 0 ${3 * u}px rgba(0,0,0,0.9), ${-3 * u}px 0 rgba(255,40,60,0.6), ${3 * u}px 0 rgba(40,220,255,0.55)`,
|
|
153
|
-
letterSpacing: "0.04em",
|
|
154
|
-
};
|
|
155
|
-
return (
|
|
156
|
-
<>
|
|
157
|
-
<Grain opacity={amount} seed={frame % 9} warm={false} frequency={1.2} />
|
|
158
|
-
<div style={{ position: "absolute", left: 0, right: 0, top: band, height: 70 * u, overflow: "hidden", opacity: 0.55 }}>
|
|
159
|
-
<Grain opacity={0.9} seed={(frame + 3) % 9} warm={false} frequency={2.2} />
|
|
160
|
-
</div>
|
|
161
|
-
<Scanlines u={u} opacity={amount * 0.7} />
|
|
162
|
-
<Vignette amount={amount * 2.2} />
|
|
163
|
-
<div style={{ ...osd, left: 60 * u, top: 70 * u }}>{"\u25B6 PLAY"}</div>
|
|
164
|
-
<div style={{ ...osd, right: 60 * u, top: 70 * u }}>SP {counter}</div>
|
|
165
|
-
<div style={{ ...osd, left: 60 * u, bottom: 80 * u, fontSize: 40 * u }}>
|
|
166
|
-
OCT 21 1996
|
|
167
|
-
<br />
|
|
168
|
-
4:20 PM
|
|
169
|
-
</div>
|
|
170
|
-
</>
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
interface CaptionWord {
|
|
175
|
-
text: string;
|
|
176
|
-
from: number;
|
|
177
|
-
to: number;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const CAPTION_Y: Record<string, number> = { top: 0.14, center: 0.5, lower: 0.7, bottom: 0.84 };
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* A captions clip drawn in the style's look: the current line as the look's chip (ink box,
|
|
184
|
-
* ransom scraps, handwriting, terminal, pill), each word popping in when spoken and the spoken
|
|
185
|
-
* word in the accent. Frames are clip-local, like the words.
|
|
186
|
-
*/
|
|
187
|
-
export function StyledCaptions({
|
|
188
|
-
styleId,
|
|
189
|
-
words,
|
|
190
|
-
position,
|
|
191
|
-
wordsPerLine,
|
|
192
|
-
fontSize: size,
|
|
193
|
-
}: {
|
|
194
|
-
styleId: string | null | undefined;
|
|
195
|
-
words: CaptionWord[];
|
|
196
|
-
position?: string;
|
|
197
|
-
wordsPerLine?: number;
|
|
198
|
-
fontSize?: number;
|
|
199
|
-
}) {
|
|
200
|
-
const frame = useCurrentFrame();
|
|
201
|
-
const { width, height, fps } = useVideoConfig();
|
|
202
|
-
const style = getMotionStyle(styleId);
|
|
203
|
-
if (!style) return null;
|
|
204
|
-
const perLine = Math.max(1, wordsPerLine ?? style.captions.wordsPerLine ?? 3);
|
|
205
|
-
let current = -1;
|
|
206
|
-
for (let i = 0; i < words.length; i += 1) {
|
|
207
|
-
if (words[i].from <= frame) current = i;
|
|
208
|
-
else break;
|
|
209
|
-
}
|
|
210
|
-
if (current < 0) return null;
|
|
211
|
-
const lineStart = Math.floor(current / perLine) * perLine;
|
|
212
|
-
const line = words.slice(lineStart, lineStart + perLine);
|
|
213
|
-
const last = line[line.length - 1];
|
|
214
|
-
const next = words[lineStart + perLine];
|
|
215
|
-
if (frame > last.to + 12 && (!next || next.from > frame)) return null;
|
|
216
|
-
|
|
217
|
-
const kit = lookKit(styleLookProps(style), unit(width, height));
|
|
218
|
-
const fontSize = size ?? Math.min(width, height) * (height > width ? 0.058 : 0.05);
|
|
219
|
-
const text = line
|
|
220
|
-
.map((word, i) => {
|
|
221
|
-
const clean = word.text.replace(/\*/g, "");
|
|
222
|
-
return lineStart + i === current && frame <= word.to + 2 ? `*${clean}*` : clean;
|
|
223
|
-
})
|
|
224
|
-
.join(" ");
|
|
225
|
-
const y = CAPTION_Y[position ?? style.captions.position ?? "lower"] ?? 0.7;
|
|
226
|
-
return (
|
|
227
|
-
<AbsoluteFill style={{ pointerEvents: "none" }}>
|
|
228
|
-
<div style={{ position: "absolute", left: "7%", right: "7%", top: `${y * 100}%`, transform: "translateY(-50%)", display: "flex", justifyContent: "center", textAlign: "center" }}>
|
|
229
|
-
<Chip kit={kit} line={text} fontSize={fontSize} frame={frame} fps={fps} times={line.map((word) => word.from)} seed={lineStart + 1} />
|
|
230
|
-
</div>
|
|
231
|
-
</AbsoluteFill>
|
|
232
|
-
);
|
|
233
|
-
}
|
|
1
|
+
// What a project style does to the whole video, beyond the component props: camera moves on the
|
|
2
|
+
// footage, a texture over everything, and captions drawn in the style's look. The studio runtime
|
|
3
|
+
// calls these (when the page provides them), so a new or changed style ships with the page.
|
|
4
|
+
import type { CSSProperties } from "react";
|
|
5
|
+
import { AbsoluteFill, useCurrentFrame, useVideoConfig } from "remotion";
|
|
6
|
+
import { FONTS, alpha, unit } from "./lib";
|
|
7
|
+
import { Chip, Grain, Scanlines, Vignette, hash, lookKit, type LookProps } from "./looks";
|
|
8
|
+
import { getMotionStyle, type MotionStyle } from "./styles";
|
|
9
|
+
|
|
10
|
+
/** The style's tokens as look props (the first of its fonts the library has). */
|
|
11
|
+
export function styleLookProps(style: MotionStyle): LookProps {
|
|
12
|
+
const font = style.tokens.font.split(",").map((f) => f.trim()).find((f) => f in FONTS) ?? "archivo";
|
|
13
|
+
return {
|
|
14
|
+
look: style.look,
|
|
15
|
+
accent: style.tokens.accent,
|
|
16
|
+
panel: style.tokens.panel,
|
|
17
|
+
panelText: style.tokens.panelText,
|
|
18
|
+
line: style.tokens.line,
|
|
19
|
+
backdrop: style.tokens.backdrop,
|
|
20
|
+
onVideo: style.tokens.text,
|
|
21
|
+
font,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The style's camera on a footage clip at `frame` (clip-local): jump-cut punch-ins with a shake,
|
|
27
|
+
* stop-motion snaps, a slow drift or glitch jumps. Null when the style keeps the camera still.
|
|
28
|
+
*/
|
|
29
|
+
export function styleCamera(
|
|
30
|
+
styleId: string | null | undefined,
|
|
31
|
+
{ frame, durationInFrames, width, height }: { frame: number; durationInFrames: number; width: number; height: number },
|
|
32
|
+
): CSSProperties | null {
|
|
33
|
+
const style = getMotionStyle(styleId);
|
|
34
|
+
const cam = style?.camera;
|
|
35
|
+
if (!cam) return null;
|
|
36
|
+
const moved = moveCamera(cam, { frame, durationInFrames, width, height });
|
|
37
|
+
if (!cam.grade) return moved;
|
|
38
|
+
return { ...moved, filter: cam.grade };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function moveCamera(
|
|
42
|
+
cam: NonNullable<ReturnType<typeof getMotionStyle>>["camera"],
|
|
43
|
+
{ frame, durationInFrames, width, height }: { frame: number; durationInFrames: number; width: number; height: number },
|
|
44
|
+
): CSSProperties | null {
|
|
45
|
+
if (cam.mode === "still") return null;
|
|
46
|
+
const u = unit(width, height);
|
|
47
|
+
const every = Math.max(8, cam.every);
|
|
48
|
+
const seg = Math.floor(frame / every);
|
|
49
|
+
const t = frame - seg * every;
|
|
50
|
+
const origin = "50% 38%";
|
|
51
|
+
switch (cam.mode) {
|
|
52
|
+
case "punch": {
|
|
53
|
+
// Cut to a tighter or wider framing every beat, with a short shake on the cut.
|
|
54
|
+
const levels = [1, cam.zoom, 1.04, cam.zoom * 1.05];
|
|
55
|
+
const scale = levels[seg % levels.length];
|
|
56
|
+
const kick = seg > 0 && t < 8 ? (1 - t / 8) * cam.shake * 18 * u : 0;
|
|
57
|
+
const x = (hash(seg, t) - 0.5) * 2 * kick;
|
|
58
|
+
const y = (hash(seg + 3, t) - 0.5) * 2 * kick;
|
|
59
|
+
return { transform: `translate(${x.toFixed(1)}px, ${y.toFixed(1)}px) scale(${scale})`, transformOrigin: origin };
|
|
60
|
+
}
|
|
61
|
+
case "snap": {
|
|
62
|
+
// Stop-motion: held on twos, a little hand jitter, framing steps with a 2-frame overshoot.
|
|
63
|
+
const held = frame - (frame % 2);
|
|
64
|
+
const levels = [1, cam.zoom, 1.05];
|
|
65
|
+
const over = seg > 0 && t < 2 ? 1.03 : 1;
|
|
66
|
+
const scale = levels[seg % levels.length] * over;
|
|
67
|
+
const x = (hash(7, held) - 0.5) * cam.shake * 6 * u;
|
|
68
|
+
const y = (hash(11, held) - 0.5) * cam.shake * 6 * u;
|
|
69
|
+
const r = (hash(13, held) - 0.5) * cam.shake * 0.5;
|
|
70
|
+
return { transform: `translate(${x.toFixed(1)}px, ${y.toFixed(1)}px) rotate(${r.toFixed(2)}deg) scale(${scale})`, transformOrigin: origin };
|
|
71
|
+
}
|
|
72
|
+
case "drift": {
|
|
73
|
+
// A slow push-in across the clip with a gentle sideways sway.
|
|
74
|
+
const p = Math.min(1, frame / Math.max(1, durationInFrames));
|
|
75
|
+
const scale = 1 + (cam.zoom - 1) * p;
|
|
76
|
+
const x = Math.sin(frame / (every * 0.9)) * cam.shake * 10 * u;
|
|
77
|
+
return { transform: `translate(${x.toFixed(1)}px, 0px) scale(${scale.toFixed(4)})`, transformOrigin: origin };
|
|
78
|
+
}
|
|
79
|
+
case "tape": {
|
|
80
|
+
// Worn tape: a slight wobble on twos, and a tracking hiccup (a sideways tear and a roll) every beat.
|
|
81
|
+
const held = frame - (frame % 2);
|
|
82
|
+
const wobble = (hash(5, held) - 0.5) * cam.shake * 3 * u;
|
|
83
|
+
if (seg > 0 && t < 4) {
|
|
84
|
+
const x = (hash(seg, t) - 0.5) * cam.shake * 40 * u;
|
|
85
|
+
const y = -(4 - t) * cam.shake * 6 * u;
|
|
86
|
+
return { transform: `translate(${x.toFixed(1)}px, ${y.toFixed(1)}px) scale(${cam.zoom})`, transformOrigin: origin };
|
|
87
|
+
}
|
|
88
|
+
return { transform: `translate(${wobble.toFixed(1)}px, 0px) scale(${cam.zoom})`, transformOrigin: origin };
|
|
89
|
+
}
|
|
90
|
+
case "glitch": {
|
|
91
|
+
// Still, except a 3-frame jump every beat.
|
|
92
|
+
if (seg > 0 && t < 3) {
|
|
93
|
+
const x = (hash(seg, t) - 0.5) * cam.shake * 60 * u;
|
|
94
|
+
return { transform: `translate(${x.toFixed(1)}px, 0px) scale(${cam.zoom})`, transformOrigin: origin };
|
|
95
|
+
}
|
|
96
|
+
return { transform: "scale(1.02)", transformOrigin: origin };
|
|
97
|
+
}
|
|
98
|
+
default:
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The style's texture over the whole frame: paper grain and copier edges, scanlines, or a vignette. */
|
|
104
|
+
export function StyleOverlay({ styleId }: { styleId: string | null | undefined }) {
|
|
105
|
+
const frame = useCurrentFrame();
|
|
106
|
+
const { width, height, fps } = useVideoConfig();
|
|
107
|
+
const style = getMotionStyle(styleId);
|
|
108
|
+
const overlay = style?.overlay;
|
|
109
|
+
if (!style || !overlay || overlay.kind === "none") return null;
|
|
110
|
+
const u = unit(width, height);
|
|
111
|
+
const amount = overlay.amount;
|
|
112
|
+
return (
|
|
113
|
+
<AbsoluteFill style={{ pointerEvents: "none" }}>
|
|
114
|
+
{overlay.kind === "grain" ? (
|
|
115
|
+
<>
|
|
116
|
+
<Grain opacity={amount} seed={Math.floor(frame / 2) % 12} />
|
|
117
|
+
<Vignette color="#2a1a08" amount={amount * 0.9} />
|
|
118
|
+
</>
|
|
119
|
+
) : null}
|
|
120
|
+
{overlay.kind === "scanlines" ? (
|
|
121
|
+
<>
|
|
122
|
+
<Scanlines u={u} opacity={amount} />
|
|
123
|
+
<div style={{ position: "absolute", inset: 0, background: style.tokens.accent, opacity: 0.035 + hash(frame, 2) * 0.02 }} />
|
|
124
|
+
<Vignette amount={amount * 1.2} />
|
|
125
|
+
</>
|
|
126
|
+
) : null}
|
|
127
|
+
{overlay.kind === "neon" ? (
|
|
128
|
+
<>
|
|
129
|
+
<Scanlines u={u} opacity={amount * 0.5} />
|
|
130
|
+
<div style={{ position: "absolute", inset: 0, background: `linear-gradient(180deg, ${alpha(style.tokens.accent, amount)} 0%, ${alpha(style.tokens.accent, 0)} 18%, ${alpha(style.tokens.line, 0)} 82%, ${alpha(style.tokens.line, amount)} 100%)` }} />
|
|
131
|
+
<Vignette color="#0a0418" amount={amount * 1.6} />
|
|
132
|
+
</>
|
|
133
|
+
) : null}
|
|
134
|
+
{overlay.kind === "vhs" ? <VhsOverlay frame={frame} fps={fps} width={width} height={height} amount={amount} /> : null}
|
|
135
|
+
{overlay.kind === "vignette" ? <Vignette amount={amount} /> : null}
|
|
136
|
+
</AbsoluteFill>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Home-video tape: noise, a tracking band rolling down, a dark TV edge and the camcorder's on-screen text. */
|
|
141
|
+
function VhsOverlay({ frame, fps, width, height, amount }: { frame: number; fps: number; width: number; height: number; amount: number }) {
|
|
142
|
+
const u = unit(width, height);
|
|
143
|
+
const band = ((frame * 9 * u) % (height * 1.6)) - height * 0.3;
|
|
144
|
+
const seconds = Math.floor(frame / fps);
|
|
145
|
+
const counter = `${Math.floor(seconds / 3600)}:${String(Math.floor(seconds / 60) % 60).padStart(2, "0")}:${String(seconds % 60).padStart(2, "0")}`;
|
|
146
|
+
const osd: CSSProperties = {
|
|
147
|
+
position: "absolute",
|
|
148
|
+
fontFamily: FONTS.pixel,
|
|
149
|
+
fontSize: 48 * u,
|
|
150
|
+
lineHeight: 1,
|
|
151
|
+
color: "#ffffff",
|
|
152
|
+
textShadow: `0 0 ${3 * u}px rgba(0,0,0,0.9), ${-3 * u}px 0 rgba(255,40,60,0.6), ${3 * u}px 0 rgba(40,220,255,0.55)`,
|
|
153
|
+
letterSpacing: "0.04em",
|
|
154
|
+
};
|
|
155
|
+
return (
|
|
156
|
+
<>
|
|
157
|
+
<Grain opacity={amount} seed={frame % 9} warm={false} frequency={1.2} />
|
|
158
|
+
<div style={{ position: "absolute", left: 0, right: 0, top: band, height: 70 * u, overflow: "hidden", opacity: 0.55 }}>
|
|
159
|
+
<Grain opacity={0.9} seed={(frame + 3) % 9} warm={false} frequency={2.2} />
|
|
160
|
+
</div>
|
|
161
|
+
<Scanlines u={u} opacity={amount * 0.7} />
|
|
162
|
+
<Vignette amount={amount * 2.2} />
|
|
163
|
+
<div style={{ ...osd, left: 60 * u, top: 70 * u }}>{"\u25B6 PLAY"}</div>
|
|
164
|
+
<div style={{ ...osd, right: 60 * u, top: 70 * u }}>SP {counter}</div>
|
|
165
|
+
<div style={{ ...osd, left: 60 * u, bottom: 80 * u, fontSize: 40 * u }}>
|
|
166
|
+
OCT 21 1996
|
|
167
|
+
<br />
|
|
168
|
+
4:20 PM
|
|
169
|
+
</div>
|
|
170
|
+
</>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
interface CaptionWord {
|
|
175
|
+
text: string;
|
|
176
|
+
from: number;
|
|
177
|
+
to: number;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const CAPTION_Y: Record<string, number> = { top: 0.14, center: 0.5, lower: 0.7, bottom: 0.84 };
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* A captions clip drawn in the style's look: the current line as the look's chip (ink box,
|
|
184
|
+
* ransom scraps, handwriting, terminal, pill), each word popping in when spoken and the spoken
|
|
185
|
+
* word in the accent. Frames are clip-local, like the words.
|
|
186
|
+
*/
|
|
187
|
+
export function StyledCaptions({
|
|
188
|
+
styleId,
|
|
189
|
+
words,
|
|
190
|
+
position,
|
|
191
|
+
wordsPerLine,
|
|
192
|
+
fontSize: size,
|
|
193
|
+
}: {
|
|
194
|
+
styleId: string | null | undefined;
|
|
195
|
+
words: CaptionWord[];
|
|
196
|
+
position?: string;
|
|
197
|
+
wordsPerLine?: number;
|
|
198
|
+
fontSize?: number;
|
|
199
|
+
}) {
|
|
200
|
+
const frame = useCurrentFrame();
|
|
201
|
+
const { width, height, fps } = useVideoConfig();
|
|
202
|
+
const style = getMotionStyle(styleId);
|
|
203
|
+
if (!style) return null;
|
|
204
|
+
const perLine = Math.max(1, wordsPerLine ?? style.captions.wordsPerLine ?? 3);
|
|
205
|
+
let current = -1;
|
|
206
|
+
for (let i = 0; i < words.length; i += 1) {
|
|
207
|
+
if (words[i].from <= frame) current = i;
|
|
208
|
+
else break;
|
|
209
|
+
}
|
|
210
|
+
if (current < 0) return null;
|
|
211
|
+
const lineStart = Math.floor(current / perLine) * perLine;
|
|
212
|
+
const line = words.slice(lineStart, lineStart + perLine);
|
|
213
|
+
const last = line[line.length - 1];
|
|
214
|
+
const next = words[lineStart + perLine];
|
|
215
|
+
if (frame > last.to + 12 && (!next || next.from > frame)) return null;
|
|
216
|
+
|
|
217
|
+
const kit = lookKit(styleLookProps(style), unit(width, height));
|
|
218
|
+
const fontSize = size ?? Math.min(width, height) * (height > width ? 0.058 : 0.05);
|
|
219
|
+
const text = line
|
|
220
|
+
.map((word, i) => {
|
|
221
|
+
const clean = word.text.replace(/\*/g, "");
|
|
222
|
+
return lineStart + i === current && frame <= word.to + 2 ? `*${clean}*` : clean;
|
|
223
|
+
})
|
|
224
|
+
.join(" ");
|
|
225
|
+
const y = CAPTION_Y[position ?? style.captions.position ?? "lower"] ?? 0.7;
|
|
226
|
+
return (
|
|
227
|
+
<AbsoluteFill style={{ pointerEvents: "none" }}>
|
|
228
|
+
<div style={{ position: "absolute", left: "7%", right: "7%", top: `${y * 100}%`, transform: "translateY(-50%)", display: "flex", justifyContent: "center", textAlign: "center" }}>
|
|
229
|
+
<Chip kit={kit} line={text} fontSize={fontSize} frame={frame} fps={fps} times={line.map((word) => word.from)} seed={lineStart + 1} />
|
|
230
|
+
</div>
|
|
231
|
+
</AbsoluteFill>
|
|
232
|
+
);
|
|
233
|
+
}
|