π₯ Make videos programmatically with React
Add Skills
ASchwada2d20907b91f
diff --git a/packages/template-prompt-to-motion-graphics/src/app/api/generate/route.ts b/packages/template-prompt-to-motion-graphics/src/app/api/generate/route.tsindex 0016794f02..d905d62cf3 100644--- a/packages/template-prompt-to-motion-graphics/src/app/api/generate/route.ts+++ b/packages/template-prompt-to-motion-graphics/src/app/api/generate/route.ts@@ -1,6 +1,12 @@import { streamText, generateObject } from "ai";import { createOpenAI } from "@ai-sdk/openai";import { z } from "zod";+import {+ getCombinedSkillContent,+ SKILL_DETECTION_PROMPT,+ SKILL_NAMES,+ type SkillName,+} from "@/skills";const VALIDATION_PROMPT = `You are a prompt classifier for a motion graphics generation tool.@@ -34,578 +40,73 @@ Return true if the prompt is valid for motion graphics generation, false otherwiconst SYSTEM_PROMPT = `You are an expert in generating React components for Remotion animations.-LAYOUT RULES:-- ALWAYS USE THE FULL WIDTH of the container-- Ensure diagrams span edge-to-edge with appropriate padding (e.g., padding: 40px)-- Never constrain diagrams to a small centered box - maximize the visual space--COLOR RULES:-- Keep colors minimal (2-4 colors max) and define them as constants INSIDE the component body-- Example: const COLOR_TEXT = "#000000"; const COLOR_HIGHLIGHT = "#A7C7E7";--TEXT CONTENT RULES (CRITICAL):-- ALL text strings that appear in the animation MUST be defined as constants INSIDE the component body-- Never hardcode text directly in JSX - always use variables-- This allows users to easily edit all text content-- Use descriptive constant names in UPPER_SNAKE_CASE-- Example:- const TITLE_TEXT = "Espresso Workflow";- const SUBTITLE_TEXT = "5-Step Process Flow";- const STEP_1_TEXT = "Grind Coffee";--ANIMATION TIMING RULES:-- Define animation speed/timing parameters as constants INSIDE the component body-- Use descriptive names for delays, durations, and speed multipliers-- This allows users to fine-tune animation pacing without editing code-- Example:- const ANIMATION_SPEED = 1.0; // Speed multiplier (1.0 = normal, 2.0 = 2x faster)- const FADE_DURATION = 20; // Duration in frames- const ELEMENT_DELAY = 5; // Delay between elements in frames--CONSTANTS PLACEMENT (CRITICAL):-- NEVER define constants outside the component function-- ALL constants (colors, text, timing, layout) MUST be defined INSIDE the component body-- Place constants AFTER the hooks (useCurrentFrame, useVideoConfig) but BEFORE any calculations-- Correct order inside component:- 1) Multi-line comment description- 2) Hooks (useCurrentFrame, useVideoConfig, useState, etc.)- 3) Constants (COLORS, TEXT, TIMING, LAYOUT)- 4) Calculations and derived values- 5) return JSX-- NEVER put constants before hooks - this is a common mistake--ADDITIONAL CONSTANTS TO DEFINE:-- Typography: FONT_SIZE, FONT_WEIGHT, LETTER_SPACING-- Layout: ROW_GAP, PADDING, BORDER_RADIUS, MAX_WIDTH_PERCENT-- Spring physics: BOUNCE_DAMPING, BOUNCE_MASS, BOUNCE_STIFFNESS-- Derived timing: Calculate from other constants (e.g., MSG2_START = MSG1_START + DURATION + DELAY)-- Responsive: Use Math.max(minValue, Math.round(width * percentage)) for responsive sizing--ANIMATION QUALITY RULES (CRITICAL):-- PREFER spring() over interpolate() for organic, natural motion-- Use spring() for: entrances, bounces, highlights, scaling, any "snappy" movement-- Use interpolate() only for: linear progress bars, opacity fades, or when exact timing control is needed-- Example: const entrance = spring({fps, frame: frame - START_DELAY, config: {damping: 200, stiffness: 120}, durationInFrames: 20});--LAYERING & CROSSFADE TECHNIQUES:-- For text that changes appearance (e.g., gets highlighted), use TWO overlapping layers that crossfade-- Never abruptly switch styles - always transition smoothly--PACING & DRAMATIC TIMING:-- Add intentional PAUSES between animation phases for dramatic effect-- Use delays like WAIT_AFTER_X_SECONDS for natural pacing-- Example: const PAUSE_FRAMES = Math.round(fps * 1.0); // 1 second pause--CONTAINER ANIMATIONS:-- Add subtle entrance animations to the entire container (e.g., scale from 0.98 to 1.0 with spring)--TYPEWRITER EFFECTS (CRITICAL):-- For typewriter/typing animations, use string slicing: typedText = FULL_TEXT.slice(0, typedChars)-- NEVER render all characters with varying opacity - this breaks cursor positioning-- The cursor must appear immediately after the last typed character-- Simple pattern: <span>{typedText}</span><span style={{opacity: caretOpacity}}>{CARET}</span>-----EXAMPLE 1: Typewriter with highlight (advanced)--Prompt: "Text with typewriter effect, pause mid-sentence, then highlight a word"--import { useCurrentFrame, useVideoConfig, AbsoluteFill, interpolate, spring } from "remotion";--export const MyAnimation = () => {- /*- * Typewriter with blinking cursor, dramatic pause, spring-based highlight, and layer crossfade.- */- const frame = useCurrentFrame();- const {fps} = useVideoConfig();-- const COLOR_TEXT = "#000000";- const COLOR_HIGHLIGHT = "#A7C7E7";-- const FULL_TEXT = "From prompt to motion graphics. This is Veloce.";- const HIGHLIGHT_WORD = "Veloce";- const CARET_SYMBOL = "β";- const SPLIT_AFTER = " This is Veloce."; // Phrase to delay before typing-- const FONT_SIZE = 72;- const FONT_WEIGHT = 700;- const CHAR_FRAMES = 2;- const CURSOR_BLINK_FRAMES = 16;- const HIGHLIGHT_DELAY = 6;- const HIGHLIGHT_WIPE_DURATION = 18;- const CROSSFADE_DURATION = 8;- const WAIT_AFTER_PRE_SECONDS = 1; // Dramatic pause mid-sentence-- const WAIT_AFTER_PRE_FRAMES = Math.round(fps * WAIT_AFTER_PRE_SECONDS);- const f = frame;-- // Split point for pause- const splitIndex = FULL_TEXT.indexOf(SPLIT_AFTER);- const preLen = splitIndex >= 0 ? splitIndex : FULL_TEXT.length;- const postLen = FULL_TEXT.length - preLen;-- // Typewriter with pause- let typedChars = 0;- if (f < preLen * CHAR_FRAMES) {- typedChars = Math.floor(f / CHAR_FRAMES);- } else if (f < preLen * CHAR_FRAMES + WAIT_AFTER_PRE_FRAMES) {- typedChars = preLen;- } else {- const postPhase = f - preLen * CHAR_FRAMES - WAIT_AFTER_PRE_FRAMES;- typedChars = Math.min(FULL_TEXT.length, preLen + Math.floor(postPhase / CHAR_FRAMES));- }- const typedText = FULL_TEXT.slice(0, typedChars);- const typingDone = typedChars >= FULL_TEXT.length;-- // Caret blink (smooth)- const caretOpacity = !typingDone- ? interpolate(f % CURSOR_BLINK_FRAMES, [0, CURSOR_BLINK_FRAMES / 2, CURSOR_BLINK_FRAMES], [1, 0, 1], {extrapolateLeft: "clamp", extrapolateRight: "clamp"})- : 0;-- // Highlight segmentation- const highlightIndex = FULL_TEXT.indexOf(HIGHLIGHT_WORD);- const hasHighlight = highlightIndex >= 0;- const preText = hasHighlight ? FULL_TEXT.slice(0, highlightIndex) : FULL_TEXT;- const postText = hasHighlight ? FULL_TEXT.slice(highlightIndex + HIGHLIGHT_WORD.length) : "";-- // Timing- const typeEnd = preLen * CHAR_FRAMES + WAIT_AFTER_PRE_FRAMES + postLen * CHAR_FRAMES;- const highlightStart = typeEnd + HIGHLIGHT_DELAY;-- const typedOpacity = interpolate(f, [highlightStart - CROSSFADE_DURATION, highlightStart + CROSSFADE_DURATION], [1, 0], {extrapolateLeft: "clamp", extrapolateRight: "clamp"});- const finalOpacity = interpolate(f, [highlightStart, highlightStart + CROSSFADE_DURATION], [0, 1], {extrapolateLeft: "clamp", extrapolateRight: "clamp"});-- // Container entrance with spring- const entrance = spring({fps, frame: f, config: {damping: 200, stiffness: 120}, durationInFrames: 20});- const containerScale = interpolate(entrance, [0, 1], [0.98, 1], {extrapolateLeft: "clamp", extrapolateRight: "clamp"});-- // Highlight with spring (smoother than interpolate)- const highlightProgress = spring({fps, frame: f - highlightStart, config: {damping: 200, stiffness: 180}, durationInFrames: HIGHLIGHT_WIPE_DURATION});- const highlightScaleX = Math.max(0, Math.min(1, highlightProgress));-- return (- <AbsoluteFill style={{display: "flex", alignItems: "center", justifyContent: "center"}}>- <div style={{position: "relative"}}>- {/* Typing layer */}- <div style={{color: COLOR_TEXT, fontSize: FONT_SIZE, fontWeight: FONT_WEIGHT, lineHeight: 1.15, whiteSpace: "pre-wrap", opacity: typedOpacity}}>- <span>{typedText}</span>- <span style={{opacity: caretOpacity}}>{CARET_SYMBOL}</span>- </div>- {/* Final layer with highlight */}- <div style={{position: "absolute", inset: 0, color: COLOR_TEXT, fontSize: FONT_SIZE, fontWeight: FONT_WEIGHT, lineHeight: 1.15, whiteSpace: "pre-wrap", opacity: finalOpacity}}>- {hasHighlight ? (- <>- <span>{preText}</span>- <span style={{position: "relative", display: "inline-block"}}>- <span style={{- position: "absolute", left: 0, right: 0, top: "50%", height: "1.05em",- transform: \`translateY(-50%) scaleX(\${highlightScaleX})\`,- transformOrigin: "left center", backgroundColor: COLOR_HIGHLIGHT, borderRadius: "0.18em", zIndex: 0- }} />- <span style={{position: "relative", zIndex: 1}}>{HIGHLIGHT_WORD}</span>- </span>- <span>{postText}</span>- </>- ) : (- <span>{FULL_TEXT}</span>- )}- </div>- </div>- </AbsoluteFill>- );-};-----EXAMPLE 2: Chat bubbles--Prompt: "WhatsApp-style chat with messages appearing one by one"--import { useCurrentFrame, useVideoConfig, AbsoluteFill, interpolate, spring } from "remotion";--export const MyAnimation = () => {- /*- * Chat conversation with bubbles sliding in with spring animation.- */- const frame = useCurrentFrame();- const {fps, width, height} = useVideoConfig();-- const COLOR_BACKGROUND = "#0b141a";- const COLOR_SENT = "#1f8a70";- const COLOR_RECEIVED = "#202c33";- const COLOR_TEXT = "#e9edef";-- const MSG_1 = "Hey, how are you?";- const MSG_2 = "Great, thanks!";- const MSG_3 = "Want to grab coffee?";-- const FONT_SIZE = 44;- const FADE_DURATION = 18;- const STAGGER_DELAY = 38;- const SLIDE_DISTANCE = 40;- const BOUNCE_DAMPING = 12;- const BOUNCE_STIFFNESS = 170;- const BUBBLE_RADIUS = 18;- const BUBBLE_PADDING_X = 24;- const BUBBLE_PADDING_Y = 18;- const ROW_GAP = 22;- const MAX_WIDTH_PERCENT = 72;-- // Derived timing- const MSG1_START = 0;- const MSG2_START = MSG1_START + FADE_DURATION + STAGGER_DELAY;- const MSG3_START = MSG2_START + FADE_DURATION + STAGGER_DELAY;-- // Helper component for repeated bubbles- const MessageRow = ({text, align, start}: {text: string, align: string, start: number}) => {- const local = frame - start;- const opacity = interpolate(local, [0, FADE_DURATION], [0, 1], {extrapolateLeft: "clamp", extrapolateRight: "clamp"});- const bounce = spring({frame: Math.max(0, local), fps, config: {damping: BOUNCE_DAMPING, stiffness: BOUNCE_STIFFNESS}});- const scale = interpolate(bounce, [0, 1], [0.98, 1], {extrapolateLeft: "clamp", extrapolateRight: "clamp"});- const xFrom = align === "right" ? SLIDE_DISTANCE : -SLIDE_DISTANCE;- const tx = interpolate(opacity, [0, 1], [xFrom, 0], {extrapolateLeft: "clamp", extrapolateRight: "clamp"});- const bubbleBg = align === "right" ? COLOR_SENT : COLOR_RECEIVED;-- return (- <div style={{width: "100%", display: "flex", justifyContent: align === "right" ? "flex-end" : "flex-start", marginTop: ROW_GAP}}>- <div style={{- maxWidth: \`\${MAX_WIDTH_PERCENT}%\`,- backgroundColor: bubbleBg,- color: COLOR_TEXT,- padding: \`\${BUBBLE_PADDING_Y}px \${BUBBLE_PADDING_X}px\`,- borderRadius: BUBBLE_RADIUS,- fontSize: FONT_SIZE,- opacity,- transform: \`translateX(\${tx}px) scale(\${scale})\`,- transformOrigin: align === "right" ? "100% 100%" : "0% 100%"- }}>- {text}- </div>- </div>- );- };-- return (- <AbsoluteFill style={{- backgroundColor: COLOR_BACKGROUND,- display: "flex",- flexDirection: "column",- justifyContent: "flex-end",- padding: Math.max(36, Math.round(width * 0.04))- }}>- <div style={{flex: 1}} />- <MessageRow text={MSG_1} align="left" start={MSG1_START} />- <MessageRow text={MSG_2} align="right" start={MSG2_START} />- <MessageRow text={MSG_3} align="left" start={MSG3_START} />- <div style={{height: Math.max(20, Math.round(height * 0.02))}} />- </AbsoluteFill>- );-};-------EXAMPLE 3: Rotating word carousel--Prompt: "Text that dissolves between different words"--import { useCurrentFrame, AbsoluteFill, interpolate } from "remotion";--export const MyAnimation = () => {- /*- * Prefix text with rotating words that crossfade with blur.- */- const frame = useCurrentFrame();-- const COLOR_TEXT = "#7b92c1";- const PREFIX = "Created for";- const WORDS = ["Creators", "Marketers", "Developers", "Everyone"];-- const PREFIX_FONT_SIZE = 80;- const WORD_FONT_SIZE = 80;- const PREFIX_WEIGHT = 300;- const WORD_WEIGHT = 700;- const WORD_GAP = 20;- const HOLD_DURATION = 32;- const FLIP_DURATION = 18;- const BLUR_AMOUNT = 6;-- const perStep = HOLD_DURATION + FLIP_DURATION;- const totalSteps = WORDS.length;- const currentStep = Math.floor(frame / perStep) % totalSteps;- const nextStep = (currentStep + 1) % totalSteps;- const phase = frame % perStep;- const isFlipping = phase >= HOLD_DURATION;- const flipProgress = isFlipping ? (phase - HOLD_DURATION) / FLIP_DURATION : 0;-- const outOpacity = interpolate(flipProgress, [0, 1], [1, 0], {extrapolateLeft: "clamp", extrapolateRight: "clamp"});- const inOpacity = interpolate(flipProgress, [0, 1], [0, 1], {extrapolateLeft: "clamp", extrapolateRight: "clamp"});- const outBlur = interpolate(flipProgress, [0, 1], [0, BLUR_AMOUNT], {extrapolateLeft: "clamp", extrapolateRight: "clamp"});- const inBlur = interpolate(flipProgress, [0, 1], [BLUR_AMOUNT, 0], {extrapolateLeft: "clamp", extrapolateRight: "clamp"});-- // Find longest word for stable width- const longestWord = WORDS.reduce((a, b) => a.length >= b.length ? a : b, WORDS[0]);-- return (- <AbsoluteFill style={{display: "flex", alignItems: "center", justifyContent: "center"}}>- <div style={{display: "flex", alignItems: "baseline", gap: WORD_GAP, color: COLOR_TEXT}}>- <div style={{fontSize: PREFIX_FONT_SIZE, fontWeight: PREFIX_WEIGHT}}>{PREFIX}</div>- <div style={{position: "relative", fontSize: WORD_FONT_SIZE, fontWeight: WORD_WEIGHT}}>- {/* Invisible width keeper */}- <div style={{visibility: "hidden"}}>{longestWord}</div>- {/* Current word (fades out during flip) */}- {!isFlipping && (- <div style={{position: "absolute", left: 0, top: 0}}>{WORDS[currentStep]}</div>- )}- {/* Crossfade during flip */}- {isFlipping && (- <>- <div style={{position: "absolute", left: 0, top: 0, opacity: outOpacity, filter: \`blur(\${outBlur}px)\`}}>- {WORDS[currentStep]}- </div>- <div style={{position: "absolute", left: 0, top: 0, opacity: inOpacity, filter: \`blur(\${inBlur}px)\`}}>- {WORDS[nextStep]}- </div>- </>- )}- </div>- </div>- </AbsoluteFill>- );-};-------EXAMPLE 4: Animated bar chart / histogram--Prompt: "An animated histogram with the gold price. Focus on simplicity and elegance. Small headline, all bars are well laid out"--import { useCurrentFrame, useVideoConfig, AbsoluteFill, spring } from "remotion";--export const MyAnimation = () => {- /*- * Elegant animated bar chart showing gold prices with Y-axis, staggered spring animations, and full-width layout.- */- const frame = useCurrentFrame();- const { fps, height: videoHeight } = useVideoConfig();-- const TITLE = "Gold Price 2024";- const UNIT = "USD per troy ounce";- const COLOR_BAR = "#D4AF37";- const COLOR_TEXT = "#ffffff";- const COLOR_MUTED = "#888888";- const COLOR_BG = "#0a0a0a";- const COLOR_AXIS = "#333333";-- const PADDING = 50;- const HEADER_HEIGHT = 70;- const LABEL_HEIGHT = 32;- const BAR_GAP = 8;- const BAR_RADIUS = 4;- const TITLE_FONT_SIZE = 24;- const LABEL_FONT_SIZE = 11;- const VALUE_FONT_SIZE = 11;- const AXIS_FONT_SIZE = 12;- const STAGGER_DELAY = 5;- const HEADER_START_FRAME = 0;- const BARS_START_FRAME = 10;- const SPRING_DAMPING = 18;- const SPRING_STIFFNESS = 80;-- const data = [- { month: "Jan", price: 2039 },- { month: "Feb", price: 2024 },- { month: "Mar", price: 2160 },- { month: "Apr", price: 2330 },- { month: "May", price: 2327 },- { month: "Jun", price: 2339 },- { month: "Jul", price: 2426 },- { month: "Aug", price: 2503 },- { month: "Sep", price: 2634 },- { month: "Oct", price: 2735 },- { month: "Nov", price: 2672 },- { month: "Dec", price: 2650 },- ];-- const minPrice = 1900;- const maxPrice = 2800;- const priceRange = maxPrice - minPrice;- const chartHeight = videoHeight - (PADDING * 2) - HEADER_HEIGHT - LABEL_HEIGHT;- const yAxisSteps = [1900, 2100, 2300, 2500, 2700];-- const headerOpacity = spring({- frame: frame - HEADER_START_FRAME,- fps,- config: { damping: 20, stiffness: 100 },- });-- return (- <AbsoluteFill- style={{- backgroundColor: COLOR_BG,- padding: PADDING,- display: "flex",- flexDirection: "column",- fontFamily: "Inter, sans-serif",- }}- >- {/* Header */}- <div style={{ height: HEADER_HEIGHT, opacity: headerOpacity, marginBottom: 10 }}>- <div style={{ color: COLOR_TEXT, fontSize: TITLE_FONT_SIZE, fontWeight: 600 }}>{TITLE}</div>- <div style={{ color: COLOR_MUTED, fontSize: 14, marginTop: 4 }}>{UNIT}</div>- </div>-- {/* Chart container */}- <div style={{ display: "flex", alignItems: "flex-end", width: "100%", flex: 1 }}>- {/* Y-Axis */}- <div- style={{- display: "flex",- flexDirection: "column",- justifyContent: "space-between",- height: chartHeight,- paddingRight: 12,- marginBottom: LABEL_HEIGHT,- }}- >- {yAxisSteps.slice().reverse().map((step) => (- <div- key={step}- style={{- color: COLOR_MUTED,- fontSize: AXIS_FONT_SIZE,- textAlign: "right",- minWidth: 40,- }}- >- {step.toLocaleString()}- </div>- ))}- </div>-- {/* Chart area */}- <div- style={{- display: "flex",- alignItems: "flex-end",- gap: BAR_GAP,- height: chartHeight,- flex: 1,- borderLeft: \`1px solid \${COLOR_AXIS}\`,- borderBottom: \`1px solid \${COLOR_AXIS}\`,- paddingLeft: 8,- }}- >- {data.map((item, i) => {- const delay = i * STAGGER_DELAY;- const progress = spring({- frame: frame - delay - BARS_START_FRAME,- fps,- config: { damping: SPRING_DAMPING, stiffness: SPRING_STIFFNESS },- });-- const normalizedHeight = ((item.price - minPrice) / priceRange) * chartHeight;- const height = normalizedHeight * progress;-- return (- <div- key={i}- style={{- textAlign: "center",- flex: 1,- height: "100%",- display: "flex",- flexDirection: "column",- justifyContent: "flex-end",- }}- >- <div- style={{- width: "100%",- height,- backgroundColor: COLOR_BAR,- borderRadius: \`\${BAR_RADIUS}px \${BAR_RADIUS}px 0 0\`,- display: "flex",- justifyContent: "center",- alignItems: "flex-start",- paddingTop: 6,- minHeight: height > 0 ? 4 : 0,- }}- >- {height > 30 && (- <span- style={{- color: COLOR_BG,- fontSize: VALUE_FONT_SIZE,- fontWeight: 600,- opacity: progress,- }}- >- {item.price.toLocaleString()}- </span>- )}- </div>- <div- style={{- color: COLOR_MUTED,- fontSize: LABEL_FONT_SIZE,- marginTop: 8,- height: LABEL_HEIGHT - 8,- }}- >- {item.month}- </div>- </div>- );- })}- </div>- </div>- </AbsoluteFill>- );-};-------END OF EXAMPLES--IMPORTANT RULES:-- Start with proper ES6 imports, then export the component as: export const MyAnimation = () => {...}-- Start the component body with a multi-line comment (/* */) containing a 2-3 sentence description of what you're building-- ALWAYS include the necessary imports at the top of the file--AVAILABLE IMPORTS (use exactly these import statements):-- import { useCurrentFrame, useVideoConfig, AbsoluteFill, interpolate, spring, Sequence } from "remotion";-- import { Circle, Rect, Triangle, Star, Ellipse, Pie } from "@remotion/shapes";-- import { Lottie } from "@remotion/lottie";-- import { ThreeCanvas } from "@remotion/three";--REACT HOOKS:-- Import React hooks using named imports: import { useState, useEffect } from "react";-- Example: const [data, setData] = useState(null);--EXPORT FORMAT:-- Always export as: export const MyAnimation = () => { ... };-- Do not use default exports--RESERVED NAMES (CRITICAL):-- NEVER use "spring" as a variable name - it shadows the spring() function from Remotion-- If you need a variable for spring season data, use "springData", "springSeason", or "springPhase" instead-- Similarly avoid naming variables: interpolate, useCurrentFrame, useVideoConfig, AbsoluteFill, Sequence--- Use creative animations with smooth transitions-- Component should use frame-based animations with interpolate()-- Make it visually impressive and modern-- Use inline styles for all styling-- ALWAYS use fontFamily: 'Inter, sans-serif' for ALL text elements to ensure consistent rendering-- Do not generate typescript types or interfaces-- ALWAYS make sure to show all contents on the screen WITHOUT going off-screen or being cut off+## COMPONENT STRUCTURE++1. Start with ES6 imports+2. Export as: export const MyAnimation = () => { ... };+3. Component body order:+ - Multi-line comment description (2-3 sentences)+ - Hooks (useCurrentFrame, useVideoConfig, etc.)+ - Constants (COLORS, TEXT, TIMING, LAYOUT) - all UPPER_SNAKE_CASE+ - Calculations and derived values+ - return JSX++## CONSTANTS RULES (CRITICAL)++ALL constants MUST be defined INSIDE the component body, AFTER hooks:+- Colors: const COLOR_TEXT = "#000000";+- Text: const TITLE_TEXT = "Hello World";+- Timing: const FADE_DURATION = 20;+- Layout: const PADDING = 40;++This allows users to easily customize the animation.++## LAYOUT RULES++- Use full width of container with appropriate padding+- Never constrain content to a small centered box+- Use Math.max(minValue, Math.round(width * percentage)) for responsive sizing++## ANIMATION RULES++- Prefer spring() for organic motion (entrances, bounces, scaling)+- Use interpolate() for linear progress (progress bars, opacity fades)+- Always use { extrapolateLeft: "clamp", extrapolateRight: "clamp" }+- Add stagger delays for multiple elements++## AVAILABLE IMPORTS++\`\`\`tsx+import { useCurrentFrame, useVideoConfig, AbsoluteFill, interpolate, spring, Sequence } from "remotion";+import { TransitionSeries, linearTiming, springTiming } from "@remotion/transitions";+import { fade } from "@remotion/transitions/fade";+import { slide } from "@remotion/transitions/slide";+import { Circle, Rect, Triangle, Star, Ellipse, Pie } from "@remotion/shapes";+import { ThreeCanvas } from "@remotion/three";+import { useState, useEffect } from "react";+\`\`\`++## RESERVED NAMES (CRITICAL)++NEVER use these as variable names - they shadow imports:+- spring, interpolate, useCurrentFrame, useVideoConfig, AbsoluteFill, Sequence++## STYLING RULES++- Use inline styles only+- ALWAYS use fontFamily: 'Inter, sans-serif'+- Keep colors minimal (2-4 max)- ALWAYS set backgroundColor on AbsoluteFill from frame 0 - never fade in backgrounds-- NEVER NEVER NEVER use fade-in for the AbsoluteFill container - always have it fully visible from frame 0-OUTPUT FORMAT (CRITICAL):-- Output ONLY the code. No explanations, no questions, no commentary.-- Do NOT ask follow-up questions like "Do you want X or Y?"-- Do NOT add text before or after the code block-- The response must start with "import" and end with "};", nothing else-- If the prompt is ambiguous, make a reasonable choice and implement it - do not ask for clarification+## OUTPUT FORMAT (CRITICAL)++- Output ONLY code - no explanations, no questions+- Response must start with "import" and end with "};"+- If prompt is ambiguous, make a reasonable choice - do not ask for clarification`;+export async function POST(req: Request) {const { prompt, model = "gpt-5-mini" } = await req.json();@@ -653,10 +154,33 @@ export async function POST(req: Request) {console.error("Validation error:", validationError);}+ // Detect which skills apply to this prompt+ let detectedSkills: SkillName[] = [];+ try {+ const skillResult = await generateObject({+ model: openai("gpt-5.2"),+ system: SKILL_DETECTION_PROMPT,+ prompt: `User prompt: "${prompt}"`,+ schema: z.object({+ skills: z.array(z.enum(SKILL_NAMES)),+ }),+ });+ detectedSkills = skillResult.object.skills;+ console.log("Detected skills:", detectedSkills);+ } catch (skillError) {+ console.error("Skill detection error:", skillError);+ }++ // Load skill-specific content and enhance the system prompt+ const skillContent = getCombinedSkillContent(detectedSkills);+ const enhancedSystemPrompt = skillContent+ ? `${SYSTEM_PROMPT}\n\n## SKILL-SPECIFIC GUIDANCE\n${skillContent}`+ : SYSTEM_PROMPT;+try {const result = streamText({model: openai(modelName),- system: SYSTEM_PROMPT,+ system: enhancedSystemPrompt,prompt,...(reasoningEffort && {providerOptions: {@@ -672,6 +196,8 @@ export async function POST(req: Request) {prompt,"model:",modelName,+ "skills:",+ detectedSkills.length > 0 ? detectedSkills.join(", ") : "general",reasoningEffort ? `reasoning_effort: ${reasoningEffort}` : "",);diff --git a/packages/template-prompt-to-motion-graphics/src/skills/3d.md b/packages/template-prompt-to-motion-graphics/src/skills/3d.mdnew file mode 100644index 0000000000..cdfda8aae1--- /dev/null+++ b/packages/template-prompt-to-motion-graphics/src/skills/3d.md@@ -0,0 +1,115 @@+---+title: 3D Animation with ThreeCanvas+impact: MEDIUM+impactDescription: enables proper 3D scene setup and smooth animations+tags: 3d, three, threejs, webgl, spatial+---++## ThreeCanvas Setup++Always wrap 3D content in ThreeCanvas and include proper lighting.++**Incorrect (missing ThreeCanvas wrapper):**++```tsx+<mesh rotation={[0, frame * 0.02, 0]}>+ <boxGeometry args={[2, 2, 2]} />+ <meshStandardMaterial color="#4a9eff" />+</mesh>+```++**Correct (proper ThreeCanvas setup):**++```tsx+import { ThreeCanvas } from "@remotion/three";++<ThreeCanvas>+ <ambientLight intensity={0.5} />+ <pointLight position={[10, 10, 10]} />+ <mesh rotation={[0, frame * 0.02, 0]}>+ <boxGeometry args={[2, 2, 2]} />+ <meshStandardMaterial color="#4a9eff" />+ </mesh>+</ThreeCanvas>+```++## Lighting Setup++Every 3D scene needs ambient + directional light for depth.++**Incorrect (no lighting - objects appear flat/black):**++```tsx+<ThreeCanvas>+ <mesh>+ <sphereGeometry args={[1, 32, 32]} />+ <meshStandardMaterial color="red" />+ </mesh>+</ThreeCanvas>+```++**Correct (proper lighting):**++```tsx+<ThreeCanvas>+ <ambientLight intensity={0.4} />+ <directionalLight position={[5, 5, 5]} intensity={0.8} />+ <mesh>+ <sphereGeometry args={[1, 32, 32]} />+ <meshStandardMaterial color="red" />+ </mesh>+</ThreeCanvas>+```++## Frame-Based Rotation++Use frame directly for smooth continuous rotation.++```tsx+const frame = useCurrentFrame();+const rotationY = frame * 0.02; // Adjust speed with multiplier++<mesh rotation={[0, rotationY, 0]}>+ <boxGeometry args={[2, 2, 2]} />+ <meshStandardMaterial color="#4a9eff" />+</mesh>+```++## Floating/Hovering Animation++Use sine wave on Y position for organic floating effect.++```tsx+const frame = useCurrentFrame();+const floatY = Math.sin(frame * 0.1) * 0.3; // Amplitude 0.3, speed 0.1++<mesh position={[0, floatY, 0]}>+ {/* geometry and material */}+</mesh>+```++## Spring-Based Scale Entrance++Use spring() for bouncy 3D object entrances.++```tsx+const scaleProgress = spring({+ frame,+ fps,+ config: { damping: 12, stiffness: 100 }+});++<mesh scale={[scaleProgress, scaleProgress, scaleProgress]}>+ {/* geometry and material */}+</mesh>+```++## Camera Positioning++Position camera at reasonable distance for scene visibility.++```tsx+<ThreeCanvas camera={{ position: [0, 0, 5], fov: 75 }}>+ {/* scene content */}+</ThreeCanvas>+```diff --git a/packages/template-prompt-to-motion-graphics/src/skills/charts.md b/packages/template-prompt-to-motion-graphics/src/skills/charts.mdnew file mode 100644index 0000000000..b8dd039ed6--- /dev/null+++ b/packages/template-prompt-to-motion-graphics/src/skills/charts.md@@ -0,0 +1,294 @@+---+title: Chart & Data Visualization+impact: HIGH+impactDescription: improves data viz quality and animation polish+tags: charts, data, visualization, bar-chart, pie-chart, graphs+---++## Bar Chart Animations++Stagger bar entrances with 3-5 frame delays and use spring() for organic motion.++**Incorrect (all bars animate together):**++```tsx+const bars = data.map((item, i) => {+ const height = spring({ frame, fps, config: { damping: 18 } });+ return <div style={{ height: height * item.value }} />;+});+```++**Correct (staggered entrances):**++```tsx+const STAGGER_DELAY = 5;++const bars = data.map((item, i) => {+ const delay = i * STAGGER_DELAY;+ const height = spring({+ frame: frame - delay,+ fps,+ config: { damping: 18, stiffness: 80 }+ });+ return <div style={{ height: height * item.value }} />;+});+```++## Always Include Y-Axis Labels++Charts without axis labels are hard to read. Always add labeled tick marks.++**Incorrect (no axis):**++```tsx+<div style={{ display: "flex", alignItems: "flex-end", gap: 8 }}>+ {bars}+</div>+```++**Correct (with Y-axis):**++```tsx+const yAxisSteps = [0, 25, 50, 75, 100];++<div style={{ display: "flex" }}>+ <div style={{ display: "flex", flexDirection: "column", justifyContent: "space-between" }}>+ {yAxisSteps.reverse().map(step => (+ <span style={{ fontSize: 12, color: "#888" }}>{step}</span>+ ))}+ </div>+ <div style={{ display: "flex", alignItems: "flex-end", gap: 8, borderLeft: "1px solid #333" }}>+ {bars}+ </div>+</div>+```++## Value Labels Inside Bars++Position value labels inside bars when height is sufficient, fade in after bar animates.++```tsx+const barHeight = normalizedHeight * progress;++<div style={{ height: barHeight, backgroundColor: COLOR_BAR }}>+ {barHeight > 30 && (+ <span style={{ opacity: progress, fontSize: 11 }}>+ {item.value.toLocaleString()}+ </span>+ )}+</div>+```++## Pie Chart Animation++Animate segments using stroke-dashoffset, starting from 12 o'clock.++```tsx+const circumference = 2 * Math.PI * radius;+const segmentLength = (value / total) * circumference;+const offset = interpolate(progress, [0, 1], [segmentLength, 0]);++<circle+ r={radius}+ cx={center}+ cy={center}+ fill="none"+ stroke={color}+ strokeWidth={strokeWidth}+ strokeDasharray={`${segmentLength} ${circumference}`}+ strokeDashoffset={offset}+ transform={`rotate(-90 ${center} ${center})`}+/>+```++---++## COMPLETE EXAMPLE: Animated Bar Chart++Prompt: "An animated histogram with the gold price. Focus on simplicity and elegance."++```tsx+import { useCurrentFrame, useVideoConfig, AbsoluteFill, spring } from "remotion";++export const MyAnimation = () => {+ /*+ * Elegant animated bar chart showing gold prices with Y-axis, staggered spring animations, and full-width layout.+ */+ const frame = useCurrentFrame();+ const { fps, height: videoHeight } = useVideoConfig();++ const TITLE = "Gold Price 2024";+ const UNIT = "USD per troy ounce";+ const COLOR_BAR = "#D4AF37";+ const COLOR_TEXT = "#ffffff";+ const COLOR_MUTED = "#888888";+ const COLOR_BG = "#0a0a0a";+ const COLOR_AXIS = "#333333";++ const PADDING = 50;+ const HEADER_HEIGHT = 70;+ const LABEL_HEIGHT = 32;+ const BAR_GAP = 8;+ const BAR_RADIUS = 4;+ const TITLE_FONT_SIZE = 24;+ const LABEL_FONT_SIZE = 11;+ const VALUE_FONT_SIZE = 11;+ const AXIS_FONT_SIZE = 12;+ const STAGGER_DELAY = 5;+ const HEADER_START_FRAME = 0;+ const BARS_START_FRAME = 10;+ const SPRING_DAMPING = 18;+ const SPRING_STIFFNESS = 80;++ const data = [+ { month: "Jan", price: 2039 },+ { month: "Feb", price: 2024 },+ { month: "Mar", price: 2160 },+ { month: "Apr", price: 2330 },+ { month: "May", price: 2327 },+ { month: "Jun", price: 2339 },+ { month: "Jul", price: 2426 },+ { month: "Aug", price: 2503 },+ { month: "Sep", price: 2634 },+ { month: "Oct", price: 2735 },+ { month: "Nov", price: 2672 },+ { month: "Dec", price: 2650 },+ ];++ const minPrice = 1900;+ const maxPrice = 2800;+ const priceRange = maxPrice - minPrice;+ const chartHeight = videoHeight - (PADDING * 2) - HEADER_HEIGHT - LABEL_HEIGHT;+ const yAxisSteps = [1900, 2100, 2300, 2500, 2700];++ const headerOpacity = spring({+ frame: frame - HEADER_START_FRAME,+ fps,+ config: { damping: 20, stiffness: 100 },+ });++ return (+ <AbsoluteFill+ style={{+ backgroundColor: COLOR_BG,+ padding: PADDING,+ display: "flex",+ flexDirection: "column",+ fontFamily: "Inter, sans-serif",+ }}+ >+ {/* Header */}+ <div style={{ height: HEADER_HEIGHT, opacity: headerOpacity, marginBottom: 10 }}>+ <div style={{ color: COLOR_TEXT, fontSize: TITLE_FONT_SIZE, fontWeight: 600 }}>{TITLE}</div>+ <div style={{ color: COLOR_MUTED, fontSize: 14, marginTop: 4 }}>{UNIT}</div>+ </div>++ {/* Chart container */}+ <div style={{ display: "flex", alignItems: "flex-end", width: "100%", flex: 1 }}>+ {/* Y-Axis */}+ <div+ style={{+ display: "flex",+ flexDirection: "column",+ justifyContent: "space-between",+ height: chartHeight,+ paddingRight: 12,+ marginBottom: LABEL_HEIGHT,+ }}+ >+ {yAxisSteps.slice().reverse().map((step) => (+ <div+ key={step}+ style={{+ color: COLOR_MUTED,+ fontSize: AXIS_FONT_SIZE,+ textAlign: "right",+ minWidth: 40,+ }}+ >+ {step.toLocaleString()}+ </div>+ ))}+ </div>++ {/* Chart area */}+ <div+ style={{+ display: "flex",+ alignItems: "flex-end",+ gap: BAR_GAP,+ height: chartHeight,+ flex: 1,+ borderLeft: `1px solid ${COLOR_AXIS}`,+ borderBottom: `1px solid ${COLOR_AXIS}`,+ paddingLeft: 8,+ }}+ >+ {data.map((item, i) => {+ const delay = i * STAGGER_DELAY;+ const progress = spring({+ frame: frame - delay - BARS_START_FRAME,+ fps,+ config: { damping: SPRING_DAMPING, stiffness: SPRING_STIFFNESS },+ });++ const normalizedHeight = ((item.price - minPrice) / priceRange) * chartHeight;+ const height = normalizedHeight * progress;++ return (+ <div+ key={i}+ style={{+ textAlign: "center",+ flex: 1,+ height: "100%",+ display: "flex",+ flexDirection: "column",+ justifyContent: "flex-end",+ }}+ >+ <div+ style={{+ width: "100%",+ height,+ backgroundColor: COLOR_BAR,+ borderRadius: `${BAR_RADIUS}px ${BAR_RADIUS}px 0 0`,+ display: "flex",+ justifyContent: "center",+ alignItems: "flex-start",+ paddingTop: 6,+ minHeight: height > 0 ? 4 : 0,+ }}+ >+ {height > 30 && (+ <span+ style={{+ color: COLOR_BG,+ fontSize: VALUE_FONT_SIZE,+ fontWeight: 600,+ opacity: progress,+ }}+ >+ {item.price.toLocaleString()}+ </span>+ )}+ </div>+ <div+ style={{+ color: COLOR_MUTED,+ fontSize: LABEL_FONT_SIZE,+ marginTop: 8,+ height: LABEL_HEIGHT - 8,+ }}+ >+ {item.month}+ </div>+ </div>+ );+ })}+ </div>+ </div>+ </AbsoluteFill>+ );+};+```diff --git a/packages/template-prompt-to-motion-graphics/src/skills/index.ts b/packages/template-prompt-to-motion-graphics/src/skills/index.tsnew file mode 100644index 0000000000..3a5921ba5d--- /dev/null+++ b/packages/template-prompt-to-motion-graphics/src/skills/index.ts@@ -0,0 +1,53 @@+import fs from "fs";+import path from "path";++export const SKILL_NAMES = [+ "charts",+ "typography",+ "social-media",+ "messaging",+ "3d",+ "transitions",+ "sequencing",+ "spring-physics",+] as const;++export type SkillName = (typeof SKILL_NAMES)[number];++const skillsDir = path.join(process.cwd(), "src/skills");++export function getSkillContent(skillName: SkillName): string {+ const filePath = path.join(skillsDir, `${skillName}.md`);+ try {+ return fs.readFileSync(filePath, "utf-8");+ } catch {+ return "";+ }+}++export function getCombinedSkillContent(skills: SkillName[]): string {+ if (skills.length === 0) {+ return "";+ }++ const contents = skills+ .map((skill) => getSkillContent(skill))+ .filter((content) => content.length > 0);++ return contents.join("\n\n---\n\n");+}++export const SKILL_DETECTION_PROMPT = `Classify this motion graphics prompt into ALL applicable categories.+A prompt can match multiple categories. Only include categories that are clearly relevant.++Categories:+- charts: data visualizations, graphs, histograms, bar charts, pie charts, progress bars, statistics, metrics+- typography: kinetic text, typewriter effects, text animations, word carousels, animated titles, text-heavy content+- social-media: Instagram stories, TikTok content, YouTube shorts, social media posts, reels, vertical video+- messaging: chat interfaces, WhatsApp conversations, iMessage, chat bubbles, text messages, DMs, messenger+- 3d: 3D objects, ThreeJS, spatial animations, rotating cubes, 3D scenes+- transitions: scene changes, fades between clips, slide transitions, wipes, multiple scenes+- sequencing: multiple elements appearing at different times, staggered animations, choreographed entrances+- spring-physics: bouncy animations, organic motion, elastic effects, overshoot animations++Return an array of matching category names. Return an empty array if none apply.`;diff --git a/packages/template-prompt-to-motion-graphics/src/skills/messaging.md b/packages/template-prompt-to-motion-graphics/src/skills/messaging.mdnew file mode 100644index 0000000000..ef6f027624--- /dev/null+++ b/packages/template-prompt-to-motion-graphics/src/skills/messaging.md@@ -0,0 +1,202 @@+---+title: Chat & Messaging UI+impact: HIGH+impactDescription: creates realistic chat interfaces with proper bubble styling and animations+tags: chat, messaging, whatsapp, imessage, bubbles, conversation+---++## Chat Bubble Layout++Use flexbox to align sent messages right, received messages left.++**Incorrect (all bubbles centered):**++```tsx+<div style={{ textAlign: "center" }}>+ {messages.map(msg => <div>{msg.text}</div>)}+</div>+```++**Correct (proper chat alignment):**++```tsx+<div style={{+ display: "flex",+ flexDirection: "column",+ justifyContent: "flex-end",+ padding: 40+}}>+ {messages.map((msg, i) => (+ <div style={{+ display: "flex",+ justifyContent: msg.sent ? "flex-end" : "flex-start",+ marginTop: 12+ }}>+ <div style={{+ maxWidth: "70%",+ padding: "12px 16px",+ borderRadius: 16,+ backgroundColor: msg.sent ? "#1f8a70" : "#202c33",+ color: "#e9edef"+ }}>+ {msg.text}+ </div>+ </div>+ ))}+</div>+```++## Staggered Message Entrances++Messages should appear one by one with slide + fade animations.++**Incorrect (all messages appear at once):**++```tsx+{messages.map(msg => <Bubble text={msg.text} />)}+```++**Correct (staggered with delays):**++```tsx+const STAGGER_DELAY = 38;+const FADE_DURATION = 18;++{messages.map((msg, i) => {+ const startFrame = i * STAGGER_DELAY;+ const opacity = interpolate(frame - startFrame, [0, FADE_DURATION], [0, 1], { extrapolateLeft: "clamp", extrapolateRight: "clamp" });+ const slideX = interpolate(opacity, [0, 1], [msg.sent ? 40 : -40, 0]);++ return (+ <div style={{ opacity, transform: `translateX(${slideX}px)` }}>+ {msg.text}+ </div>+ );+})}+```++## Spring Bounce on Bubble Entrance++Add spring physics for organic bubble pop-in effect.++```tsx+const bounce = spring({+ frame: frame - startFrame,+ fps,+ config: { damping: 12, stiffness: 170 }+});+const scaleValue = interpolate(bounce, [0, 1], [0.98, 1]);++<div style={{+ transform: `translateX(${slideX}px) scale(${scaleValue})`,+ transformOrigin: msg.sent ? "100% 100%" : "0% 100%"+}}>+```++## Dark Theme Colors (WhatsApp style)++```tsx+const COLOR_BACKGROUND = "#0b141a";+const COLOR_SENT = "#1f8a70"; // Green for sent+const COLOR_RECEIVED = "#202c33"; // Dark gray for received+const COLOR_TEXT = "#e9edef"; // Light text+```++## Light Theme Colors (iMessage style)++```tsx+const COLOR_BACKGROUND = "#ffffff";+const COLOR_SENT = "#007AFF"; // Blue for sent+const COLOR_RECEIVED = "#E9E9EB"; // Light gray for received+const COLOR_TEXT_SENT = "#ffffff";+const COLOR_TEXT_RECEIVED = "#000000";+```++---++## COMPLETE EXAMPLE: WhatsApp-Style Chat++Prompt: "WhatsApp-style chat with messages appearing one by one"++```tsx+import { useCurrentFrame, useVideoConfig, AbsoluteFill, interpolate, spring } from "remotion";++export const MyAnimation = () => {+ /*+ * Chat conversation with bubbles sliding in with spring animation.+ */+ const frame = useCurrentFrame();+ const {fps, width, height} = useVideoConfig();++ const COLOR_BACKGROUND = "#0b141a";+ const COLOR_SENT = "#1f8a70";+ const COLOR_RECEIVED = "#202c33";+ const COLOR_TEXT = "#e9edef";++ const MSG_1 = "Hey, how are you?";+ const MSG_2 = "Great, thanks!";+ const MSG_3 = "Want to grab coffee?";++ const FONT_SIZE = 44;+ const FADE_DURATION = 18;+ const STAGGER_DELAY = 38;+ const SLIDE_DISTANCE = 40;+ const BOUNCE_DAMPING = 12;+ const BOUNCE_STIFFNESS = 170;+ const BUBBLE_RADIUS = 18;+ const BUBBLE_PADDING_X = 24;+ const BUBBLE_PADDING_Y = 18;+ const ROW_GAP = 22;+ const MAX_WIDTH_PERCENT = 72;++ const MSG1_START = 0;+ const MSG2_START = MSG1_START + FADE_DURATION + STAGGER_DELAY;+ const MSG3_START = MSG2_START + FADE_DURATION + STAGGER_DELAY;++ const MessageRow = ({text, align, start}: {text: string, align: string, start: number}) => {+ const local = frame - start;+ const opacity = interpolate(local, [0, FADE_DURATION], [0, 1], {extrapolateLeft: "clamp", extrapolateRight: "clamp"});+ const bounce = spring({frame: Math.max(0, local), fps, config: {damping: BOUNCE_DAMPING, stiffness: BOUNCE_STIFFNESS}});+ const scaleValue = interpolate(bounce, [0, 1], [0.98, 1], {extrapolateLeft: "clamp", extrapolateRight: "clamp"});+ const xFrom = align === "right" ? SLIDE_DISTANCE : -SLIDE_DISTANCE;+ const tx = interpolate(opacity, [0, 1], [xFrom, 0], {extrapolateLeft: "clamp", extrapolateRight: "clamp"});+ const bubbleBg = align === "right" ? COLOR_SENT : COLOR_RECEIVED;++ return (+ <div style={{width: "100%", display: "flex", justifyContent: align === "right" ? "flex-end" : "flex-start", marginTop: ROW_GAP}}>+ <div style={{+ maxWidth: `${MAX_WIDTH_PERCENT}%`,+ backgroundColor: bubbleBg,+ color: COLOR_TEXT,+ padding: `${BUBBLE_PADDING_Y}px ${BUBBLE_PADDING_X}px`,+ borderRadius: BUBBLE_RADIUS,+ fontSize: FONT_SIZE,+ fontFamily: "Inter, sans-serif",+ opacity,+ transform: `translateX(${tx}px) scale(${scaleValue})`,+ transformOrigin: align === "right" ? "100% 100%" : "0% 100%"+ }}>+ {text}+ </div>+ </div>+ );+ };++ return (+ <AbsoluteFill style={{+ backgroundColor: COLOR_BACKGROUND,+ display: "flex",+ flexDirection: "column",+ justifyContent: "flex-end",+ padding: Math.max(36, Math.round(width * 0.04)),+ fontFamily: "Inter, sans-serif"+ }}>+ <div style={{flex: 1}} />+ <MessageRow text={MSG_1} align="left" start={MSG1_START} />+ <MessageRow text={MSG_2} align="right" start={MSG2_START} />+ <MessageRow text={MSG_3} align="left" start={MSG3_START} />+ <div style={{height: Math.max(20, Math.round(height * 0.02))}} />+ </AbsoluteFill>+ );+};+```diff --git a/packages/template-prompt-to-motion-graphics/src/skills/sequencing.md b/packages/template-prompt-to-motion-graphics/src/skills/sequencing.mdnew file mode 100644index 0000000000..61ed94ddd9--- /dev/null+++ b/packages/template-prompt-to-motion-graphics/src/skills/sequencing.md@@ -0,0 +1,243 @@+---+title: Timing & Sequencing+impact: HIGH+impactDescription: controls when elements appear and enables complex choreography+tags: sequence, series, timing, delay, choreography+---++## Sequence for Delayed Elements++Use Sequence to delay when an element appears in the timeline.++**Incorrect (manual frame checks):**++```tsx+{frame >= 30 && <Title />}+{frame >= 60 && <Subtitle />}+```++**Correct (Sequence component):**++```tsx+import { Sequence } from "remotion";++<Sequence from={30} durationInFrames={90}>+ <Title />+</Sequence>+<Sequence from={60} durationInFrames={60}>+ <Subtitle />+</Sequence>+```++## Series for Sequential Playback++Use Series when elements should play one after another without overlap.++```tsx+import { Series } from "remotion";++<Series>+ <Series.Sequence durationInFrames={45}>+ <Intro />+ </Series.Sequence>+ <Series.Sequence durationInFrames={60}>+ <MainContent />+ </Series.Sequence>+ <Series.Sequence durationInFrames={30}>+ <Outro />+ </Series.Sequence>+</Series>+```++## Series with Offset for Overlap++Use negative offset for overlapping sequences:++```tsx+<Series>+ <Series.Sequence durationInFrames={60}>+ <SceneA />+ </Series.Sequence>+ <Series.Sequence offset={-15} durationInFrames={60}>+ {/* Starts 15 frames before SceneA ends */}+ <SceneB />+ </Series.Sequence>+</Series>+```++## Staggered Element Entrances++For staggered animations of multiple items, calculate delays:++**Incorrect (hardcoded delays):**++```tsx+const items = data.map((item, i) => {+ const delay = i === 0 ? 0 : i === 1 ? 10 : i === 2 ? 20 : 30;+ // ...+});+```++**Correct (calculated stagger):**++```tsx+const STAGGER_DELAY = 8;+const BASE_DELAY = 15;++const items = data.map((item, i) => {+ const delay = BASE_DELAY + i * STAGGER_DELAY;+ const progress = spring({+ frame: frame - delay,+ fps,+ config: { damping: 15, stiffness: 120 }+ });+ return <Item key={i} style={{ opacity: progress, transform: `translateY(${(1 - progress) * 20}px)` }} />;+});+```++## Nested Sequences++Sequences can be nested for complex timing:++```tsx+<Sequence from={0} durationInFrames={120}>+ <Background />+ <Sequence from={15} durationInFrames={90}>+ <Title />+ </Sequence>+ <Sequence from={45} durationInFrames={60}>+ <Subtitle />+ </Sequence>+</Sequence>+```++## Frame References Inside Sequences++Inside a Sequence, useCurrentFrame() returns the local frame (starting from 0):++```tsx+<Sequence from={60} durationInFrames={30}>+ <MyComponent />+ {/* Inside MyComponent, useCurrentFrame() returns 0-29, not 60-89 */}+</Sequence>+```++---++## COMPLETE EXAMPLE: Staggered List Animation++Prompt: "A list of features that animate in one by one with a slide and fade effect"++```tsx+import { useCurrentFrame, useVideoConfig, AbsoluteFill, interpolate, spring } from "remotion";++export const MyAnimation = () => {+ /*+ * Feature list with staggered spring entrances and subtle hover-like highlights.+ */+ const frame = useCurrentFrame();+ const { fps } = useVideoConfig();++ const COLOR_BG = "#0f0f0f";+ const COLOR_TEXT = "#ffffff";+ const COLOR_ACCENT = "#6366f1";+ const COLOR_MUTED = "#a1a1aa";++ const TITLE = "Why Choose Us";+ const FEATURES = [+ { icon: "β‘", title: "Lightning Fast", desc: "Built for speed from the ground up" },+ { icon: "π", title: "Secure by Default", desc: "Enterprise-grade security included" },+ { icon: "π¨", title: "Beautiful Design", desc: "Crafted with attention to detail" },+ { icon: "π", title: "Scale Infinitely", desc: "Grows with your business needs" },+ ];++ const TITLE_FONT_SIZE = 48;+ const ITEM_FONT_SIZE = 28;+ const DESC_FONT_SIZE = 18;+ const ICON_SIZE = 48;+ const ITEM_GAP = 24;+ const PADDING = 60;++ const TITLE_START = 0;+ const ITEMS_START = 20;+ const STAGGER_DELAY = 12;+ const SLIDE_DISTANCE = 30;++ const titleProgress = spring({+ frame: frame - TITLE_START,+ fps,+ config: { damping: 20, stiffness: 100 }+ });++ return (+ <AbsoluteFill style={{+ backgroundColor: COLOR_BG,+ padding: PADDING,+ display: "flex",+ flexDirection: "column",+ justifyContent: "center",+ fontFamily: "Inter, sans-serif"+ }}>+ {/* Title */}+ <div style={{+ fontSize: TITLE_FONT_SIZE,+ fontWeight: 700,+ color: COLOR_TEXT,+ marginBottom: 40,+ opacity: titleProgress,+ transform: `translateY(${(1 - titleProgress) * 20}px)`+ }}>+ {TITLE}+ </div>++ {/* Feature list */}+ <div style={{ display: "flex", flexDirection: "column", gap: ITEM_GAP }}>+ {FEATURES.map((feature, i) => {+ const itemStart = ITEMS_START + i * STAGGER_DELAY;+ const itemProgress = spring({+ frame: frame - itemStart,+ fps,+ config: { damping: 15, stiffness: 120 }+ });+ const opacity = interpolate(itemProgress, [0, 1], [0, 1], { extrapolateLeft: "clamp", extrapolateRight: "clamp" });+ const translateX = interpolate(itemProgress, [0, 1], [SLIDE_DISTANCE, 0], { extrapolateLeft: "clamp", extrapolateRight: "clamp" });++ return (+ <div+ key={i}+ style={{+ display: "flex",+ alignItems: "center",+ gap: 20,+ opacity,+ transform: `translateX(${translateX}px)`+ }}+ >+ <div style={{+ width: ICON_SIZE,+ height: ICON_SIZE,+ borderRadius: 12,+ backgroundColor: COLOR_ACCENT + "20",+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ fontSize: 24+ }}>+ {feature.icon}+ </div>+ <div>+ <div style={{ fontSize: ITEM_FONT_SIZE, fontWeight: 600, color: COLOR_TEXT }}>+ {feature.title}+ </div>+ <div style={{ fontSize: DESC_FONT_SIZE, color: COLOR_MUTED, marginTop: 4 }}>+ {feature.desc}+ </div>+ </div>+ </div>+ );+ })}+ </div>+ </AbsoluteFill>+ );+};+```diff --git a/packages/template-prompt-to-motion-graphics/src/skills/social-media.md b/packages/template-prompt-to-motion-graphics/src/skills/social-media.mdnew file mode 100644index 0000000000..d9064e44e1--- /dev/null+++ b/packages/template-prompt-to-motion-graphics/src/skills/social-media.md@@ -0,0 +1,101 @@+---+title: Social Media Content+impact: MEDIUM+impactDescription: optimizes content for mobile viewing and engagement+tags: social, instagram, tiktok, reels, stories, mobile+---++## Safe Zone for UI Overlays++Keep key content in the center 80% to avoid platform UI elements.++**Incorrect (content at edges - gets covered by UI):**++```tsx+<AbsoluteFill style={{ padding: 10 }}>+ <div style={{ position: "absolute", top: 0 }}>Title</div>+ <div style={{ position: "absolute", bottom: 0 }}>CTA</div>+</AbsoluteFill>+```++**Correct (content in safe zone):**++```tsx+const SAFE_MARGIN_TOP = height * 0.12;+const SAFE_MARGIN_BOTTOM = height * 0.15;+const SAFE_MARGIN_SIDES = width * 0.05;++<AbsoluteFill style={{+ paddingTop: SAFE_MARGIN_TOP,+ paddingBottom: SAFE_MARGIN_BOTTOM,+ paddingLeft: SAFE_MARGIN_SIDES,+ paddingRight: SAFE_MARGIN_SIDES+}}>+ {content}+</AbsoluteFill>+```++## Mobile-First Text Sizing++Text must be readable on small screens. Minimum 48px for headlines.++**Incorrect (text too small for mobile):**++```tsx+const TITLE_SIZE = 24;+const BODY_SIZE = 14;+```++**Correct (mobile-readable sizes):**++```tsx+const TITLE_SIZE = Math.max(48, Math.round(width * 0.08));+const BODY_SIZE = Math.max(28, Math.round(width * 0.045));+```++## Hook in First Frames++Social content needs immediate visual interest. Add movement from frame 0.++**Incorrect (static start):**++```tsx+const entrance = spring({ frame: frame - 30, fps }); // Starts after 1 second+```++**Correct (immediate hook):**++```tsx+const entrance = spring({ frame, fps, config: { damping: 12, stiffness: 200 } });+const pulse = Math.sin(frame * 0.15) * 0.03 + 1; // Subtle constant motion++<div style={{ transform: `scale(${entrance * pulse})` }}>+ {content}+</div>+```++## High Contrast Colors++Use bold, saturated colors that pop on mobile screens.++```tsx+// Good for social+const COLOR_PRIMARY = "#FF3366";+const COLOR_ACCENT = "#00D4FF";+const COLOR_BG = "#0A0A0A";++// Avoid muted/pastel colors that look washed out+// const COLOR_PRIMARY = "#C4A4A4"; // Too muted+```++## Loop-Friendly Endings++Design animations that can seamlessly loop.++```tsx+const TOTAL_DURATION = durationInFrames;+const loopProgress = (frame % TOTAL_DURATION) / TOTAL_DURATION;++// Or fade to start state at the end+const fadeOut = interpolate(frame, [TOTAL_DURATION - 15, TOTAL_DURATION], [1, 0]);+```diff --git a/packages/template-prompt-to-motion-graphics/src/skills/spring-physics.md b/packages/template-prompt-to-motion-graphics/src/skills/spring-physics.mdnew file mode 100644index 0000000000..9b2d6abba9--- /dev/null+++ b/packages/template-prompt-to-motion-graphics/src/skills/spring-physics.md@@ -0,0 +1,128 @@+---+title: Spring Physics Animation+impact: HIGH+impactDescription: creates natural, organic motion instead of mechanical animations+tags: spring, physics, bounce, easing, organic+---++## Prefer spring() Over interpolate()++Use spring() for natural motion, interpolate() only for linear progress.++**Incorrect (mechanical motion):**++```tsx+const scale = interpolate(frame, [0, 30], [0, 1], { extrapolateRight: "clamp" });+```++**Correct (organic spring motion):**++```tsx+const scale = spring({+ frame,+ fps,+ config: { damping: 12, stiffness: 100 },+ durationInFrames: 30+});+```++## Spring Config Parameters++```tsx+spring({+ frame,+ fps,+ config: {+ damping: 10, // Higher = less bounce (10-200)+ stiffness: 100, // Higher = faster snap (50-200)+ mass: 1, // Higher = more inertia (0.5-3)+ }+});+```++## Common Spring Presets++```tsx+// Snappy, minimal bounce (UI elements)+const snappy = { damping: 20, stiffness: 200 };++// Bouncy entrance (playful animations)+const bouncy = { damping: 8, stiffness: 100 };++// Smooth, no bounce (subtle reveals)+const smooth = { damping: 200, stiffness: 100 };++// Heavy, slow (large objects)+const heavy = { damping: 15, stiffness: 80, mass: 2 };+```++## Delayed Spring Start++Offset the frame for delayed spring animations:++**Incorrect (spring starts immediately):**++```tsx+const entrance = spring({ frame, fps, config: { damping: 12 } });+```++**Correct (spring starts after delay):**++```tsx+const ENTRANCE_DELAY = 20;+const entrance = spring({+ frame: frame - ENTRANCE_DELAY,+ fps,+ config: { damping: 12, stiffness: 100 }+});+// Returns 0 until frame 20, then animates to 1+```++## Spring for Scale with Overshoot++For bouncy scale animations that overshoot:++```tsx+const bounce = spring({+ frame,+ fps,+ config: { damping: 8, stiffness: 150 }+});+// Will overshoot past 1.0 before settling++<div style={{ transform: `scale(${bounce})` }}>+ {content}+</div>+```++## Combining Spring with Interpolate++Map spring output (0-1) to custom ranges:++```tsx+const springProgress = spring({ frame, fps, config: { damping: 15 } });++// Map to rotation+const rotation = interpolate(springProgress, [0, 1], [0, 360]);++// Map to position+const translateY = interpolate(springProgress, [0, 1], [50, 0]);++<div style={{ transform: `translateY(${translateY}px) rotate(${rotation}deg)` }}>+```++## Chained Springs for Sequential Motion++```tsx+const PHASE_1_END = 30;+const PHASE_2_START = 25; // Slight overlap++const phase1 = spring({ frame, fps, config: { damping: 15 } });+const phase2 = spring({+ frame: frame - PHASE_2_START,+ fps,+ config: { damping: 12 }+});++// phase1 controls entrance, phase2 controls secondary motion+```diff --git a/packages/template-prompt-to-motion-graphics/src/skills/transitions.md b/packages/template-prompt-to-motion-graphics/src/skills/transitions.mdnew file mode 100644index 0000000000..d00e768e83--- /dev/null+++ b/packages/template-prompt-to-motion-graphics/src/skills/transitions.md@@ -0,0 +1,106 @@+---+title: Scene Transitions+impact: HIGH+impactDescription: enables smooth scene changes and professional video flow+tags: transitions, fade, slide, wipe, scenes+---++## TransitionSeries for Scene Changes++Use TransitionSeries to animate between multiple scenes or clips.++**Incorrect (abrupt scene cuts):**++```tsx+<Sequence from={0} durationInFrames={60}>+ <SceneA />+</Sequence>+<Sequence from={60} durationInFrames={60}>+ <SceneB />+</Sequence>+```++**Correct (smooth transitions):**++```tsx+import { TransitionSeries, linearTiming } from "@remotion/transitions";+import { fade } from "@remotion/transitions/fade";++<TransitionSeries>+ <TransitionSeries.Sequence durationInFrames={60}>+ <SceneA />+ </TransitionSeries.Sequence>+ <TransitionSeries.Transition+ presentation={fade()}+ timing={linearTiming({ durationInFrames: 15 })}+ />+ <TransitionSeries.Sequence durationInFrames={60}>+ <SceneB />+ </TransitionSeries.Sequence>+</TransitionSeries>+```++## Available Transition Types++Import transitions from their respective modules:++```tsx+import { fade } from "@remotion/transitions/fade";+import { slide } from "@remotion/transitions/slide";+import { wipe } from "@remotion/transitions/wipe";+import { flip } from "@remotion/transitions/flip";+import { clockWipe } from "@remotion/transitions/clock-wipe";+```++## Slide Transition with Direction++Specify slide direction for enter/exit animations.++```tsx+import { slide } from "@remotion/transitions/slide";++<TransitionSeries.Transition+ presentation={slide({ direction: "from-left" })}+ timing={linearTiming({ durationInFrames: 20 })}+/>+```++Directions: `"from-left"`, `"from-right"`, `"from-top"`, `"from-bottom"`++## Custom Crossfade Without TransitionSeries++For simple opacity crossfades within a single component:++```tsx+const TRANSITION_START = 60;+const TRANSITION_DURATION = 15;++const scene1Opacity = interpolate(+ frame,+ [TRANSITION_START, TRANSITION_START + TRANSITION_DURATION],+ [1, 0],+ { extrapolateLeft: "clamp", extrapolateRight: "clamp" }+);++const scene2Opacity = interpolate(+ frame,+ [TRANSITION_START, TRANSITION_START + TRANSITION_DURATION],+ [0, 1],+ { extrapolateLeft: "clamp", extrapolateRight: "clamp" }+);++<AbsoluteFill style={{ opacity: scene1Opacity }}><SceneA /></AbsoluteFill>+<AbsoluteFill style={{ opacity: scene2Opacity }}><SceneB /></AbsoluteFill>+```++## Timing Options++```tsx+import { linearTiming, springTiming } from "@remotion/transitions";++// Linear timing - constant speed+linearTiming({ durationInFrames: 20 })++// Spring timing - organic motion+springTiming({ config: { damping: 200 }, durationInFrames: 25 })+```diff --git a/packages/template-prompt-to-motion-graphics/src/skills/typography.md b/packages/template-prompt-to-motion-graphics/src/skills/typography.mdnew file mode 100644index 0000000000..149a58ab34--- /dev/null+++ b/packages/template-prompt-to-motion-graphics/src/skills/typography.md@@ -0,0 +1,431 @@+---+title: Typography & Text Animation+impact: HIGH+impactDescription: fixes common text animation bugs and improves readability+tags: typography, text, typewriter, kinetic, animation+---++## Typewriter Effect - Use String Slicing++Always use string slicing for typewriter effects. Never use per-character opacity.++**Incorrect (per-character opacity - breaks cursor positioning):**++```tsx+{+ text+ .split("")+ .map((char, i) => (+ <span style={{ opacity: i < typedCount ? 1 : 0 }}>{char}</span>+ ));+}+<span>|</span>;+```++**Correct (string slicing - cursor follows text):**++```tsx+const typedText = FULL_TEXT.slice(0, typedChars);++<span>{typedText}</span>+<span style={{ opacity: caretOpacity }}>β</span>+```++## Cursor Blink - Use Smooth Interpolation++Blinking cursors should fade smoothly, not flash on/off abruptly.++**Incorrect (abrupt blink):**++```tsx+const caretVisible = Math.floor(frame / 15) % 2 === 0;+<span style={{ opacity: caretVisible ? 1 : 0 }}>|</span>;+```++**Correct (smooth blink):**++```tsx+const CURSOR_BLINK_FRAMES = 16;+const caretOpacity = interpolate(+ frame % CURSOR_BLINK_FRAMES,+ [0, CURSOR_BLINK_FRAMES / 2, CURSOR_BLINK_FRAMES],+ [1, 0, 1],+ { extrapolateLeft: "clamp", extrapolateRight: "clamp" },+);++<span style={{ opacity: caretOpacity }}>β</span>;+```++## Word Carousel - Stable Width Container++Prevent layout shifts by using the longest word to set container width.++**Incorrect (width jumps between words):**++```tsx+<div style={{ position: "relative" }}>+ <span>{WORDS[currentIndex]}</span>+</div>+```++**Correct (stable width from longest word):**++```tsx+const longestWord = WORDS.reduce(+ (a, b) => (a.length >= b.length ? a : b),+ WORDS[0],+);++<div style={{ position: "relative" }}>+ <div style={{ visibility: "hidden" }}>{longestWord}</div>+ <div style={{ position: "absolute", left: 0, top: 0 }}>+ {WORDS[currentIndex]}+ </div>+</div>;+```++## Text Highlight - Two Layer Crossfade++Use overlapping layers for smooth highlight transitions.++```tsx+const typedOpacity = interpolate(+ frame,+ [highlightStart - 8, highlightStart + 8],+ [1, 0],+ { extrapolateLeft: "clamp", extrapolateRight: "clamp" },+);+const finalOpacity = interpolate(+ frame,+ [highlightStart, highlightStart + 8],+ [0, 1],+ { extrapolateLeft: "clamp", extrapolateRight: "clamp" },+);++{+ /* Typing layer */+}+<div style={{ opacity: typedOpacity }}>{typedText}</div>;++{+ /* Final layer with highlight */+}+<div style={{ position: "absolute", inset: 0, opacity: finalOpacity }}>+ <span>{preText}</span>+ <span style={{ backgroundColor: COLOR_HIGHLIGHT }}>{HIGHLIGHT_WORD}</span>+ <span>{postText}</span>+</div>;+```++---++## COMPLETE EXAMPLE: Typewriter with Highlight++Prompt: "Text with typewriter effect, pause mid-sentence, then highlight a word"++```tsx+import {+ useCurrentFrame,+ useVideoConfig,+ AbsoluteFill,+ interpolate,+ spring,+} from "remotion";++export const MyAnimation = () => {+ /*+ * Typewriter with blinking cursor, dramatic pause, spring-based highlight, and layer crossfade.+ */+ const frame = useCurrentFrame();+ const { fps } = useVideoConfig();++ const COLOR_TEXT = "#000000";+ const COLOR_HIGHLIGHT = "#A7C7E7";++ const FULL_TEXT = "From prompt to motion graphics. This is Remotion.";+ const HIGHLIGHT_WORD = "Remotion";+ const CARET_SYMBOL = "β";+ const SPLIT_AFTER = " This is Remotion.";++ const FONT_SIZE = 72;+ const FONT_WEIGHT = 700;+ const CHAR_FRAMES = 2;+ const CURSOR_BLINK_FRAMES = 16;+ const HIGHLIGHT_DELAY = 6;+ const HIGHLIGHT_WIPE_DURATION = 18;+ const CROSSFADE_DURATION = 8;+ const WAIT_AFTER_PRE_SECONDS = 1;++ const WAIT_AFTER_PRE_FRAMES = Math.round(fps * WAIT_AFTER_PRE_SECONDS);+ const f = frame;++ const splitIndex = FULL_TEXT.indexOf(SPLIT_AFTER);+ const preLen = splitIndex >= 0 ? splitIndex : FULL_TEXT.length;+ const postLen = FULL_TEXT.length - preLen;++ let typedChars = 0;+ if (f < preLen * CHAR_FRAMES) {+ typedChars = Math.floor(f / CHAR_FRAMES);+ } else if (f < preLen * CHAR_FRAMES + WAIT_AFTER_PRE_FRAMES) {+ typedChars = preLen;+ } else {+ const postPhase = f - preLen * CHAR_FRAMES - WAIT_AFTER_PRE_FRAMES;+ typedChars = Math.min(+ FULL_TEXT.length,+ preLen + Math.floor(postPhase / CHAR_FRAMES),+ );+ }+ const typedText = FULL_TEXT.slice(0, typedChars);+ const typingDone = typedChars >= FULL_TEXT.length;++ const caretOpacity = !typingDone+ ? interpolate(+ f % CURSOR_BLINK_FRAMES,+ [0, CURSOR_BLINK_FRAMES / 2, CURSOR_BLINK_FRAMES],+ [1, 0, 1],+ { extrapolateLeft: "clamp", extrapolateRight: "clamp" },+ )+ : 0;++ const highlightIndex = FULL_TEXT.indexOf(HIGHLIGHT_WORD);+ const hasHighlight = highlightIndex >= 0;+ const preText = hasHighlight ? FULL_TEXT.slice(0, highlightIndex) : FULL_TEXT;+ const postText = hasHighlight+ ? FULL_TEXT.slice(highlightIndex + HIGHLIGHT_WORD.length)+ : "";++ const typeEnd =+ preLen * CHAR_FRAMES + WAIT_AFTER_PRE_FRAMES + postLen * CHAR_FRAMES;+ const highlightStart = typeEnd + HIGHLIGHT_DELAY;++ const typedOpacity = interpolate(+ f,+ [highlightStart - CROSSFADE_DURATION, highlightStart + CROSSFADE_DURATION],+ [1, 0],+ { extrapolateLeft: "clamp", extrapolateRight: "clamp" },+ );+ const finalOpacity = interpolate(+ f,+ [highlightStart, highlightStart + CROSSFADE_DURATION],+ [0, 1],+ { extrapolateLeft: "clamp", extrapolateRight: "clamp" },+ );++ const entrance = spring({+ fps,+ frame: f,+ config: { damping: 200, stiffness: 120 },+ durationInFrames: 20,+ });+ const containerScale = interpolate(entrance, [0, 1], [0.98, 1], {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ });++ const highlightProgress = spring({+ fps,+ frame: f - highlightStart,+ config: { damping: 200, stiffness: 180 },+ durationInFrames: HIGHLIGHT_WIPE_DURATION,+ });+ const highlightScaleX = Math.max(0, Math.min(1, highlightProgress));++ return (+ <AbsoluteFill+ style={{+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ fontFamily: "Inter, sans-serif",+ }}+ >+ <div+ style={{ position: "relative", transform: `scale(${containerScale})` }}+ >+ {/* Typing layer */}+ <div+ style={{+ color: COLOR_TEXT,+ fontSize: FONT_SIZE,+ fontWeight: FONT_WEIGHT,+ lineHeight: 1.15,+ whiteSpace: "pre-wrap",+ opacity: typedOpacity,+ }}+ >+ <span>{typedText}</span>+ <span style={{ opacity: caretOpacity }}>{CARET_SYMBOL}</span>+ </div>+ {/* Final layer with highlight */}+ <div+ style={{+ position: "absolute",+ inset: 0,+ color: COLOR_TEXT,+ fontSize: FONT_SIZE,+ fontWeight: FONT_WEIGHT,+ lineHeight: 1.15,+ whiteSpace: "pre-wrap",+ opacity: finalOpacity,+ }}+ >+ {hasHighlight ? (+ <>+ <span>{preText}</span>+ <span style={{ position: "relative", display: "inline-block" }}>+ <span+ style={{+ position: "absolute",+ left: 0,+ right: 0,+ top: "50%",+ height: "1.05em",+ transform: `translateY(-50%) scaleX(${highlightScaleX})`,+ transformOrigin: "left center",+ backgroundColor: COLOR_HIGHLIGHT,+ borderRadius: "0.18em",+ zIndex: 0,+ }}+ />+ <span style={{ position: "relative", zIndex: 1 }}>+ {HIGHLIGHT_WORD}+ </span>+ </span>+ <span>{postText}</span>+ </>+ ) : (+ <span>{FULL_TEXT}</span>+ )}+ </div>+ </div>+ </AbsoluteFill>+ );+};+```++---++## COMPLETE EXAMPLE: Rotating Word Carousel++Prompt: "Text that dissolves between different words"++```tsx+import { useCurrentFrame, AbsoluteFill, interpolate } from "remotion";++export const MyAnimation = () => {+ /*+ * Prefix text with rotating words that crossfade with blur.+ */+ const frame = useCurrentFrame();++ const COLOR_TEXT = "#7b92c1";+ const PREFIX = "Created for";+ const WORDS = ["Creators", "Marketers", "Developers", "Everyone"];++ const PREFIX_FONT_SIZE = 80;+ const WORD_FONT_SIZE = 80;+ const PREFIX_WEIGHT = 300;+ const WORD_WEIGHT = 700;+ const WORD_GAP = 20;+ const HOLD_DURATION = 32;+ const FLIP_DURATION = 18;+ const BLUR_AMOUNT = 6;++ const perStep = HOLD_DURATION + FLIP_DURATION;+ const totalSteps = WORDS.length;+ const currentStep = Math.floor(frame / perStep) % totalSteps;+ const nextStep = (currentStep + 1) % totalSteps;+ const phase = frame % perStep;+ const isFlipping = phase >= HOLD_DURATION;+ const flipProgress = isFlipping ? (phase - HOLD_DURATION) / FLIP_DURATION : 0;++ const outOpacity = interpolate(flipProgress, [0, 1], [1, 0], {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ });+ const inOpacity = interpolate(flipProgress, [0, 1], [0, 1], {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ });+ const outBlur = interpolate(flipProgress, [0, 1], [0, BLUR_AMOUNT], {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ });+ const inBlur = interpolate(flipProgress, [0, 1], [BLUR_AMOUNT, 0], {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ });++ const longestWord = WORDS.reduce(+ (a, b) => (a.length >= b.length ? a : b),+ WORDS[0],+ );++ return (+ <AbsoluteFill+ style={{+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ fontFamily: "Inter, sans-serif",+ }}+ >+ <div+ style={{+ display: "flex",+ alignItems: "baseline",+ gap: WORD_GAP,+ color: COLOR_TEXT,+ }}+ >+ <div style={{ fontSize: PREFIX_FONT_SIZE, fontWeight: PREFIX_WEIGHT }}>+ {PREFIX}+ </div>+ <div+ style={{+ position: "relative",+ fontSize: WORD_FONT_SIZE,+ fontWeight: WORD_WEIGHT,+ }}+ >+ {/* Invisible width keeper */}+ <div style={{ visibility: "hidden" }}>{longestWord}</div>+ {/* Current word (fades out during flip) */}+ {!isFlipping && (+ <div style={{ position: "absolute", left: 0, top: 0 }}>+ {WORDS[currentStep]}+ </div>+ )}+ {/* Crossfade during flip */}+ {isFlipping && (+ <>+ <div+ style={{+ position: "absolute",+ left: 0,+ top: 0,+ opacity: outOpacity,+ filter: `blur(${outBlur}px)`,+ }}+ >+ {WORDS[currentStep]}+ </div>+ <div+ style={{+ position: "absolute",+ left: 0,+ top: 0,+ opacity: inOpacity,+ filter: `blur(${inBlur}px)`,+ }}+ >+ {WORDS[nextStep]}+ </div>+ </>+ )}+ </div>+ </div>+ </AbsoluteFill>+ );+};+```