agentcut 0.2.26 → 0.2.28
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 -177
- 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 +24 -24
- 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.js +8 -0
- 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/release-cursor.js +21 -21
- package/dist/studio/release-video.js +10 -10
- package/dist/studio/schema.d.ts +102 -0
- package/dist/studio/schema.js +5 -0
- package/dist/studio/schema.js.map +1 -1
- package/dist/studio/tools.js +7 -0
- package/dist/studio/tools.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 +1207 -1189
- package/template/runtime/helpers.tsx +230 -230
- package/template/runtime/index.tsx +26 -22
- package/template/runtime/types.ts +324 -315
- package/template/skill/SKILL.md +188 -187
- 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 +97 -97
- package/template/skill/references/editing-styles.md +57 -57
- package/template/skill/references/feature-launch.md +34 -34
- package/template/skill/references/footage.md +72 -72
- package/template/skill/references/format.md +145 -142
- package/template/skill/references/how-to.md +146 -146
- package/template/skill/references/launch-direction.md +89 -89
- package/template/skill/references/loops.md +151 -151
- package/template/skill/references/mcp-external.md +19 -19
- 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 +134 -134
- package/template/skill/references/release-capture.md +53 -53
- package/template/skill/references/sound.md +167 -166
- 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,73 +1,73 @@
|
|
|
1
|
-
// A photo as a torn, taped cut-out that gets slapped onto the wall. Treatments: color, xerox, red, pink, yellow.
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { AbsoluteFill, Img, useCurrentFrame } from "remotion";
|
|
4
|
-
import { asset, type SceneProps } from "agentcut";
|
|
5
|
-
import { P, Paper, Tape, Halftone, areas, backOut, easeIn, jit, lerp, st, type Side } from "./lib/punk";
|
|
6
|
-
|
|
7
|
-
type Props = SceneProps & {
|
|
8
|
-
src?: string;
|
|
9
|
-
imgAspect?: number; // natural width / height of the image
|
|
10
|
-
side?: Side;
|
|
11
|
-
treatment?: "color" | "xerox" | "red" | "pink" | "yellow" | "teal";
|
|
12
|
-
aspect?: number; // frame width / height
|
|
13
|
-
zoom?: number; // 1 = whole photo
|
|
14
|
-
fx?: number; // focus point in the photo (0..1)
|
|
15
|
-
fy?: number;
|
|
16
|
-
rot?: number;
|
|
17
|
-
scale?: number; // size multiplier of the picture area
|
|
18
|
-
from?: "left" | "right" | "top" | "bottom";
|
|
19
|
-
seed?: number;
|
|
20
|
-
x?: number; // optional center override (fraction of width)
|
|
21
|
-
y?: number; // optional center override (fraction of height)
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const TINT: Record<string, string> = { red: P.red, pink: P.pink, yellow: P.yellow, teal: P.teal };
|
|
25
|
-
|
|
26
|
-
export default function Photo({ src = "assets/photo.jpg", imgAspect = 0.75, side = "right", treatment = "color", aspect = 0.78, zoom = 1, fx = 0.52, fy = 0.4, rot = -4, scale = 1, from = "bottom", seed = 3, x, y, width, height, clip }: Props) {
|
|
27
|
-
const f = useCurrentFrame();
|
|
28
|
-
const D = clip.duration;
|
|
29
|
-
const vertical = height > width;
|
|
30
|
-
const pic = areas(width, height, side).pic;
|
|
31
|
-
const cx = x != null ? x * width : pic.cx;
|
|
32
|
-
const cy = y != null ? y * height : pic.cy;
|
|
33
|
-
const S = pic.size * scale;
|
|
34
|
-
const h = aspect >= 1 ? (S * 1.15) / aspect : S;
|
|
35
|
-
const w = aspect >= 1 ? S * 1.15 : S * aspect;
|
|
36
|
-
const rim = Math.max(14, S * 0.035);
|
|
37
|
-
const iw = w - rim * 2, ih = h - rim * 2;
|
|
38
|
-
|
|
39
|
-
// photo cover + zoom around the focus point
|
|
40
|
-
const drift = lerp(1, 1.06, f / Math.max(1, D));
|
|
41
|
-
const imgW = Math.max(iw, ih * imgAspect) * zoom * drift;
|
|
42
|
-
const imgH = imgW / imgAspect;
|
|
43
|
-
const left = Math.min(0, Math.max(iw - imgW, iw / 2 - fx * imgW));
|
|
44
|
-
const top = Math.min(0, Math.max(ih - imgH, ih / 2 - fy * imgH));
|
|
45
|
-
|
|
46
|
-
const inT = st(f, 0, 10, backOut);
|
|
47
|
-
const outT = st(f, D - 9, 8, easeIn);
|
|
48
|
-
const off = vertical ? height : width;
|
|
49
|
-
const dir = { left: [-1, 0], right: [1, 0], top: [0, -1], bottom: [0, 1] }[from];
|
|
50
|
-
const dx = dir[0] * off * (1 - inT) - dir[0] * off * outT * 0.8 + (from === "left" || from === "right" ? 0 : 0);
|
|
51
|
-
const dy = dir[1] * off * (1 - inT) + off * outT * 0.9;
|
|
52
|
-
const j = jit(seed, f, 2);
|
|
53
|
-
const r = rot + (1 - inT) * 25 * (dir[0] || 1) + outT * 30 + j.r;
|
|
54
|
-
|
|
55
|
-
const filter = treatment === "color" ? "saturate(1.25) contrast(1.1)" : "grayscale(1) contrast(1.9) brightness(1.1)";
|
|
56
|
-
const tint = TINT[treatment];
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<AbsoluteFill>
|
|
60
|
-
<div style={{ position: "absolute", left: cx - w / 2 + dx + j.x, top: cy - h / 2 + dy + j.y, width: w, height: h, transform: `rotate(${r}deg)` }}>
|
|
61
|
-
<Paper w={w} h={h} seed={seed} tex="white" kind="tear" shadow={1.4}>
|
|
62
|
-
<div style={{ position: "absolute", left: rim, top: rim, width: iw, height: ih, overflow: "hidden", background: P.ink }}>
|
|
63
|
-
<Img src={asset(src)} style={{ position: "absolute", left, top, width: imgW, height: imgH, filter }} />
|
|
64
|
-
{tint ? <div style={{ position: "absolute", inset: 0, background: tint, opacity: 0.42 }} /> : null}
|
|
65
|
-
{treatment !== "color" ? <Halftone x={iw * 0.8} y={ih * 0.85} size={Math.max(iw, ih) * 0.9} color="black" o={0.35} /> : null}
|
|
66
|
-
</div>
|
|
67
|
-
</Paper>
|
|
68
|
-
<Tape x={w * 0.5} y={4} w={Math.min(220, w * 0.4)} rot={-3 + (seed % 5)} seed={seed} />
|
|
69
|
-
<Tape x={w * 0.92} y={h * 0.96} w={Math.min(170, w * 0.32)} rot={-38} seed={seed + 1} />
|
|
70
|
-
</div>
|
|
71
|
-
</AbsoluteFill>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
1
|
+
// A photo as a torn, taped cut-out that gets slapped onto the wall. Treatments: color, xerox, red, pink, yellow.
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { AbsoluteFill, Img, useCurrentFrame } from "remotion";
|
|
4
|
+
import { asset, type SceneProps } from "agentcut";
|
|
5
|
+
import { P, Paper, Tape, Halftone, areas, backOut, easeIn, jit, lerp, st, type Side } from "./lib/punk";
|
|
6
|
+
|
|
7
|
+
type Props = SceneProps & {
|
|
8
|
+
src?: string;
|
|
9
|
+
imgAspect?: number; // natural width / height of the image
|
|
10
|
+
side?: Side;
|
|
11
|
+
treatment?: "color" | "xerox" | "red" | "pink" | "yellow" | "teal";
|
|
12
|
+
aspect?: number; // frame width / height
|
|
13
|
+
zoom?: number; // 1 = whole photo
|
|
14
|
+
fx?: number; // focus point in the photo (0..1)
|
|
15
|
+
fy?: number;
|
|
16
|
+
rot?: number;
|
|
17
|
+
scale?: number; // size multiplier of the picture area
|
|
18
|
+
from?: "left" | "right" | "top" | "bottom";
|
|
19
|
+
seed?: number;
|
|
20
|
+
x?: number; // optional center override (fraction of width)
|
|
21
|
+
y?: number; // optional center override (fraction of height)
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const TINT: Record<string, string> = { red: P.red, pink: P.pink, yellow: P.yellow, teal: P.teal };
|
|
25
|
+
|
|
26
|
+
export default function Photo({ src = "assets/photo.jpg", imgAspect = 0.75, side = "right", treatment = "color", aspect = 0.78, zoom = 1, fx = 0.52, fy = 0.4, rot = -4, scale = 1, from = "bottom", seed = 3, x, y, width, height, clip }: Props) {
|
|
27
|
+
const f = useCurrentFrame();
|
|
28
|
+
const D = clip.duration;
|
|
29
|
+
const vertical = height > width;
|
|
30
|
+
const pic = areas(width, height, side).pic;
|
|
31
|
+
const cx = x != null ? x * width : pic.cx;
|
|
32
|
+
const cy = y != null ? y * height : pic.cy;
|
|
33
|
+
const S = pic.size * scale;
|
|
34
|
+
const h = aspect >= 1 ? (S * 1.15) / aspect : S;
|
|
35
|
+
const w = aspect >= 1 ? S * 1.15 : S * aspect;
|
|
36
|
+
const rim = Math.max(14, S * 0.035);
|
|
37
|
+
const iw = w - rim * 2, ih = h - rim * 2;
|
|
38
|
+
|
|
39
|
+
// photo cover + zoom around the focus point
|
|
40
|
+
const drift = lerp(1, 1.06, f / Math.max(1, D));
|
|
41
|
+
const imgW = Math.max(iw, ih * imgAspect) * zoom * drift;
|
|
42
|
+
const imgH = imgW / imgAspect;
|
|
43
|
+
const left = Math.min(0, Math.max(iw - imgW, iw / 2 - fx * imgW));
|
|
44
|
+
const top = Math.min(0, Math.max(ih - imgH, ih / 2 - fy * imgH));
|
|
45
|
+
|
|
46
|
+
const inT = st(f, 0, 10, backOut);
|
|
47
|
+
const outT = st(f, D - 9, 8, easeIn);
|
|
48
|
+
const off = vertical ? height : width;
|
|
49
|
+
const dir = { left: [-1, 0], right: [1, 0], top: [0, -1], bottom: [0, 1] }[from];
|
|
50
|
+
const dx = dir[0] * off * (1 - inT) - dir[0] * off * outT * 0.8 + (from === "left" || from === "right" ? 0 : 0);
|
|
51
|
+
const dy = dir[1] * off * (1 - inT) + off * outT * 0.9;
|
|
52
|
+
const j = jit(seed, f, 2);
|
|
53
|
+
const r = rot + (1 - inT) * 25 * (dir[0] || 1) + outT * 30 + j.r;
|
|
54
|
+
|
|
55
|
+
const filter = treatment === "color" ? "saturate(1.25) contrast(1.1)" : "grayscale(1) contrast(1.9) brightness(1.1)";
|
|
56
|
+
const tint = TINT[treatment];
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<AbsoluteFill>
|
|
60
|
+
<div style={{ position: "absolute", left: cx - w / 2 + dx + j.x, top: cy - h / 2 + dy + j.y, width: w, height: h, transform: `rotate(${r}deg)` }}>
|
|
61
|
+
<Paper w={w} h={h} seed={seed} tex="white" kind="tear" shadow={1.4}>
|
|
62
|
+
<div style={{ position: "absolute", left: rim, top: rim, width: iw, height: ih, overflow: "hidden", background: P.ink }}>
|
|
63
|
+
<Img src={asset(src)} style={{ position: "absolute", left, top, width: imgW, height: imgH, filter }} />
|
|
64
|
+
{tint ? <div style={{ position: "absolute", inset: 0, background: tint, opacity: 0.42 }} /> : null}
|
|
65
|
+
{treatment !== "color" ? <Halftone x={iw * 0.8} y={ih * 0.85} size={Math.max(iw, ih) * 0.9} color="black" o={0.35} /> : null}
|
|
66
|
+
</div>
|
|
67
|
+
</Paper>
|
|
68
|
+
<Tape x={w * 0.5} y={4} w={Math.min(220, w * 0.4)} rot={-3 + (seed % 5)} seed={seed} />
|
|
69
|
+
<Tape x={w * 0.92} y={h * 0.96} w={Math.min(170, w * 0.32)} rot={-38} seed={seed + 1} />
|
|
70
|
+
</div>
|
|
71
|
+
</AbsoluteFill>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
// One sung line as a ransom note: each word is a cut-out paper chip that slaps down on its sung frame.
|
|
2
|
-
// Words starting with "*" are accents: cut letter by letter, bigger. Props: words [{t, at}] (frames from clip start).
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { AbsoluteFill, useCurrentFrame } from "remotion";
|
|
5
|
-
import type { SceneProps } from "agentcut";
|
|
6
|
-
import { CHIPS, FACES, P, areas, easeIn, hash, jit, outline, slap, st, strSeed, type Side } from "./lib/punk";
|
|
7
|
-
import { Img } from "remotion";
|
|
8
|
-
import { asset } from "agentcut";
|
|
9
|
-
|
|
10
|
-
type Word = { t: string; at: number };
|
|
11
|
-
type Props = SceneProps & {
|
|
12
|
-
words: Word[];
|
|
13
|
-
side?: Side;
|
|
14
|
-
seed?: number;
|
|
15
|
-
size?: number; // max font size px (wide); mobile scales
|
|
16
|
-
letters?: boolean; // cut every word letter by letter
|
|
17
|
-
stagger?: number; // frames between letters of an accent word
|
|
18
|
-
align?: "left" | "center" | "right";
|
|
19
|
-
yShift?: number; // fraction of height
|
|
20
|
-
palette?: number[]; // indexes into CHIPS to use
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
function Chip({ text, size, face, chip, seed, rot, f, t0, exitT, exitDir }: {
|
|
24
|
-
text: string; size: number; face: (typeof FACES)[number]; chip: (typeof CHIPS)[number]; seed: number; rot: number;
|
|
25
|
-
f: number; t0: number; exitT: number; exitDir: number;
|
|
26
|
-
}) {
|
|
27
|
-
const [family, mult, upper] = face;
|
|
28
|
-
const [bg, fg, tex] = chip;
|
|
29
|
-
const fs = size * mult;
|
|
30
|
-
const s = slap(f, t0, 1.9);
|
|
31
|
-
const j = f >= t0 + 8 ? jit(seed, f, 1.6) : { x: 0, y: 0, r: 0 };
|
|
32
|
-
const e = exitT;
|
|
33
|
-
const estW = text.length * fs * 0.6 + fs * 0.5;
|
|
34
|
-
const estH = fs * 1.4;
|
|
35
|
-
const clip = outline(estW, estH, seed, hash(seed, 9) > 0.5 ? "tear" : "cut");
|
|
36
|
-
return (
|
|
37
|
-
<div style={{
|
|
38
|
-
position: "relative", display: "inline-block", margin: `${size * 0.05}px ${size * 0.11}px`,
|
|
39
|
-
opacity: s.o * (1 - e),
|
|
40
|
-
transform: `translate(${j.x + e * exitDir * 260}px, ${j.y - e * 380}px) rotate(${rot + j.r + e * exitDir * 70}deg) scale(${s.s})`,
|
|
41
|
-
}}>
|
|
42
|
-
<div style={{ position: "absolute", left: 7, top: 11, right: -7, bottom: -11, background: "rgba(20,12,4,0.45)", clipPath: clip }} />
|
|
43
|
-
<div style={{ position: "relative", background: bg, clipPath: clip, overflow: "hidden" }}>
|
|
44
|
-
{tex ? <Img src={asset(`assets/paper/${tex === "newsprint" ? "newsprint" : tex === "kraft" ? "kraft" : tex === "white" ? "paper-white" : "paper-cream"}.jpg`)}
|
|
45
|
-
style={{ position: "absolute", left: -((seed * 37) % 400), top: -((seed * 53) % 400), width: 1024, height: 1024 }} />
|
|
46
|
-
: <Img src={asset("assets/paper/grain-overlay.png")} style={{ position: "absolute", left: -((seed * 37) % 300), top: -((seed * 53) % 300), width: 1024, height: 1024, opacity: 0.4 }} />}
|
|
47
|
-
<div style={{
|
|
48
|
-
position: "relative", fontFamily: family, fontSize: fs, lineHeight: 1.08, color: fg, whiteSpace: "nowrap",
|
|
49
|
-
textTransform: upper ? "uppercase" : "none", padding: `${fs * 0.1}px ${fs * 0.2}px ${fs * 0.06}px`,
|
|
50
|
-
}}>{text}</div>
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export default function Ransom({ words = [], side = "left", seed = 1, size, letters = false, stagger = 2, align, yShift = 0, palette, width, height, clip }: Props) {
|
|
57
|
-
const f = useCurrentFrame();
|
|
58
|
-
const vertical = height > width;
|
|
59
|
-
const A = areas(width, height, side).text;
|
|
60
|
-
const base = seed * 101 + strSeed(words.map((w) => w.t).join(" "));
|
|
61
|
-
const chips = palette && palette.length ? palette.map((i) => CHIPS[i % CHIPS.length]) : CHIPS;
|
|
62
|
-
|
|
63
|
-
// fit the type to the area
|
|
64
|
-
const chars = words.reduce((n, w) => n + w.t.replace("*", "").length * (w.t.startsWith("*") ? 1.5 : 1), 0) + words.length * 0.8;
|
|
65
|
-
const maxSize = size ?? (vertical ? 120 : 118);
|
|
66
|
-
const fit = Math.sqrt((A.w * A.h * 0.85) / (Math.max(1, chars) * 0.62 * 1.5));
|
|
67
|
-
// the widest single word (accent words are cut letter by letter, ~1.3em per letter) must fit the area
|
|
68
|
-
const widest = Math.max(...words.map((w) => {
|
|
69
|
-
const n = w.t.replace("*", "").length;
|
|
70
|
-
return letters || w.t.startsWith("*") ? n * 1.34 + 0.3 : n * 0.66 + 0.6;
|
|
71
|
-
}), 1);
|
|
72
|
-
const fs = Math.max(40, Math.min(maxSize * (vertical ? 1.05 : 1), fit, (A.w * 0.94) / widest));
|
|
73
|
-
|
|
74
|
-
const D = clip.duration;
|
|
75
|
-
let k = 0;
|
|
76
|
-
const nodes = words.map((w, wi) => {
|
|
77
|
-
const accent = letters || w.t.startsWith("*");
|
|
78
|
-
const text = w.t.replace(/^\*/, "");
|
|
79
|
-
const ws = base + wi * 17;
|
|
80
|
-
const dir = hash(ws, 5) > 0.5 ? 1 : -1;
|
|
81
|
-
if (!accent) {
|
|
82
|
-
const face = FACES[Math.floor(hash(ws, 1) * FACES.length)];
|
|
83
|
-
const chip = chips[Math.floor(hash(ws, 2) * chips.length)];
|
|
84
|
-
const exitT = st(f, D - 10 + (k++) * 0.6, 7, easeIn);
|
|
85
|
-
return (
|
|
86
|
-
<Chip key={wi} text={text} size={fs} face={face} chip={chip} seed={ws} rot={(hash(ws, 3) - 0.5) * 9}
|
|
87
|
-
f={f} t0={w.at} exitT={exitT} exitDir={dir} />
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
return (
|
|
91
|
-
<div key={wi} style={{ display: "inline-flex", alignItems: "center", margin: `0 ${fs * 0.12}px` }}>
|
|
92
|
-
{Array.from(text.toUpperCase()).map((ch, ci) => {
|
|
93
|
-
if (ch === " ") return <div key={ci} style={{ width: fs * 0.35 }} />;
|
|
94
|
-
const ls = ws + ci * 7;
|
|
95
|
-
const face = FACES[Math.floor(hash(ls, 1) * FACES.length)];
|
|
96
|
-
const chip = chips[Math.floor(hash(ls, 2) * chips.length)];
|
|
97
|
-
const exitT = st(f, D - 10 + (k++) * 0.4, 7, easeIn);
|
|
98
|
-
return (
|
|
99
|
-
<Chip key={ci} text={ch} size={fs * 1.2} face={face} chip={chip} seed={ls} rot={(hash(ls, 3) - 0.5) * 18}
|
|
100
|
-
f={f} t0={w.at + ci * stagger} exitT={exitT} exitDir={hash(ls, 5) > 0.5 ? 1 : -1} />
|
|
101
|
-
);
|
|
102
|
-
})}
|
|
103
|
-
</div>
|
|
104
|
-
);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
const justify = align ?? (vertical || side === "center" ? "center" : side === "left" ? "flex-start" : "flex-end");
|
|
108
|
-
return (
|
|
109
|
-
<AbsoluteFill>
|
|
110
|
-
<div style={{
|
|
111
|
-
position: "absolute", left: A.x, top: A.y + yShift * height, width: A.w, height: A.h,
|
|
112
|
-
display: "flex", flexWrap: "wrap", alignContent: "center", alignItems: "center", justifyContent: justify,
|
|
113
|
-
color: P.ink,
|
|
114
|
-
}}>
|
|
115
|
-
{nodes}
|
|
116
|
-
</div>
|
|
117
|
-
</AbsoluteFill>
|
|
118
|
-
);
|
|
119
|
-
}
|
|
1
|
+
// One sung line as a ransom note: each word is a cut-out paper chip that slaps down on its sung frame.
|
|
2
|
+
// Words starting with "*" are accents: cut letter by letter, bigger. Props: words [{t, at}] (frames from clip start).
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { AbsoluteFill, useCurrentFrame } from "remotion";
|
|
5
|
+
import type { SceneProps } from "agentcut";
|
|
6
|
+
import { CHIPS, FACES, P, areas, easeIn, hash, jit, outline, slap, st, strSeed, type Side } from "./lib/punk";
|
|
7
|
+
import { Img } from "remotion";
|
|
8
|
+
import { asset } from "agentcut";
|
|
9
|
+
|
|
10
|
+
type Word = { t: string; at: number };
|
|
11
|
+
type Props = SceneProps & {
|
|
12
|
+
words: Word[];
|
|
13
|
+
side?: Side;
|
|
14
|
+
seed?: number;
|
|
15
|
+
size?: number; // max font size px (wide); mobile scales
|
|
16
|
+
letters?: boolean; // cut every word letter by letter
|
|
17
|
+
stagger?: number; // frames between letters of an accent word
|
|
18
|
+
align?: "left" | "center" | "right";
|
|
19
|
+
yShift?: number; // fraction of height
|
|
20
|
+
palette?: number[]; // indexes into CHIPS to use
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function Chip({ text, size, face, chip, seed, rot, f, t0, exitT, exitDir }: {
|
|
24
|
+
text: string; size: number; face: (typeof FACES)[number]; chip: (typeof CHIPS)[number]; seed: number; rot: number;
|
|
25
|
+
f: number; t0: number; exitT: number; exitDir: number;
|
|
26
|
+
}) {
|
|
27
|
+
const [family, mult, upper] = face;
|
|
28
|
+
const [bg, fg, tex] = chip;
|
|
29
|
+
const fs = size * mult;
|
|
30
|
+
const s = slap(f, t0, 1.9);
|
|
31
|
+
const j = f >= t0 + 8 ? jit(seed, f, 1.6) : { x: 0, y: 0, r: 0 };
|
|
32
|
+
const e = exitT;
|
|
33
|
+
const estW = text.length * fs * 0.6 + fs * 0.5;
|
|
34
|
+
const estH = fs * 1.4;
|
|
35
|
+
const clip = outline(estW, estH, seed, hash(seed, 9) > 0.5 ? "tear" : "cut");
|
|
36
|
+
return (
|
|
37
|
+
<div style={{
|
|
38
|
+
position: "relative", display: "inline-block", margin: `${size * 0.05}px ${size * 0.11}px`,
|
|
39
|
+
opacity: s.o * (1 - e),
|
|
40
|
+
transform: `translate(${j.x + e * exitDir * 260}px, ${j.y - e * 380}px) rotate(${rot + j.r + e * exitDir * 70}deg) scale(${s.s})`,
|
|
41
|
+
}}>
|
|
42
|
+
<div style={{ position: "absolute", left: 7, top: 11, right: -7, bottom: -11, background: "rgba(20,12,4,0.45)", clipPath: clip }} />
|
|
43
|
+
<div style={{ position: "relative", background: bg, clipPath: clip, overflow: "hidden" }}>
|
|
44
|
+
{tex ? <Img src={asset(`assets/paper/${tex === "newsprint" ? "newsprint" : tex === "kraft" ? "kraft" : tex === "white" ? "paper-white" : "paper-cream"}.jpg`)}
|
|
45
|
+
style={{ position: "absolute", left: -((seed * 37) % 400), top: -((seed * 53) % 400), width: 1024, height: 1024 }} />
|
|
46
|
+
: <Img src={asset("assets/paper/grain-overlay.png")} style={{ position: "absolute", left: -((seed * 37) % 300), top: -((seed * 53) % 300), width: 1024, height: 1024, opacity: 0.4 }} />}
|
|
47
|
+
<div style={{
|
|
48
|
+
position: "relative", fontFamily: family, fontSize: fs, lineHeight: 1.08, color: fg, whiteSpace: "nowrap",
|
|
49
|
+
textTransform: upper ? "uppercase" : "none", padding: `${fs * 0.1}px ${fs * 0.2}px ${fs * 0.06}px`,
|
|
50
|
+
}}>{text}</div>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default function Ransom({ words = [], side = "left", seed = 1, size, letters = false, stagger = 2, align, yShift = 0, palette, width, height, clip }: Props) {
|
|
57
|
+
const f = useCurrentFrame();
|
|
58
|
+
const vertical = height > width;
|
|
59
|
+
const A = areas(width, height, side).text;
|
|
60
|
+
const base = seed * 101 + strSeed(words.map((w) => w.t).join(" "));
|
|
61
|
+
const chips = palette && palette.length ? palette.map((i) => CHIPS[i % CHIPS.length]) : CHIPS;
|
|
62
|
+
|
|
63
|
+
// fit the type to the area
|
|
64
|
+
const chars = words.reduce((n, w) => n + w.t.replace("*", "").length * (w.t.startsWith("*") ? 1.5 : 1), 0) + words.length * 0.8;
|
|
65
|
+
const maxSize = size ?? (vertical ? 120 : 118);
|
|
66
|
+
const fit = Math.sqrt((A.w * A.h * 0.85) / (Math.max(1, chars) * 0.62 * 1.5));
|
|
67
|
+
// the widest single word (accent words are cut letter by letter, ~1.3em per letter) must fit the area
|
|
68
|
+
const widest = Math.max(...words.map((w) => {
|
|
69
|
+
const n = w.t.replace("*", "").length;
|
|
70
|
+
return letters || w.t.startsWith("*") ? n * 1.34 + 0.3 : n * 0.66 + 0.6;
|
|
71
|
+
}), 1);
|
|
72
|
+
const fs = Math.max(40, Math.min(maxSize * (vertical ? 1.05 : 1), fit, (A.w * 0.94) / widest));
|
|
73
|
+
|
|
74
|
+
const D = clip.duration;
|
|
75
|
+
let k = 0;
|
|
76
|
+
const nodes = words.map((w, wi) => {
|
|
77
|
+
const accent = letters || w.t.startsWith("*");
|
|
78
|
+
const text = w.t.replace(/^\*/, "");
|
|
79
|
+
const ws = base + wi * 17;
|
|
80
|
+
const dir = hash(ws, 5) > 0.5 ? 1 : -1;
|
|
81
|
+
if (!accent) {
|
|
82
|
+
const face = FACES[Math.floor(hash(ws, 1) * FACES.length)];
|
|
83
|
+
const chip = chips[Math.floor(hash(ws, 2) * chips.length)];
|
|
84
|
+
const exitT = st(f, D - 10 + (k++) * 0.6, 7, easeIn);
|
|
85
|
+
return (
|
|
86
|
+
<Chip key={wi} text={text} size={fs} face={face} chip={chip} seed={ws} rot={(hash(ws, 3) - 0.5) * 9}
|
|
87
|
+
f={f} t0={w.at} exitT={exitT} exitDir={dir} />
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
return (
|
|
91
|
+
<div key={wi} style={{ display: "inline-flex", alignItems: "center", margin: `0 ${fs * 0.12}px` }}>
|
|
92
|
+
{Array.from(text.toUpperCase()).map((ch, ci) => {
|
|
93
|
+
if (ch === " ") return <div key={ci} style={{ width: fs * 0.35 }} />;
|
|
94
|
+
const ls = ws + ci * 7;
|
|
95
|
+
const face = FACES[Math.floor(hash(ls, 1) * FACES.length)];
|
|
96
|
+
const chip = chips[Math.floor(hash(ls, 2) * chips.length)];
|
|
97
|
+
const exitT = st(f, D - 10 + (k++) * 0.4, 7, easeIn);
|
|
98
|
+
return (
|
|
99
|
+
<Chip key={ci} text={ch} size={fs * 1.2} face={face} chip={chip} seed={ls} rot={(hash(ls, 3) - 0.5) * 18}
|
|
100
|
+
f={f} t0={w.at + ci * stagger} exitT={exitT} exitDir={hash(ls, 5) > 0.5 ? 1 : -1} />
|
|
101
|
+
);
|
|
102
|
+
})}
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const justify = align ?? (vertical || side === "center" ? "center" : side === "left" ? "flex-start" : "flex-end");
|
|
108
|
+
return (
|
|
109
|
+
<AbsoluteFill>
|
|
110
|
+
<div style={{
|
|
111
|
+
position: "absolute", left: A.x, top: A.y + yShift * height, width: A.w, height: A.h,
|
|
112
|
+
display: "flex", flexWrap: "wrap", alignContent: "center", alignItems: "center", justifyContent: justify,
|
|
113
|
+
color: P.ink,
|
|
114
|
+
}}>
|
|
115
|
+
{nodes}
|
|
116
|
+
</div>
|
|
117
|
+
</AbsoluteFill>
|
|
118
|
+
);
|
|
119
|
+
}
|