agentcut 0.0.0-stage → 0.1.1

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.
Files changed (248) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -2
  3. package/dist/bridge.d.ts +45 -0
  4. package/dist/bridge.js +691 -0
  5. package/dist/bridge.js.map +1 -0
  6. package/dist/config.d.ts +13 -0
  7. package/dist/config.js +50 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.js +35 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/log.d.ts +1 -0
  13. package/dist/log.js +14 -0
  14. package/dist/log.js.map +1 -0
  15. package/dist/studio/agents/claude.d.ts +7 -0
  16. package/dist/studio/agents/claude.js +155 -0
  17. package/dist/studio/agents/claude.js.map +1 -0
  18. package/dist/studio/agents/codex.d.ts +4 -0
  19. package/dist/studio/agents/codex.js +169 -0
  20. package/dist/studio/agents/codex.js.map +1 -0
  21. package/dist/studio/agents/index.d.ts +8 -0
  22. package/dist/studio/agents/index.js +50 -0
  23. package/dist/studio/agents/index.js.map +1 -0
  24. package/dist/studio/agents/types.d.ts +131 -0
  25. package/dist/studio/agents/types.js +11 -0
  26. package/dist/studio/agents/types.js.map +1 -0
  27. package/dist/studio/bundler.d.ts +29 -0
  28. package/dist/studio/bundler.js +136 -0
  29. package/dist/studio/bundler.js.map +1 -0
  30. package/dist/studio/chat.d.ts +147 -0
  31. package/dist/studio/chat.js +681 -0
  32. package/dist/studio/chat.js.map +1 -0
  33. package/dist/studio/cli.d.ts +2 -0
  34. package/dist/studio/cli.js +194 -0
  35. package/dist/studio/cli.js.map +1 -0
  36. package/dist/studio/components.d.ts +4 -0
  37. package/dist/studio/components.js +36 -0
  38. package/dist/studio/components.js.map +1 -0
  39. package/dist/studio/host.d.ts +105 -0
  40. package/dist/studio/host.js +634 -0
  41. package/dist/studio/host.js.map +1 -0
  42. package/dist/studio/http.d.ts +21 -0
  43. package/dist/studio/http.js +240 -0
  44. package/dist/studio/http.js.map +1 -0
  45. package/dist/studio/music.d.ts +35 -0
  46. package/dist/studio/music.js +130 -0
  47. package/dist/studio/music.js.map +1 -0
  48. package/dist/studio/proc.d.ts +11 -0
  49. package/dist/studio/proc.js +69 -0
  50. package/dist/studio/proc.js.map +1 -0
  51. package/dist/studio/projects.d.ts +84 -0
  52. package/dist/studio/projects.js +369 -0
  53. package/dist/studio/projects.js.map +1 -0
  54. package/dist/studio/render.d.ts +24 -0
  55. package/dist/studio/render.js +197 -0
  56. package/dist/studio/render.js.map +1 -0
  57. package/dist/studio/reveal.d.ts +7 -0
  58. package/dist/studio/reveal.js +49 -0
  59. package/dist/studio/reveal.js.map +1 -0
  60. package/dist/studio/schema.d.ts +4152 -0
  61. package/dist/studio/schema.js +358 -0
  62. package/dist/studio/schema.js.map +1 -0
  63. package/dist/studio/tools.d.ts +2 -0
  64. package/dist/studio/tools.js +165 -0
  65. package/dist/studio/tools.js.map +1 -0
  66. package/dist/studio/voice.d.ts +150 -0
  67. package/dist/studio/voice.js +434 -0
  68. package/dist/studio/voice.js.map +1 -0
  69. package/dist/studio/workspace.d.ts +31 -0
  70. package/dist/studio/workspace.js +187 -0
  71. package/dist/studio/workspace.js.map +1 -0
  72. package/package.json +50 -4
  73. package/template/AGENTS.md +13 -0
  74. package/template/components/CATALOG.md +1306 -0
  75. package/template/components/README.md +61 -0
  76. package/template/components/STYLES.md +246 -0
  77. package/template/components/arcade-title/ArcadeTitle.tsx +860 -0
  78. package/template/components/arcade-title/meta.json +28 -0
  79. package/template/components/aurora/Aurora.tsx +63 -0
  80. package/template/components/aurora/meta.json +28 -0
  81. package/template/components/bar-wipe-title/BarWipeTitle.tsx +94 -0
  82. package/template/components/bar-wipe-title/meta.json +29 -0
  83. package/template/components/before-after/BeforeAfter.tsx +89 -0
  84. package/template/components/before-after/meta.json +233 -0
  85. package/template/components/bento-grid/BentoGrid.tsx +202 -0
  86. package/template/components/bento-grid/meta.json +25 -0
  87. package/template/components/blur-in-title/BlurInTitle.tsx +121 -0
  88. package/template/components/blur-in-title/meta.json +32 -0
  89. package/template/components/catalog.json +8730 -0
  90. package/template/components/catalog.ts +103 -0
  91. package/template/components/chat-thread/ChatThread.tsx +128 -0
  92. package/template/components/chat-thread/meta.json +24 -0
  93. package/template/components/checklist/Checklist.tsx +129 -0
  94. package/template/components/checklist/meta.json +25 -0
  95. package/template/components/confetti/Confetti.tsx +109 -0
  96. package/template/components/confetti/meta.json +28 -0
  97. package/template/components/countdown/Countdown.tsx +166 -0
  98. package/template/components/countdown/meta.json +28 -0
  99. package/template/components/cut-and-paste/CutAndPaste.tsx +654 -0
  100. package/template/components/cut-and-paste/meta.json +29 -0
  101. package/template/components/decode-text/DecodeText.tsx +97 -0
  102. package/template/components/decode-text/meta.json +29 -0
  103. package/template/components/editorial-quote/EditorialQuote.tsx +122 -0
  104. package/template/components/editorial-quote/meta.json +28 -0
  105. package/template/components/glitch-title/GlitchTitle.tsx +171 -0
  106. package/template/components/glitch-title/meta.json +32 -0
  107. package/template/components/halftone-wave/HalftoneWave.tsx +106 -0
  108. package/template/components/halftone-wave/meta.json +28 -0
  109. package/template/components/highlighter/Highlighter.tsx +142 -0
  110. package/template/components/highlighter/meta.json +28 -0
  111. package/template/components/hook-card/HookCard.tsx +552 -0
  112. package/template/components/hook-card/meta.json +304 -0
  113. package/template/components/index.ts +149 -0
  114. package/template/components/iris-wipe/IrisWipe.tsx +76 -0
  115. package/template/components/iris-wipe/meta.json +24 -0
  116. package/template/components/kinetic-poster/KineticPoster.tsx +437 -0
  117. package/template/components/kinetic-poster/meta.json +31 -0
  118. package/template/components/kinetic-punch/KineticPunch.tsx +80 -0
  119. package/template/components/kinetic-punch/meta.json +30 -0
  120. package/template/components/lava-lamp/LavaLamp.tsx +92 -0
  121. package/template/components/lava-lamp/meta.json +28 -0
  122. package/template/components/letter-cascade/LetterCascade.tsx +102 -0
  123. package/template/components/letter-cascade/meta.json +29 -0
  124. package/template/components/lib.ts +179 -0
  125. package/template/components/light-leak/LightLeakTransition.tsx +43 -0
  126. package/template/components/light-leak/meta.json +74 -0
  127. package/template/components/line-diagram/LineDiagram.tsx +205 -0
  128. package/template/components/line-diagram/meta.json +217 -0
  129. package/template/components/list-card/ListCard.tsx +104 -0
  130. package/template/components/list-card/meta.json +232 -0
  131. package/template/components/logo-sting/LogoSting.tsx +129 -0
  132. package/template/components/logo-sting/meta.json +29 -0
  133. package/template/components/looks.tsx +1447 -0
  134. package/template/components/lower-third/LowerThird.tsx +100 -0
  135. package/template/components/lower-third/meta.json +24 -0
  136. package/template/components/marquee/Marquee.tsx +100 -0
  137. package/template/components/marquee/meta.json +30 -0
  138. package/template/components/notification/Notification.tsx +115 -0
  139. package/template/components/notification/meta.json +27 -0
  140. package/template/components/outline-fill/OutlineFill.tsx +106 -0
  141. package/template/components/outline-fill/meta.json +28 -0
  142. package/template/components/panel-sweep/PanelSweep.tsx +86 -0
  143. package/template/components/panel-sweep/meta.json +25 -0
  144. package/template/components/prompt-box/PromptBox.tsx +131 -0
  145. package/template/components/prompt-box/meta.json +24 -0
  146. package/template/components/props.ts +73 -0
  147. package/template/components/quote-card/QuoteCard.tsx +71 -0
  148. package/template/components/quote-card/meta.json +216 -0
  149. package/template/components/shape-shift/ShapeShift.tsx +420 -0
  150. package/template/components/shape-shift/meta.json +31 -0
  151. package/template/components/slide-zoom-message/SlideZoomMessage.tsx +179 -0
  152. package/template/components/slide-zoom-message/meta.json +199 -0
  153. package/template/components/social-post/SocialPost.tsx +185 -0
  154. package/template/components/social-post/meta.json +30 -0
  155. package/template/components/split-flap/SplitFlap.tsx +191 -0
  156. package/template/components/split-flap/meta.json +29 -0
  157. package/template/components/spotlight-grid/SpotlightGrid.tsx +84 -0
  158. package/template/components/spotlight-grid/meta.json +25 -0
  159. package/template/components/stat-counter/StatCounter.tsx +117 -0
  160. package/template/components/stat-counter/meta.json +27 -0
  161. package/template/components/sticker-badge/StickerBadge.tsx +46 -0
  162. package/template/components/sticker-badge/meta.json +220 -0
  163. package/template/components/sticker-slam/StickerSlam.tsx +941 -0
  164. package/template/components/sticker-slam/meta.json +34 -0
  165. package/template/components/style-layer.tsx +233 -0
  166. package/template/components/styles.json +762 -0
  167. package/template/components/styles.ts +113 -0
  168. package/template/components/target-lock/TargetLock.tsx +662 -0
  169. package/template/components/target-lock/meta.json +32 -0
  170. package/template/components/text-reveal/TextReveal.tsx +99 -0
  171. package/template/components/text-reveal/meta.json +28 -0
  172. package/template/components/tile-wipe/TileWipe.tsx +75 -0
  173. package/template/components/tile-wipe/meta.json +24 -0
  174. package/template/components/type-zoom/TypeZoom.tsx +103 -0
  175. package/template/components/type-zoom/meta.json +27 -0
  176. package/template/components/types.ts +66 -0
  177. package/template/components/typewriter/Typewriter.tsx +112 -0
  178. package/template/components/typewriter/meta.json +29 -0
  179. package/template/components/word-pop/WordPop.tsx +59 -0
  180. package/template/components/word-pop/meta.json +237 -0
  181. package/template/components/word-stack/WordStack.tsx +122 -0
  182. package/template/components/word-stack/meta.json +27 -0
  183. package/template/components/word-swap/WordSwap.tsx +127 -0
  184. package/template/components/word-swap/meta.json +30 -0
  185. package/template/presets/charcoal-sketch/PROMPT.md +48 -0
  186. package/template/presets/charcoal-sketch/assets/paper/grain-0.png +0 -0
  187. package/template/presets/charcoal-sketch/assets/paper/grain-1.png +0 -0
  188. package/template/presets/charcoal-sketch/assets/paper/grain-2.png +0 -0
  189. package/template/presets/charcoal-sketch/assets/paper/sketch-paper.jpg +0 -0
  190. package/template/presets/charcoal-sketch/assets/paper/smudge.png +0 -0
  191. package/template/presets/charcoal-sketch/poster.jpg +0 -0
  192. package/template/presets/charcoal-sketch/preset.json +17 -0
  193. package/template/presets/charcoal-sketch/preview.mp4 +0 -0
  194. package/template/presets/charcoal-sketch/scenes/Grain.tsx +23 -0
  195. package/template/presets/charcoal-sketch/scenes/Paper.tsx +17 -0
  196. package/template/presets/charcoal-sketch/scenes/examples/Agents.tsx +100 -0
  197. package/template/presets/charcoal-sketch/scenes/examples/Approvals.tsx +110 -0
  198. package/template/presets/charcoal-sketch/scenes/examples/Blog.tsx +105 -0
  199. package/template/presets/charcoal-sketch/scenes/examples/EndCard.tsx +41 -0
  200. package/template/presets/charcoal-sketch/scenes/examples/Hook.tsx +130 -0
  201. package/template/presets/charcoal-sketch/scenes/examples/Ideas.tsx +92 -0
  202. package/template/presets/charcoal-sketch/scenes/examples/Posting.tsx +128 -0
  203. package/template/presets/charcoal-sketch/scenes/lib/painfix.tsx +119 -0
  204. package/template/presets/charcoal-sketch/scenes/lib/sketch.tsx +291 -0
  205. package/template/presets/charcoal-sketch/scripts/build_layers.example.py +193 -0
  206. package/template/presets/charcoal-sketch/scripts/duck_music.py +34 -0
  207. package/template/presets/charcoal-sketch/scripts/make_textures.py +93 -0
  208. package/template/presets/punk-cut-paper/PROMPT.md +37 -0
  209. package/template/presets/punk-cut-paper/assets/paper/desk-cream.jpg +0 -0
  210. package/template/presets/punk-cut-paper/assets/paper/grain-overlay.png +0 -0
  211. package/template/presets/punk-cut-paper/assets/paper/halftone-black.png +0 -0
  212. package/template/presets/punk-cut-paper/assets/paper/halftone-red.png +0 -0
  213. package/template/presets/punk-cut-paper/assets/paper/halftone-yellow.png +0 -0
  214. package/template/presets/punk-cut-paper/assets/paper/kraft.jpg +0 -0
  215. package/template/presets/punk-cut-paper/assets/paper/newsprint.jpg +0 -0
  216. package/template/presets/punk-cut-paper/assets/paper/paper-cream.jpg +0 -0
  217. package/template/presets/punk-cut-paper/assets/paper/paper-white.jpg +0 -0
  218. package/template/presets/punk-cut-paper/assets/paper/tape.png +0 -0
  219. package/template/presets/punk-cut-paper/build_layers.example.py +150 -0
  220. package/template/presets/punk-cut-paper/poster.jpg +0 -0
  221. package/template/presets/punk-cut-paper/preset.json +15 -0
  222. package/template/presets/punk-cut-paper/preview.mp4 +0 -0
  223. package/template/presets/punk-cut-paper/scenes/Backdrop.tsx +76 -0
  224. package/template/presets/punk-cut-paper/scenes/Motif.tsx +376 -0
  225. package/template/presets/punk-cut-paper/scenes/Photo.tsx +73 -0
  226. package/template/presets/punk-cut-paper/scenes/Ransom.tsx +119 -0
  227. package/template/presets/punk-cut-paper/scenes/Xerox.tsx +31 -0
  228. package/template/presets/punk-cut-paper/scenes/lib/punk.tsx +208 -0
  229. package/template/runtime/composition.tsx +920 -0
  230. package/template/runtime/helpers.tsx +228 -0
  231. package/template/runtime/index.tsx +22 -0
  232. package/template/runtime/types.ts +248 -0
  233. package/template/skill/SKILL.md +149 -0
  234. package/template/skill/references/browser-export.md +61 -0
  235. package/template/skill/references/components.md +38 -0
  236. package/template/skill/references/craft.md +53 -0
  237. package/template/skill/references/cursor.md +91 -0
  238. package/template/skill/references/footage.md +73 -0
  239. package/template/skill/references/format.md +140 -0
  240. package/template/skill/references/presets.md +56 -0
  241. package/template/skill/references/sound.md +128 -0
  242. package/template/starter/.studio/chat.json +1 -0
  243. package/template/starter/assets/.keep +0 -0
  244. package/template/starter/layers.json +46 -0
  245. package/template/starter/notes.md +4 -0
  246. package/template/starter/project.json +13 -0
  247. package/template/starter/renders/.keep +0 -0
  248. package/template/starter/scenes/Title.tsx +38 -0
