Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
{
"type": "remotion-element",
"version": 1,
"element": {
"assets": [],
"dependencies": [],
"dimensions": null,
"displayName": "Phyllotaxis",
"initialProps": null,
"slug": "phyllotaxis",
"sourceCode": "import { AbsoluteFill, Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ntype PhyllotaxisProps = {\n /** Number of seeds. */\n count?: number;\n /** Seed size multiplier. */\n size?: number;\n /** Frames for all seeds to spiral out. */\n growFrames?: number;\n /** Frames per pulse along the accent arm once grown. */\n pulseFrames?: number;\n /** Arm spacing: every n-th seed forms one parastichy (a Fibonacci number reads best). */\n arm?: number;\n /** Slow rotation of the head in degrees per second; 0 holds still. */\n rotation?: number;\n speed?: number;\n background?: string;\n color?: string;\n accent?: string;\n};\n\nconst phyllotaxisDefaults: Required<PhyllotaxisProps> = {\n count: 420,\n size: 1,\n growFrames: 60,\n pulseFrames: 45,\n arm: 21,\n rotation: 4,\n speed: 1,\n background: \"#111111\",\n color: \"#FFFFFF\",\n accent: \"#E5322D\",\n};\n\nconst GOLDEN = (137.508 * Math.PI) / 180;\nconst POP = 10;\nconst pop = Easing.out(Easing.back(2.2));\nconst clamp = { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" } as const;\nconst fmt = (n: number) => Math.round(n * 10) / 10;\nconst dot = (x: number, y: number, r: number) =>\n `M ${fmt(x - r)} ${fmt(y)} a ${fmt(r)} ${fmt(r)} 0 1 0 ${fmt(r * 2)} 0 a ${fmt(r)} ${fmt(r)} 0 1 0 ${fmt(-r * 2)} 0 `;\n\nfunction PhyllotaxisBase({\n count = phyllotaxisDefaults.count,\n size = phyllotaxisDefaults.size,\n growFrames = phyllotaxisDefaults.growFrames,\n pulseFrames = phyllotaxisDefaults.pulseFrames,\n arm = phyllotaxisDefaults.arm,\n rotation = phyllotaxisDefaults.rotation,\n speed = phyllotaxisDefaults.speed,\n background = phyllotaxisDefaults.background,\n color = phyllotaxisDefaults.color,\n accent = phyllotaxisDefaults.accent,\n}: PhyllotaxisProps) {\n const frame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const n = Math.max(1, Math.round(count));\n const step = Math.max(1, Math.round(arm));\n const time = frame * speed;\n const cx = width / 2;\n const cy = height / 2;\n const maxR = Math.min(width, height) * 0.44;\n const c = maxR / Math.sqrt(n);\n const spin = (rotation * Math.PI * time) / 180 / fps;\n\n // Seeds appear in order with a little overshoot; the reveal eases so the\n // dense centre does not flash in all at once.\n const grown = (i: number) => {\n const at = growFrames * Math.sqrt(i / n);\n return pop(Math.min(1, Math.max(0, (time - at) / POP)));\n };\n const armIn = interpolate(time, [growFrames, growFrames + 14], [0, 1], {\n ...clamp,\n easing: Easing.out(Easing.cubic),\n });\n const since = time - growFrames - 10;\n const pulse = since > 0 ? (since / Math.max(1, pulseFrames)) % 1 : -1;\n\n let plain = \"\";\n let red = \"\";\n let spine = \"\";\n for (let i = 1; i <= n; i++) {\n const s = grown(i);\n if (s <= 0) continue;\n const radius = c * Math.sqrt(i);\n const theta = i * GOLDEN + spin;\n const x = cx + Math.cos(theta) * radius;\n const y = cy + Math.sin(theta) * radius;\n // Outer seeds are a touch larger, like a sunflower head.\n const base = c * 0.42 * size * (0.55 + 0.45 * Math.sqrt(i / n));\n const onArm = i % step === 0 && armIn > 0;\n if (!onArm) {\n plain += dot(x, y, base * s);\n continue;\n }\n // Pulse travels outward along the arm as a soft gaussian bump.\n const u = Math.sqrt(i / n);\n const bump =\n pulse >= 0 ? Math.exp(-(((u - pulse * 1.4 + 0.2) / 0.09) ** 2)) : 0;\n red += dot(x, y, base * s * (1 + 0.25 * armIn + bump * 0.9));\n spine += `${spine ? \"L\" : \"M\"} ${fmt(x)} ${fmt(y)} `;\n }\n\n return (\n <AbsoluteFill style={{ backgroundColor: background }}>\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox={`0 0 ${width} ${height}`}\n role=\"img\"\n aria-label=\"PhyllotaxisBase spiral\"\n style={{ display: \"block\" }}\n >\n <path d={plain} fill={color} />\n {spine ? (\n <path\n d={spine}\n fill=\"none\"\n stroke={accent}\n strokeOpacity={0.35 * armIn}\n strokeWidth={Math.min(width, height) / 720}\n />\n ) : null}\n <path d={red} fill={color} fillOpacity={1 - armIn} />\n <path d={red} fill={accent} fillOpacity={armIn} />\n </svg>\n </AbsoluteFill>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n count: {\n type: \"number\",\n default: 420,\n min: 50,\n max: 1200,\n step: 10,\n description: \"Seeds\",\n hiddenFromList: false,\n },\n size: {\n type: \"number\",\n default: 1,\n min: 0.3,\n max: 2,\n step: 0.05,\n description: \"Seed size\",\n hiddenFromList: false,\n },\n arm: {\n type: \"number\",\n default: 21,\n min: 1,\n max: 89,\n step: 1,\n description: \"Arm spacing\",\n hiddenFromList: false,\n },\n growFrames: {\n type: \"number\",\n default: 60,\n min: 15,\n max: 150,\n step: 5,\n description: \"Grow frames\",\n hiddenFromList: false,\n },\n pulseFrames: {\n type: \"number\",\n default: 45,\n min: 15,\n max: 120,\n step: 5,\n description: \"Pulse frames\",\n hiddenFromList: false,\n },\n rotation: {\n type: \"number\",\n default: 4,\n min: -30,\n max: 30,\n step: 1,\n description: \"Rotation °/s\",\n hiddenFromList: false,\n },\n background: {\n type: \"color\",\n default: \"#111111\",\n description: \"Background\",\n },\n color: {\n type: \"color\",\n default: \"#FFFFFF\",\n description: \"Seeds\",\n },\n accent: {\n type: \"color\",\n default: \"#E5322D\",\n description: \"Arm\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"count\",\"size\",\"arm\",\"growFrames\",\"pulseFrames\",\"rotation\",\"background\",\"color\",\"accent\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n count: 420,\n size: 1,\n arm: 21,\n growFrames: 60,\n pulseFrames: 45,\n rotation: 4,\n background: \"#111111\",\n color: \"#FFFFFF\",\n accent: \"#E5322D\",\n speed: 1,\n};\n\ntype PhyllotaxisElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof PhyllotaxisBase>;\n\nconst PhyllotaxisInner = forwardRef<\n HTMLDivElement,\n PhyllotaxisElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<Phyllotaxis>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <PhyllotaxisBase\n {...(componentProps as unknown as ComponentProps<typeof PhyllotaxisBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const Phyllotaxis = Interactive.withSchema({\n Component: PhyllotaxisInner,\n componentName: \"<Phyllotaxis>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 74,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 74
}