@@ -0,0 +1,420 @@
1
+ import { useId } from "react";
2
+ import { AbsoluteFill, Easing, useCurrentFrame } from "remotion";
3
+ import { FONTS, clamp01, exitOut, fill, glowStyle, mix, pop, ramp, unit } from "../lib";
4
+ import type { MotionBaseProps } from "../types";
5
+
6
+ type Props = MotionBaseProps & {
7
+ shapes: string[];
8
+ captions: string[];
9
+ colors: string[];
10
+ background: string;
11
+ captionColor: string;
12
+ size: number;
13
+ morphFrames: number;
14
+ via: boolean;
15
+ squash: number;
16
+ rotation: boolean;
17
+ trail: boolean;
18
+ glow: boolean;
19
+ font: string;
20
+ };
21
+
22
+ type Pt = [number, number];
23
+
24
+ /** Points on every outline: all shapes share the count, start vertex (top) and winding, so morphs never knot. */
25
+ const N = 160;
26
+ const MORPH_EASE = Easing.bezier(0.7, 0, 0.3, 1);
27
+ const DEFAULT_COLORS = ["#3d5bff", "#22c55e", "#f43f5e", "#f59e0b"];
28
+
29
+ /**
30
+ * Shape morphing: each shape flows into the next through a continuous outline, by way of a circle,
31
+ * with a hop, a slight turn and squash & stretch at the morph. Held shapes carry a caption.
32
+ */
33
+ export function ShapeShift(props: Props) {
34
+ const frame = useCurrentFrame();
35
+ const { width, height, fps, durationInFrames: d } = props;
36
+ const u = unit(width, height);
37
+ const id = `sm${useId().replace(/[^a-zA-Z0-9]/g, "")}`;
38
+ const names = props.shapes.map((s) => s.trim().toLowerCase()).filter(Boolean);
39
+ if (!names.length) names.push("circle");
40
+ const colors = props.colors.map((c) => c.trim()).filter((c) => /^#[0-9a-f]{6}$/i.test(c));
41
+ const palette = colors.length ? colors : DEFAULT_COLORS;
42
+ const K = names.length;
43
+ const R = ((props.size / 100) * Math.min(width, height)) / 2;
44
+ const exitFrames = Math.min(14, d * 0.15);
45
+ const segment = (d - exitFrames) / K;
46
+ const morph = Math.min(props.morphFrames, segment * 0.8);
47
+ const hasCaptions = props.captions.some((c) => c.trim());
48
+ const capSize = Math.min(width, height) * 0.052;
49
+ const cx = width / 2;
50
+ const cy = height / 2 - (hasCaptions ? capSize * 1.1 : 0);
51
+
52
+ /** Where the shape is at frame f: outline, color and the morph's motion. */
53
+ const pose = (f: number) => {
54
+ const i = Math.max(0, Math.min(K - 1, Math.floor(f / segment)));
55
+ const local = f - i * segment;
56
+ const p = i < K - 1 && local > segment - morph ? (local - (segment - morph)) / morph : 0;
57
+ const a = i;
58
+ const b = Math.min(i + 1, K - 1);
59
+ const e = p > 0 ? MORPH_EASE(clamp01(p)) : 0;
60
+ const A = outline(names[a], f);
61
+ let pts: Pt[];
62
+ if (e === 0) pts = A;
63
+ else {
64
+ const B = outline(names[b], f);
65
+ const via = props.via && names[a] !== "circle" && names[b] !== "circle";
66
+ pts = via ? (e < 0.5 ? lerpPts(A, CIRCLE(), e * 2) : lerpPts(CIRCLE(), B, (e - 0.5) * 2)) : lerpPts(A, B, e);
67
+ }
68
+ const color = mixHex(palette[a % palette.length], palette[b % palette.length], e);
69
+ const bump = Math.sin(Math.PI * e);
70
+ const dir = a % 2 === 0 ? 1 : -1;
71
+ const s = (props.squash / 100) * bump;
72
+ const enter = pop(f, fps, 0, 200);
73
+ const out = exitOut(f, d, exitFrames);
74
+ const scale = enter * mix(0.85, 1, out);
75
+ return {
76
+ pts,
77
+ color,
78
+ a,
79
+ b,
80
+ p,
81
+ sx: (1 + s) * scale,
82
+ sy: (1 - s * 0.85) * scale,
83
+ rot: (props.rotation ? bump * 12 * dir : 0) + (1 - enter) * -40,
84
+ dx: bump * R * 0.06 * dir,
85
+ dy: -bump * R * 0.14,
86
+ out,
87
+ };
88
+ };
89
+
90
+ const now = pose(frame);
91
+ const transform = (q: ReturnType<typeof pose>) =>
92
+ `translate(${rd(cx + q.dx)} ${rd(cy + q.dy)}) rotate(${rd(q.rot)}) scale(${Math.round(q.sx * 1000) / 1000} ${Math.round(q.sy * 1000) / 1000})`;
93
+ const trails = props.trail && now.p > 0 ? [1, 2, 3].map((k) => ({ k, q: pose(frame - k * 2) })) : [];
94
+ // Details (a phone's notch, a pin's hole…) fade out as a morph starts and back in as it lands.
95
+ const detailA = now.p > 0 ? 1 - clamp01(now.p * 5) : 1;
96
+ const detailB = now.p > 0 ? clamp01((now.p - 0.8) * 5) : 0;
97
+ const capIn = ramp(frame, 6, 14);
98
+ const capA = (now.p > 0 ? 1 - clamp01(now.p * 3) : 1) * capIn;
99
+ const capB = now.p > 0 ? clamp01((now.p - 0.6) * 2.5) : 0;
100
+ const lift = Math.abs(now.dy) / (R * 0.14 || 1);
101
+
102
+ const caption = (index: number, opacity: number, shift: number) => {
103
+ const text = props.captions[index]?.trim();
104
+ if (!text || opacity <= 0) return null;
105
+ return (
106
+ <div
107
+ key={`cap${index}`}
108
+ style={{
109
+ position: "absolute",
110
+ left: 0,
111
+ right: 0,
112
+ top: cy + R * 1.12 + capSize * 0.3,
113
+ textAlign: "center",
114
+ fontFamily: FONTS[props.font] ?? FONTS.display,
115
+ fontWeight: 700,
116
+ fontSize: capSize,
117
+ letterSpacing: "-0.02em",
118
+ color: props.captionColor,
119
+ opacity: rd(opacity * now.out),
120
+ transform: `translateY(${rd(shift * capSize)}px)`,
121
+ }}
122
+ >
123
+ {text}
124
+ </div>
125
+ );
126
+ };
127
+
128
+ return (
129
+ <AbsoluteFill style={{ background: fill(props.background), opacity: now.out }}>
130
+ {props.glow ? <div style={glowStyle(cx, cy, R * 3.4, R * 3.4, now.color, 0.4 * now.out)} /> : null}
131
+ <svg width={width} height={height} style={{ position: "absolute", inset: 0 }}>
132
+ <defs>
133
+ <linearGradient id={`${id}-g`} x1="0" y1="0" x2="1" y2="1">
134
+ <stop offset="0%" stopColor={mixHex(now.color, "#ffffff", 0.25)} />
135
+ <stop offset="55%" stopColor={now.color} />
136
+ <stop offset="100%" stopColor={mixHex(now.color, "#000000", 0.2)} />
137
+ </linearGradient>
138
+ <radialGradient id={`${id}-s`}>
139
+ <stop offset="0%" stopColor={now.color} stopOpacity={0.5} />
140
+ <stop offset="100%" stopColor={now.color} stopOpacity={0} />
141
+ </radialGradient>
142
+ </defs>
143
+ {/* Floor glow: shrinks as the shape hops. */}
144
+ <ellipse
145
+ cx={rd(cx)}
146
+ cy={rd(cy + R * 1.02)}
147
+ rx={rd(R * 0.8 * (1 - lift * 0.25) * Math.max(0, now.sx))}
148
+ ry={rd(R * 0.09)}
149
+ fill={`url(#${id}-s)`}
150
+ opacity={rd(0.8 * now.out)}
151
+ />
152
+ {trails.map(({ k, q }) => (
153
+ <path
154
+ key={k}
155
+ d={pathD(q.pts, R)}
156
+ transform={transform(q)}
157
+ fill="none"
158
+ stroke={q.color}
159
+ strokeWidth={rd(Math.max(1, 3 * u))}
160
+ opacity={rd(0.4 - k * 0.11)}
161
+ />
162
+ ))}
163
+ <g transform={transform(now)}>
164
+ <path d={pathD(now.pts, R)} fill={`url(#${id}-g)`} stroke="rgba(255, 255, 255, 0.16)" strokeWidth={rd(1.5 * u)} />
165
+ {detail(names[now.a], R, detailA, `a${now.a}`)}
166
+ {now.b !== now.a ? detail(names[now.b], R, detailB, `b${now.b}`) : null}
167
+ </g>
168
+ </svg>
169
+ {caption(now.a, capA, -mix(0, 0.6, now.p > 0 ? clamp01(now.p * 3) : 0))}
170
+ {now.b !== now.a ? caption(now.b, capB, mix(0.6, 0, capB)) : null}
171
+ </AbsoluteFill>
172
+ );
173
+ }
174
+
175
+ /** Inner marks drawn on top of a held shape, in its local (centered, R-scaled) space. */
176
+ function detail(name: string, R: number, opacity: number, key: string) {
177
+ if (opacity <= 0) return null;
178
+ const o = rd(opacity);
179
+ const ink = "rgba(255, 255, 255, 0.92)";
180
+ switch (name) {
181
+ case "phone":
182
+ return (
183
+ <g key={key} opacity={o} fill="rgba(0, 0, 0, 0.3)">
184
+ <rect x={rd(-0.17 * R)} y={rd(-0.84 * R)} width={rd(0.34 * R)} height={rd(0.08 * R)} rx={rd(0.04 * R)} />
185
+ <rect x={rd(-0.2 * R)} y={rd(0.8 * R)} width={rd(0.4 * R)} height={rd(0.04 * R)} rx={rd(0.02 * R)} />
186
+ </g>
187
+ );
188
+ case "pin":
189
+ return <circle key={key} cx={0} cy={rd(-0.28 * R)} r={rd(0.25 * R)} fill={ink} opacity={o} />;
190
+ case "badge":
191
+ return (
192
+ <path
193
+ key={key}
194
+ d={`M${rd(-0.32 * R)} ${rd(0.02 * R)} L${rd(-0.08 * R)} ${rd(0.26 * R)} L${rd(0.36 * R)} ${rd(-0.22 * R)}`}
195
+ fill="none"
196
+ stroke={ink}
197
+ strokeWidth={rd(0.13 * R)}
198
+ strokeLinecap="round"
199
+ strokeLinejoin="round"
200
+ opacity={o}
201
+ />
202
+ );
203
+ case "bubble":
204
+ return (
205
+ <g key={key} opacity={o} fill={ink}>
206
+ {[-0.42, 0, 0.42].map((x) => (
207
+ <circle key={x} cx={rd(x * R)} cy={rd(-0.13 * R)} r={rd(0.1 * R)} />
208
+ ))}
209
+ </g>
210
+ );
211
+ default:
212
+ return null;
213
+ }
214
+ }
215
+
216
+ // ---- Outlines (unit space, y down, roughly within ±1) ----
217
+
218
+ const cache = new Map<string, Pt[]>();
219
+
220
+ function outline(name: string, frame: number): Pt[] {
221
+ if (name === "blob") {
222
+ const f = frame;
223
+ return normalize(
224
+ polar((t) => 0.82 + 0.08 * Math.sin(3 * t + f * 0.05) + 0.05 * Math.sin(5 * t - f * 0.07) + 0.03 * Math.sin(2 * t + f * 0.03)),
225
+ );
226
+ }
227
+ const key = SHAPES[name] ? name : "circle";
228
+ let pts = cache.get(key);
229
+ if (!pts) {
230
+ pts = normalize(SHAPES[key]());
231
+ cache.set(key, pts);
232
+ }
233
+ return pts;
234
+ }
235
+
236
+ const CIRCLE = () => outline("circle", 0);
237
+
238
+ const SHAPES: Record<string, () => Pt[]> = {
239
+ circle: () => polar(() => 0.92),
240
+ square: () => roundedPolygon([[-0.82, -0.82], [0.82, -0.82], [0.82, 0.82], [-0.82, 0.82]], 0.3),
241
+ triangle: () => roundedPolygon([[0, -0.95], [0.98, 0.75], [-0.98, 0.75]], 0.16),
242
+ star: () =>
243
+ roundedPolygon(
244
+ Array.from({ length: 10 }, (_, k) => {
245
+ const a = -Math.PI / 2 + (k * Math.PI) / 5;
246
+ const r = k % 2 === 0 ? 1.02 : 0.47;
247
+ return [r * Math.cos(a), r * Math.sin(a) + 0.08] as Pt;
248
+ }),
249
+ 0.07,
250
+ ),
251
+ heart: () =>
252
+ Array.from({ length: 400 }, (_, k) => {
253
+ const t = (k / 400) * Math.PI * 2;
254
+ const x = 16 * Math.sin(t) ** 3;
255
+ const y = -(13 * Math.cos(t) - 5 * Math.cos(2 * t) - 2 * Math.cos(3 * t) - Math.cos(4 * t));
256
+ return [x / 16.5, y / 16.5 - 0.12] as Pt;
257
+ }),
258
+ pin: () => {
259
+ const c: Pt = [0, -0.28];
260
+ const r = 0.66;
261
+ const tip: Pt = [0, 0.98];
262
+ const beta = Math.acos(r / (tip[1] - c[1]));
263
+ const pts: Pt[] = [];
264
+ for (let k = 0; k <= 200; k++) {
265
+ const a = Math.PI / 2 + beta + (k / 200) * (2 * Math.PI - 2 * beta);
266
+ pts.push([c[0] + r * Math.cos(a), c[1] + r * Math.sin(a)]);
267
+ }
268
+ pts.push(tip);
269
+ return pts;
270
+ },
271
+ phone: () => roundedPolygon([[-0.52, -0.95], [0.52, -0.95], [0.52, 0.95], [-0.52, 0.95]], 0.2),
272
+ bubble: () =>
273
+ roundedPolygon(
274
+ [[-0.95, -0.72], [0.95, -0.72], [0.95, 0.48], [-0.15, 0.48], [-0.58, 0.92], [-0.5, 0.48], [-0.95, 0.48]],
275
+ [0.32, 0.32, 0.32, 0.05, 0.04, 0.05, 0.32],
276
+ ),
277
+ bolt: () => roundedPolygon([[0.2, -1], [-0.62, 0.12], [-0.04, 0.12], [-0.22, 1], [0.62, -0.16], [0.04, -0.16]], 0.05),
278
+ badge: () => polar((t) => 0.86 + 0.07 * Math.cos(12 * t)),
279
+ play: () => roundedPolygon([[-0.62, -0.88], [0.86, 0], [-0.62, 0.88]], 0.22),
280
+ cloud: () => {
281
+ const circles: [number, number, number][] = [
282
+ [-0.52, 0.2, 0.42],
283
+ [-0.05, -0.18, 0.58],
284
+ [0.5, 0.08, 0.46],
285
+ [0.1, 0.28, 0.44],
286
+ ];
287
+ const o: Pt = [0, 0.1];
288
+ const base = 0.62;
289
+ const pts: Pt[] = [];
290
+ for (let k = 0; k < 360; k++) {
291
+ const t = -Math.PI / 2 + (k / 360) * Math.PI * 2;
292
+ const dx = Math.cos(t);
293
+ const dy = Math.sin(t);
294
+ let best = 0;
295
+ for (const [x, y, r] of circles) {
296
+ const wx = x - o[0];
297
+ const wy = y - o[1];
298
+ const b = dx * wx + dy * wy;
299
+ const disc = r * r - (wx * wx + wy * wy - b * b);
300
+ if (disc >= 0) best = Math.max(best, b + Math.sqrt(disc));
301
+ }
302
+ if (best <= 0) continue;
303
+ if (o[1] + best * dy > base) best = (base - o[1]) / dy;
304
+ pts.push([o[0] + best * dx, o[1] + best * dy - 0.1]);
305
+ }
306
+ return pts;
307
+ },
308
+ };
309
+
310
+ /** r(θ) sampled clockwise from the top. */
311
+ function polar(r: (t: number) => number, samples = 360): Pt[] {
312
+ return Array.from({ length: samples }, (_, k) => {
313
+ const t = -Math.PI / 2 + (k / samples) * Math.PI * 2;
314
+ const v = r(t);
315
+ return [v * Math.cos(t), v * Math.sin(t)] as Pt;
316
+ });
317
+ }
318
+
319
+ /** A polygon with each corner rounded by a quadratic curve `radius` along its edges. */
320
+ function roundedPolygon(verts: Pt[], radius: number | number[]): Pt[] {
321
+ const out: Pt[] = [];
322
+ const n = verts.length;
323
+ for (let i = 0; i < n; i++) {
324
+ const v = verts[i];
325
+ const p = verts[(i - 1 + n) % n];
326
+ const q = verts[(i + 1) % n];
327
+ const r = Array.isArray(radius) ? radius[i] : radius;
328
+ const lp = Math.hypot(p[0] - v[0], p[1] - v[1]);
329
+ const lq = Math.hypot(q[0] - v[0], q[1] - v[1]);
330
+ const dist = Math.min(r, lp / 2, lq / 2);
331
+ const a: Pt = [v[0] + ((p[0] - v[0]) / lp) * dist, v[1] + ((p[1] - v[1]) / lp) * dist];
332
+ const b: Pt = [v[0] + ((q[0] - v[0]) / lq) * dist, v[1] + ((q[1] - v[1]) / lq) * dist];
333
+ for (let s = 0; s <= 10; s++) {
334
+ const t = s / 10;
335
+ const w = 1 - t;
336
+ out.push([w * w * a[0] + 2 * w * t * v[0] + t * t * b[0], w * w * a[1] + 2 * w * t * v[1] + t * t * b[1]]);
337
+ }
338
+ }
339
+ return out;
340
+ }
341
+
342
+ /** Clockwise, starting at the point straight above the center, resampled to N points evenly by arc length. */
343
+ function normalize(raw: Pt[]): Pt[] {
344
+ let pts = raw;
345
+ let area = 0;
346
+ for (let i = 0; i < pts.length; i++) {
347
+ const [x1, y1] = pts[i];
348
+ const [x2, y2] = pts[(i + 1) % pts.length];
349
+ area += x1 * y2 - x2 * y1;
350
+ }
351
+ if (area < 0) pts = [...pts].reverse();
352
+ const xs = pts.map((p) => p[0]);
353
+ const ys = pts.map((p) => p[1]);
354
+ const mx = (Math.min(...xs) + Math.max(...xs)) / 2;
355
+ const my = (Math.min(...ys) + Math.max(...ys)) / 2;
356
+ let start = 0;
357
+ let bestDist = Infinity;
358
+ pts.forEach(([x, y], i) => {
359
+ const a = Math.atan2(y - my, x - mx);
360
+ const dist = Math.abs(Math.atan2(Math.sin(a + Math.PI / 2), Math.cos(a + Math.PI / 2)));
361
+ if (dist < bestDist) {
362
+ bestDist = dist;
363
+ start = i;
364
+ }
365
+ });
366
+ pts = [...pts.slice(start), ...pts.slice(0, start)];
367
+ const lengths = [0];
368
+ for (let i = 1; i <= pts.length; i++) {
369
+ const [x1, y1] = pts[i - 1];
370
+ const [x2, y2] = pts[i % pts.length];
371
+ lengths.push(lengths[i - 1] + Math.hypot(x2 - x1, y2 - y1));
372
+ }
373
+ const total = lengths[pts.length];
374
+ const out: Pt[] = [];
375
+ let j = 0;
376
+ for (let k = 0; k < N; k++) {
377
+ const target = (k / N) * total;
378
+ while (j < pts.length - 1 && lengths[j + 1] < target) j++;
379
+ const seg = lengths[j + 1] - lengths[j] || 1;
380
+ const t = (target - lengths[j]) / seg;
381
+ const [x1, y1] = pts[j];
382
+ const [x2, y2] = pts[(j + 1) % pts.length];
383
+ out.push([x1 + (x2 - x1) * t, y1 + (y2 - y1) * t]);
384
+ }
385
+ return out;
386
+ }
387
+
388
+ function lerpPts(a: Pt[], b: Pt[], t: number): Pt[] {
389
+ return a.map(([x, y], i) => [x + (b[i][0] - x) * t, y + (b[i][1] - y) * t]);
390
+ }
391
+
392
+ /** A smooth closed path through the points (Catmull-Rom as cubics), in pixels, rounded so SSR and client agree. */
393
+ function pathD(pts: Pt[], R: number) {
394
+ const P = pts.map(([x, y]) => [x * R, y * R]);
395
+ const n = P.length;
396
+ let path = `M${rd(P[0][0])} ${rd(P[0][1])}`;
397
+ for (let i = 0; i < n; i++) {
398
+ const p0 = P[(i - 1 + n) % n];
399
+ const p1 = P[i];
400
+ const p2 = P[(i + 1) % n];
401
+ const p3 = P[(i + 2) % n];
402
+ path += `C${rd(p1[0] + (p2[0] - p0[0]) / 6)} ${rd(p1[1] + (p2[1] - p0[1]) / 6)} ${rd(p2[0] - (p3[0] - p1[0]) / 6)} ${rd(
403
+ p2[1] - (p3[1] - p1[1]) / 6,
404
+ )} ${rd(p2[0])} ${rd(p2[1])}`;
405
+ }
406
+ return `${path}Z`;
407
+ }
408
+
409
+ function mixHex(a: string, b: string, t: number) {
410
+ const pa = /^#?([0-9a-f]{6})$/i.exec(a.trim());
411
+ const pb = /^#?([0-9a-f]{6})$/i.exec(b.trim());
412
+ if (!pa || !pb) return a;
413
+ const na = parseInt(pa[1], 16);
414
+ const nb = parseInt(pb[1], 16);
415
+ const ch = (n: number, s: number) => (n >> s) & 255;
416
+ const c = (s: number) => Math.round(ch(na, s) + (ch(nb, s) - ch(na, s)) * t);
417
+ return `#${((c(16) << 16) | (c(8) << 8) | c(0)).toString(16).padStart(6, "0")}`;
418
+ }
419
+
420
+ const rd = (v: number) => Math.round(v * 100) / 100;
@@ -0,0 +1,31 @@
1
+ {
2
+ "id": "shape-shift",
3
+ "name": "Shape Shift",
4
+ "category": "AI & Product",
5
+ "description": "One shape flows into the next through a continuous outline (by way of a circle), hopping, turning and squashing as it morphs, each held shape with its own caption.",
6
+ "useWhen": "Explainer and keynote-style storytelling where one idea turns into the next: a phone becomes a map pin becomes a heart (open the app, find a place, save it), a cloud becomes a bolt, steps of a flow, before/after. 2–5 shapes; put the payoff last, it holds to the end.",
7
+ "durationInFrames": 150,
8
+ "layer": "full",
9
+ "tags": ["morph", "shape", "explainer", "icon", "transform", "keynote", "steps", "story", "liquid", "geometric"],
10
+ "props": {
11
+ "shapes": { "type": "lines", "label": "Shapes", "default": ["phone", "pin", "heart", "star"], "max": 8, "help": "One per line: circle, square, triangle, star, heart, pin, phone, bubble, bolt, badge, play, cloud, blob." },
12
+ "captions": { "type": "lines", "label": "Captions", "default": ["Open the app", "Find a spot", "Save favourites", "Leave a review"], "max": 8, "help": "One per shape, shown under it. Leave empty for none." },
13
+ "colors": { "type": "lines", "label": "Colors", "default": ["#3d5bff", "#22c55e", "#f43f5e", "#f59e0b"], "max": 8, "help": "One hex color per shape (repeats if shorter); colors blend through the morph." },
14
+ "background": { "type": "color", "label": "Background", "default": "#0b0d14", "help": "\"transparent\" to sit over other layers." },
15
+ "captionColor": { "type": "color", "label": "Caption", "default": "#ffffff" },
16
+ "size": { "type": "number", "label": "Size", "default": 40, "min": 15, "max": 70, "step": 1, "unit": "% of frame" },
17
+ "morphFrames": { "type": "number", "label": "Morph length", "default": 22, "min": 8, "max": 48, "step": 1, "unit": "frames" },
18
+ "via": { "type": "boolean", "label": "Pass through a circle", "default": true, "help": "Complex shapes morph A → circle → B, which reads cleaner than a direct blend." },
19
+ "squash": { "type": "number", "label": "Squash & stretch", "default": 12, "min": 0, "max": 30, "step": 1, "unit": "%" },
20
+ "rotation": { "type": "boolean", "label": "Turn while morphing", "default": true },
21
+ "trail": { "type": "boolean", "label": "Echo outlines", "default": false },
22
+ "glow": { "type": "boolean", "label": "Glow", "default": true },
23
+ "font": { "type": "select", "label": "Caption font", "default": "display", "options": [{ "value": "display", "label": "Bricolage" }, { "value": "sans", "label": "Inter" }, { "value": "serif", "label": "Instrument Serif" }, { "value": "fraunces", "label": "Fraunces" }, { "value": "grotesk", "label": "Space Grotesk" }, { "value": "syne", "label": "Syne" }, { "value": "wide", "label": "Unbounded" }, { "value": "condensed", "label": "Anton" }, { "value": "mono", "label": "Mono" }] }
24
+ },
25
+ "examples": [
26
+ { "name": "App story", "props": {} },
27
+ { "name": "Weather", "props": { "shapes": ["cloud", "bolt", "circle"], "captions": ["Cloudy", "Storms", "Clear skies"], "colors": ["#94a3b8", "#facc15", "#fb923c"], "background": "#0f172a", "font": "grotesk" } },
28
+ { "name": "Light, flat", "props": { "shapes": ["bubble", "play", "badge"], "captions": ["Ask", "Watch", "Done"], "colors": ["#111827", "#ef4444", "#10b981"], "background": "#f5f5f4", "captionColor": "#111827", "glow": false, "trail": true, "font": "sans" } }
29
+ ],
30
+ "stillAt": 0.8
31
+ }
@@ -0,0 +1,179 @@
1
+ import { AbsoluteFill, Easing, interpolate, useCurrentFrame } from "remotion";
2
+ import { FONTS, exitOut, splitHighlights, unit } from "../lib";
3
+ import type { MotionBaseProps } from "../types";
4
+
5
+ type Props = MotionBaseProps & {
6
+ lines: string[];
7
+ enterFrom: string;
8
+ pan: string;
9
+ zoom: number;
10
+ color: string;
11
+ accent: string;
12
+ background: string;
13
+ size: number;
14
+ weight: string;
15
+ font: string;
16
+ motionBlur: boolean;
17
+ };
18
+
19
+ const out = Easing.bezier(0.16, 1, 0.3, 1);
20
+ const inOut = Easing.bezier(0.65, 0, 0.35, 1);
21
+
22
+ /**
23
+ * The classic intro move: the message slides in from the side with motion blur, the camera
24
+ * pushes in on its first words, travels along the line, then pulls back to show it all.
25
+ * Phases scale with the clip length: slide 0–16%, hold, zoom in 24–44%, pan 44–68%, zoom out 68–88%.
26
+ */
27
+ export function SlideZoomMessage(props: Props) {
28
+ const frame = useCurrentFrame();
29
+ const { width, height, durationInFrames: d } = props;
30
+ const u = unit(width, height);
31
+ const vertical = height > width;
32
+ const fontSize =
33
+ (props.size / 100) * Math.min(width, height) * (vertical ? 1.15 : 1);
34
+ const at = (fraction: number) => Math.round(d * fraction);
35
+ const clamp = {
36
+ extrapolateLeft: "clamp",
37
+ extrapolateRight: "clamp",
38
+ } as const;
39
+
40
+ // 1. Slide in (with a velocity-based motion trail).
41
+ const sign = props.enterFrom === "right" ? 1 : -1;
42
+ const travel = width * 0.75;
43
+ const slideAt = (f: number) =>
44
+ interpolate(f, [0, at(0.16)], [sign * travel, 0], {
45
+ ...clamp,
46
+ easing: out,
47
+ });
48
+ const x = slideAt(frame);
49
+ const velocity = x - slideAt(frame - 1);
50
+
51
+ // 2–4. Camera: focus point and scale (the content moves the opposite way).
52
+ const span = width * (vertical ? 0.16 : 0.24);
53
+ const start = props.pan === "right" ? span : -span;
54
+ const end = -start;
55
+ const zoomT = interpolate(frame, [at(0.24), at(0.44)], [0, 1], {
56
+ ...clamp,
57
+ easing: inOut,
58
+ });
59
+ const panT = interpolate(frame, [at(0.44), at(0.68)], [0, 1], {
60
+ ...clamp,
61
+ easing: inOut,
62
+ });
63
+ const backT = interpolate(frame, [at(0.68), at(0.88)], [0, 1], {
64
+ ...clamp,
65
+ easing: inOut,
66
+ });
67
+ const scale = 1 + (props.zoom - 1) * zoomT * (1 - backT);
68
+ const focus = (start * zoomT + (end - start) * panT) * (1 - backT);
69
+ const camAt = (f: number) => {
70
+ const z = interpolate(f, [at(0.24), at(0.44)], [0, 1], {
71
+ ...clamp,
72
+ easing: inOut,
73
+ });
74
+ const p = interpolate(f, [at(0.44), at(0.68)], [0, 1], {
75
+ ...clamp,
76
+ easing: inOut,
77
+ });
78
+ const b = interpolate(f, [at(0.68), at(0.88)], [0, 1], {
79
+ ...clamp,
80
+ easing: inOut,
81
+ });
82
+ return {
83
+ s: 1 + (props.zoom - 1) * z * (1 - b),
84
+ x: (start * z + (end - start) * p) * (1 - b),
85
+ };
86
+ };
87
+ const previous = camAt(frame - 1);
88
+ const camSpeed =
89
+ Math.abs(focus * scale - previous.x * previous.s) +
90
+ Math.abs(scale - previous.s) * width * 0.25;
91
+
92
+ const fade = exitOut(frame, d, 10);
93
+ const blurPx = props.motionBlur
94
+ ? Math.min(14 * u, Math.abs(velocity) * 0.05 + camSpeed * 0.03)
95
+ : 0;
96
+ const trail = props.motionBlur
97
+ ? Math.min(Math.abs(velocity) / (8 * u), 6)
98
+ : 0;
99
+
100
+ const text = (
101
+ <div
102
+ style={{
103
+ display: "flex",
104
+ flexDirection: "column",
105
+ alignItems: "center",
106
+ gap: fontSize * 0.04,
107
+ fontFamily: FONTS[props.font] ?? FONTS.sans,
108
+ fontWeight: Number(props.weight) || 800,
109
+ fontSize,
110
+ lineHeight: 1.02,
111
+ letterSpacing: "-0.04em",
112
+ whiteSpace: "nowrap",
113
+ }}
114
+ >
115
+ {props.lines.map((line, i) => (
116
+ <div key={i} style={{ display: "flex", gap: fontSize * 0.26 }}>
117
+ {splitHighlights(line).map((word, j) => (
118
+ <span
119
+ key={j}
120
+ style={{ color: word.highlighted ? props.accent : props.color }}
121
+ >
122
+ {word.text}
123
+ </span>
124
+ ))}
125
+ </div>
126
+ ))}
127
+ </div>
128
+ );
129
+
130
+ return (
131
+ <AbsoluteFill
132
+ style={{
133
+ background:
134
+ props.background === "transparent" ? undefined : props.background,
135
+ overflow: "hidden",
136
+ opacity: fade,
137
+ }}
138
+ >
139
+ {/* Blur on an untransformed layer: the browser export clips a filtered element to its own box. */}
140
+ <AbsoluteFill
141
+ style={{
142
+ filter: blurPx > 0.4 ? `blur(${blurPx.toFixed(2)}px)` : undefined,
143
+ }}
144
+ >
145
+ <AbsoluteFill
146
+ style={{
147
+ alignItems: "center",
148
+ justifyContent: "center",
149
+ transform: `scale(${scale}) translateX(${-focus}px)`,
150
+ }}
151
+ >
152
+ {/* Ghost copies behind the text, spaced by its speed: a motion trail the browser export can draw. */}
153
+ {Array.from({ length: Math.ceil(trail) }, (_, i) => (
154
+ <AbsoluteFill
155
+ key={i}
156
+ style={{
157
+ alignItems: "center",
158
+ justifyContent: "center",
159
+ transform: `translateX(${x - velocity * (i + 1) * 0.6}px)`,
160
+ opacity: 0.22 * (1 - i / Math.max(1, trail)),
161
+ }}
162
+ >
163
+ {text}
164
+ </AbsoluteFill>
165
+ ))}
166
+ <AbsoluteFill
167
+ style={{
168
+ alignItems: "center",
169
+ justifyContent: "center",
170
+ transform: `translateX(${x}px)`,
171
+ }}
172
+ >
173
+ {text}
174
+ </AbsoluteFill>
175
+ </AbsoluteFill>
176
+ </AbsoluteFill>
177
+ </AbsoluteFill>
178
+ );
179
+ }