Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
Add cursor gravity pull transition
kapishdima1d30f00840a8
diff --git a/config/site.ts b/config/site.tsindex a960998a..6115bbbb 100644--- a/config/site.ts+++ b/config/site.ts@@ -80,6 +80,7 @@ export const NEW_BADGE_PATHS = new Set<string>(["/docs/typography/word-push","/docs/typography/word-stream","/docs/typography/zoom-words",+ "/docs/effects/cursor-gravity","/docs/effects/radial-burst","/docs/ui-blocks/search-reveal",]);diff --git a/content/docs/effects/cursor-gravity.mdx b/content/docs/effects/cursor-gravity.mdxnew file mode 100644index 00000000..dde9afb0--- /dev/null+++ b/content/docs/effects/cursor-gravity.mdx@@ -0,0 +1,87 @@+---+title: Cursor Gravity+description: A rounded triangular cursor tugs a button out of the screen edge with pulsed elastic resistance+component: cursor-gravity+vibe: playful+length: 151+useWhen:+ - "An empty scene should reveal a call to action through a physical pulling gesture."+ - "A button needs to feel extracted from beyond the frame with tension, recoil, and release."+avoidWhen:+ - "A cursor must accurately demonstrate an existing interface — use simulated-cursor."+ - "Two complete scenes need to swap — this reveals one element rather than replacing the whole frame."+---++<ComponentPreview name="cursor-gravity" />++<InstallBlock name="cursor-gravity" />++## Usage++An empty scene. A soft triangular cursor arrives from below, approaches the+right edge and catches a hidden button. Two quick tugs pull its leading edge+into view, pause under load, and recoil. The button's back remains outside the+frame, stretching the surface into a narrow neck. A final pull frees the whole+button, which settles at center as the cursor exits below.++```tsx+import { CursorGravity } from "@/components/remocn/cursor-gravity";++export const Scene = () => <CursorGravity label="Create something" />;+```++`Tension` controls the recoil and surface deformation. The cursor’s rear bows backward under each tug while its tip stays at the+attachment point, then springs back as the effort releases. The pulse is in the+movement itself: a fast pull, a short hold, a small release, then a stronger+pull. All motion is frame-driven, including the spring and cursor shape.++## Custom content++The button has a 300 × 88 reference-pixel content slot. Supply `children` to+replace its label and arrow with your own content. The surrounding surface is+still the elastic button; text remains unstretched as it travels with the+material. Use compact content that fits the slot.++```tsx+<CursorGravity color="#e8ef9b" backgroundColor="#201426" tension={1.2}>+ <span style={{ fontSize: 26 }}>Start creating ↗</span>+</CursorGravity>+```++The composition's actual right edge is always the extraction boundary,+including in portrait and square renders. Element sizes scale with the smaller+of `width / 1280` and `height / 720`. A transparent background lets the button+appear over an existing scene.++## Timing++Reference frames at 30 fps and `speed={1}`:++| Frames | Motion |+| --- | --- |+| 0–10 | Empty scene |+| 10–39 | Triangular cursor enters from below |+| 39–48 | Cursor approaches and catches the right edge |+| 48–70 | First tug, hold, and recoil |+| 70–94 | Stronger second tug, hold, and recoil |+| 94–132 | Final pull; the trailing edge releases and springs inward |+| 132–151 | Button settles; cursor finishes exiting below |+| 151–180 | Centered button holds |++`cursorGravityLength` is 151, when the reveal and cursor exit have finished.+`getCursorGravityDuration({ speed })` includes the final hold and returns+frames at 30 fps. Multiply by `fps / 30` and round up for another frame rate.+Playback duration in seconds is consistent across frame rates. The final+button stays in place after the sequence ends.++<PropsTable title="Props" rows={[+ { name: "children", type: "ReactNode", description: "Replace the label and arrow; fits a 300 × 88 content slot" },+ { name: "label", type: "string", default: '"Create something"', description: "Default button label; long text truncates; ignored with children" },+ { name: "tension", type: "number", default: "1", description: "Elastic neck deformation and recoil, clamped to 0–1.5" },+ { name: "cursorColor", type: "string", default: '"#fffaf0"', description: "Rounded triangular cursor and short attachment thread" },+ { name: "color", type: "string", default: '"#fffaf0"', description: "Elastic button surface" },+ { name: "textColor", type: "string", default: '"#32153c"', description: "Button label and arrow" },+ { name: "backgroundColor", type: "string", default: '"#a800b7"', description: "Full-frame background; accepts transparent" },+ { name: "speed", type: "number", default: "1", description: "Time multiplier; zero or negative freezes the empty initial frame" },+ { name: "className", type: "string", description: "Class on the full-frame root" },+]} />diff --git a/content/docs/effects/index.mdx b/content/docs/effects/index.mdxindex 83d698f6..7b24a194 100644--- a/content/docs/effects/index.mdx+++ b/content/docs/effects/index.mdx@@ -7,6 +7,12 @@ Drop-in effect overlays you compose on top of any scene — fire them on a frame<ComponentCardGriditems={[+ {+ name: "Cursor Gravity",+ description: "A soft triangular cursor extracts a hidden button from the screen edge with elastic tugs",+ status: "stable",+ href: "/docs/effects/cursor-gravity",+ },{name: "Radial Burst",description: "A sculptural intro — twisting ribbons fold into a tilted ring and sweep outward with contour echoes",diff --git a/content/docs/effects/meta.json b/content/docs/effects/meta.jsonindex 39c9f6c6..0d73f2ca 100644--- a/content/docs/effects/meta.json+++ b/content/docs/effects/meta.json@@ -3,6 +3,7 @@"defaultOpen": true,"pages": ["index",+ "cursor-gravity","radial-burst","tv-power-off","confetti",diff --git a/docs/plans/2026-09-08-cursor-gravity-design.md b/docs/plans/2026-09-08-cursor-gravity-design.mdnew file mode 100644index 00000000..e3c282bf--- /dev/null+++ b/docs/plans/2026-09-08-cursor-gravity-design.md@@ -0,0 +1,21 @@+# Cursor Gravity++The user approved implementing the eight creative concepts in order, one per+review cycle. First: cursor-gravity. Do not start layout-domino until the user+accepts this result and says to continue. Remaining order: type-fossil,+screen-loom, time-echo, negative-space-reveal, perspective-secret,+interface-pressure.++Revised direction from user review: start with an empty scene. A rounded+triangular cursor enters from outside the frame, approaches the screen edge,+and extracts a hidden button. The action should read as an entrance transition.+Two pulsed tugs, each with a hold and recoil, stretch the leading edge while the+back remains offscreen. A final pull frees the button, which settles in the+center; the cursor exits. No orbit or collection of visible tiles.++Six seconds at 30 fps. Use the actual composition edge for the extraction on+all aspect ratios. An SVG surface deforms into a narrow neck; lettering keeps+its shape. Expose label or custom content, tension, palette and speed. Verify+empty opening, offscreen back during the tugs, continuity, arbitrary seeking,+final hold and cursor exit. Render the revised sequence for review before+proceeding to another component.diff --git a/registry-artifacts/cursor-gravity.json b/registry-artifacts/cursor-gravity.jsonnew file mode 100644index 00000000..8dab63b4--- /dev/null+++ b/registry-artifacts/cursor-gravity.json@@ -0,0 +1,16 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "cursor-gravity",+ "title": "Cursor Gravity",+ "description": "A rounded triangular cursor tugs a button out of the screen edge with pulsed elastic resistance.",+ "dependencies": ["remotion"],+ "files": [+ {+ "path": "registry/remocn/cursor-gravity/index.tsx",+ "content": "\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport { Easing, useCurrentFrame, useVideoConfig } from \"remotion\";\n\nexport interface CursorGravityProps {\n /** Custom content in a 300 × 88 reference-pixel slot. */\n children?: ReactNode;\n label?: string;\n /** Strength of the elastic neck and recoil, 0–1.5. */\n tension?: number;\n cursorColor?: string;\n color?: string;\n textColor?: string;\n backgroundColor?: string;\n speed?: number;\n className?: string;\n}\n\nexport const cursorGravityLength = 151;\nconst DURATION = 180;\nconst finite = (value: number, fallback: number) =>\n Number.isFinite(value) ? value : fallback;\nconst clamp = (value: number) => Math.max(0, Math.min(1, value));\nconst mix = (a: number, b: number, p: number) => a + (b - a) * p;\nconst progress = (frame: number, start: number, end: number) =>\n clamp((frame - start) / (end - start));\nconst ease = Easing.bezier(0.65, 0, 0.35, 1);\nconst pullEase = Easing.bezier(0.12, 0.8, 0.22, 1);\n\n/** Complete transition plus a one-second hold, in frames at 30 fps. */\nexport function getCursorGravityDuration({\n speed = 1,\n}: Pick<CursorGravityProps, \"speed\"> = {}) {\n const rate = Math.max(0, finite(speed, 1));\n return rate === 0 ? 1 : Math.max(1, Math.ceil(DURATION / rate));\n}\n\n/** A pull advances sharply, pauses under load, then recoils before the next tug. */\nfunction pullDistance(t: number, strength: number) {\n const keys = [\n [48, 0],\n [59, 116],\n [64, 116],\n [70, 116 - 30 * strength],\n [83, 292],\n [87, 292],\n [94, 292 - 42 * strength],\n [112, 772],\n ];\n if (t <= keys[0][0]) return 0;\n for (let i = 1; i < keys.length; i++) {\n const [start, a] = keys[i - 1];\n const [end, b] = keys[i];\n if (t <= end)\n return mix(a, b, (b > a ? pullEase : ease)(progress(t, start, end)));\n }\n return 772;\n}\n\n/** Pure, resolution-aware pose. The right edge is the real composition boundary. */\nexport function getCursorGravityState(\n frame: number,\n {\n width = 1280,\n height = 720,\n tension = 1,\n }: { width?: number; height?: number; tension?: number } = {},\n) {\n const w = Math.max(1, finite(width, 1280));\n const h = Math.max(1, finite(height, 720));\n const unit = Math.min(w / 1280, h / 720);\n const t = Math.max(0, finite(frame, 0));\n const strength = Math.max(0, Math.min(1.5, finite(tension, 1)));\n const centerY = h * 0.5;\n const finalLeft = w / 2 - 150 * unit;\n const finalRight = w / 2 + 150 * unit;\n const edgeTip = w - 24 * unit;\n const distance = pullDistance(t, strength) / 772;\n const extraction = distance * (edgeTip - (finalLeft - 14 * unit));\n // The back of the button resists the first two tugs beyond the frame edge.\n const releaseTime = progress(t, 94, 132);\n // Closed-form damped spring stays continuous at fractional frames too.\n const springRelease =\n 1 -\n Math.exp(-7 * releaseTime) *\n (Math.cos(10 * releaseTime) + 0.7 * Math.sin(10 * releaseTime));\n const release = mix(springRelease, 1, ease(progress(t, 122, 132)));\n const front = mix(w + 12 * unit, finalLeft, distance);\n const right = mix(w + 312 * unit - distance * 70 * unit, finalRight, release);\n const buttonWidth = Math.max(220 * unit, right - front);\n const strain = clamp((buttonWidth / (300 * unit) - 1) / 1.3) * strength;\n const wobble =\n t < 112\n ? 0\n : Math.sin((t - 112) * 0.48) *\n Math.exp(-(t - 112) * 0.14) *\n 5 *\n unit *\n strength *\n (1 - progress(t, 132, 140));\n const y = centerY + wobble;\n const entry = ease(progress(t, 10, 39));\n const approach = ease(progress(t, 39, 48));\n const leave = ease(progress(t, 127, 151));\n const holdTip = mix(w * 0.28, edgeTip - 80 * unit, entry);\n const pullTip = edgeTip - extraction;\n const cursorX =\n t < 48 ? mix(holdTip, edgeTip, approach) : mix(pullTip, w * 0.25, leave);\n const cursorY =\n t < 39\n ? mix(h + 110 * unit, centerY + 70 * unit, entry)\n : t < 48\n ? mix(centerY + 70 * unit, centerY, approach)\n : mix(centerY, h + 110 * unit, leave);\n // Triangle points toward the edge while pulling; turns toward its exit afterward.\n const cursorAngle = t < 48 ? mix(-32, 0, approach) : mix(0, 115, leave);\n const effortPulse = (\n start: number,\n peak: number,\n hold: number,\n end: number,\n ) => ease(progress(t, start, peak)) * (1 - ease(progress(t, hold, end)));\n const cursorEffort =\n strength *\n (0.8 * effortPulse(48, 58, 64, 70) +\n effortPulse(70, 81, 87, 94) +\n 1.15 * effortPulse(94, 100, 104, 118));\n return {\n frame: t,\n unit,\n front,\n right: front + buttonWidth,\n buttonWidth,\n centerY: y,\n strain,\n neckHeight: 88 * unit * (1 - 0.58 * strain),\n bodyHeight: 88 * unit * (1 - 0.17 * strain),\n cursorX,\n cursorY,\n cursorAngle,\n cursorEffort,\n attached: t >= 48 && t <= 121,\n tetherOpacity: progress(t, 46, 49) * (1 - progress(t, 115, 122)),\n };\n}\n\n/** The tip stays fixed; the rear bows backward as each tug builds effort. */\nexport function getGravityCursorPath(effort: number) {\n const load = Math.max(0, Math.min(1.725, finite(effort, 0)));\n const shoulder = -62 - 30 * load;\n const rear = -70 - 40 * load;\n const halfHeight = 26 - 4 * load;\n return `M -5 -4 Q 3 0 -5 4\n C -24 ${11.333 - load * 3} ${shoulder + 19} ${halfHeight - 7.333} ${shoulder} ${halfHeight}\n Q ${rear} ${halfHeight + 4} ${rear} ${halfHeight - 6}\n C ${rear} 4 ${rear - 18 * load} 8 ${rear - 18 * load} 0\n C ${rear - 18 * load} -8 ${rear} -4 ${rear} ${-halfHeight + 6}\n Q ${rear} ${-halfHeight - 4} ${shoulder} ${-halfHeight}\n C ${shoulder + 19} ${-halfHeight + 7.333} -24 ${-11.333 + load * 3} -5 -4 Z`;\n}\n\n/** Rounded rectangle with a narrow leading edge: the pull deforms the surface. */\nexport function getGravityButtonPath(\n state: ReturnType<typeof getCursorGravityState>,\n) {\n const { buttonWidth: w, neckHeight, bodyHeight, unit } = state;\n const a = neckHeight / 2;\n const b = bodyHeight / 2;\n const r = Math.min(25 * unit, a * 0.9);\n const backRadius = 25 * unit;\n return `M ${r} ${-a}\n C ${w * 0.35} ${-a} ${w * 0.35} ${-b} ${w - backRadius} ${-b}\n Q ${w} ${-b} ${w} ${-b + backRadius}\n L ${w} ${b - backRadius} Q ${w} ${b} ${w - backRadius} ${b}\n C ${w * 0.35} ${b} ${w * 0.35} ${a} ${r} ${a}\n Q 0 ${a} 0 ${a - r} L 0 ${-a + r} Q 0 ${-a} ${r} ${-a} Z`;\n}\n\nexport function CursorGravity({\n children,\n label = \"Create something\",\n tension = 1,\n cursorColor = \"#fffaf0\",\n color = \"#fffaf0\",\n textColor = \"#32153c\",\n backgroundColor = \"#a800b7\",\n speed = 1,\n className,\n}: CursorGravityProps) {\n const frame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const t = frame * (30 / fps) * Math.max(0, finite(speed, 1));\n const state = getCursorGravityState(t, { width, height, tension });\n const { unit } = state;\n // Content travels with the material, without stretching the lettering.\n const contentUnit = unit * Math.min(1, state.buttonWidth / (300 * unit));\n const contentX = state.front + state.buttonWidth - 150 * contentUnit;\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n backgroundColor,\n fontFamily: \"Arial, sans-serif\",\n }}\n >\n <svg\n width={width}\n height={height}\n viewBox={`0 0 ${width} ${height}`}\n aria-hidden=\"true\"\n style={{ position: \"absolute\", inset: 0 }}\n >\n <path\n d={getGravityButtonPath(state)}\n transform={`translate(${state.front} ${state.centerY})`}\n fill={color}\n />\n <path\n d={`M ${state.cursorX + 2 * unit} ${state.cursorY} Q ${mix(state.cursorX, state.front, 0.5)} ${state.centerY} ${state.front + 2 * unit} ${state.centerY}`}\n fill=\"none\"\n stroke={cursorColor}\n strokeWidth={2 * unit}\n strokeLinecap=\"round\"\n opacity={state.tetherOpacity}\n />\n </svg>\n <div\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n width: 300,\n height: 88,\n translate: `${contentX - 150 * contentUnit}px ${state.centerY - 44 * contentUnit}px`,\n scale: contentUnit,\n transformOrigin: \"top left\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: 20,\n color: textColor,\n fontWeight: 600,\n fontSize: 23,\n }}\n >\n {children ?? (\n <>\n <span\n style={{\n maxWidth: 220,\n overflow: \"hidden\",\n whiteSpace: \"nowrap\",\n textOverflow: \"ellipsis\",\n }}\n >\n {label}\n </span>\n <svg width=\"22\" height=\"22\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path\n d=\"M5 12H19M13 6L19 12L13 18\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </>\n )}\n </div>\n <svg\n width={190 * unit}\n height={70 * unit}\n viewBox=\"-180 -35 190 70\"\n role=\"img\"\n aria-label=\"Rounded triangular cursor\"\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n translate: `${state.cursorX - 180 * unit}px ${state.cursorY - 35 * unit}px`,\n transform: `rotate(${state.cursorAngle}deg)`,\n transformOrigin: `${180 * unit}px ${35 * unit}px`,\n }}\n >\n <path d={getGravityCursorPath(state.cursorEffort)} fill={cursorColor} />\n </svg>\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/cursor-gravity.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/elements/cursor-gravity.json b/registry-artifacts/elements/cursor-gravity.jsonnew file mode 100644index 00000000..02b11500--- /dev/null+++ b/registry-artifacts/elements/cursor-gravity.json@@ -0,0 +1,14 @@+{+ "type": "remotion-element",+ "version": 1,+ "element": {+ "dependencies": [],+ "dimensions": null,+ "displayName": "Cursor Gravity",+ "durationInFrames": 151,+ "installationMode": "component-owned-sequence",+ "slug": "cursor-gravity",+ "sourceCode": "import { forwardRef, useImperativeHandle, useRef, type ComponentProps, type ReactNode } from \"react\";\nimport { Easing, Interactive, Sequence, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface CursorGravityProps {\n /** Custom content in a 300 × 88 reference-pixel slot. */\n children?: ReactNode;\n label?: string;\n /** Strength of the elastic neck and recoil, 0–1.5. */\n tension?: number;\n cursorColor?: string;\n color?: string;\n textColor?: string;\n backgroundColor?: string;\n speed?: number;\n className?: string;\n}\n\nconst cursorGravityLength = 151;\nconst DURATION = 180;\nconst finite = (value: number, fallback: number) =>\n Number.isFinite(value) ? value : fallback;\nconst clamp = (value: number) => Math.max(0, Math.min(1, value));\nconst mix = (a: number, b: number, p: number) => a + (b - a) * p;\nconst progress = (frame: number, start: number, end: number) =>\n clamp((frame - start) / (end - start));\nconst ease = Easing.bezier(0.65, 0, 0.35, 1);\nconst pullEase = Easing.bezier(0.12, 0.8, 0.22, 1);\n\n/** Complete transition plus a one-second hold, in frames at 30 fps. */\nfunction getCursorGravityDuration({\n speed = 1,\n}: Pick<CursorGravityProps, \"speed\"> = {}) {\n const rate = Math.max(0, finite(speed, 1));\n return rate === 0 ? 1 : Math.max(1, Math.ceil(DURATION / rate));\n}\n\n/** A pull advances sharply, pauses under load, then recoils before the next tug. */\nfunction pullDistance(t: number, strength: number) {\n const keys = [\n [48, 0],\n [59, 116],\n [64, 116],\n [70, 116 - 30 * strength],\n [83, 292],\n [87, 292],\n [94, 292 - 42 * strength],\n [112, 772],\n ];\n if (t <= keys[0][0]) return 0;\n for (let i = 1; i < keys.length; i++) {\n const [start, a] = keys[i - 1];\n const [end, b] = keys[i];\n if (t <= end)\n return mix(a, b, (b > a ? pullEase : ease)(progress(t, start, end)));\n }\n return 772;\n}\n\n/** Pure, resolution-aware pose. The right edge is the real composition boundary. */\nfunction getCursorGravityState(\n frame: number,\n {\n width = 1280,\n height = 720,\n tension = 1,\n }: { width?: number; height?: number; tension?: number } = {},\n) {\n const w = Math.max(1, finite(width, 1280));\n const h = Math.max(1, finite(height, 720));\n const unit = Math.min(w / 1280, h / 720);\n const t = Math.max(0, finite(frame, 0));\n const strength = Math.max(0, Math.min(1.5, finite(tension, 1)));\n const centerY = h * 0.5;\n const finalLeft = w / 2 - 150 * unit;\n const finalRight = w / 2 + 150 * unit;\n const edgeTip = w - 24 * unit;\n const distance = pullDistance(t, strength) / 772;\n const extraction = distance * (edgeTip - (finalLeft - 14 * unit));\n // The back of the button resists the first two tugs beyond the frame edge.\n const releaseTime = progress(t, 94, 132);\n // Closed-form damped spring stays continuous at fractional frames too.\n const springRelease =\n 1 -\n Math.exp(-7 * releaseTime) *\n (Math.cos(10 * releaseTime) + 0.7 * Math.sin(10 * releaseTime));\n const release = mix(springRelease, 1, ease(progress(t, 122, 132)));\n const front = mix(w + 12 * unit, finalLeft, distance);\n const right = mix(w + 312 * unit - distance * 70 * unit, finalRight, release);\n const buttonWidth = Math.max(220 * unit, right - front);\n const strain = clamp((buttonWidth / (300 * unit) - 1) / 1.3) * strength;\n const wobble =\n t < 112\n ? 0\n : Math.sin((t - 112) * 0.48) *\n Math.exp(-(t - 112) * 0.14) *\n 5 *\n unit *\n strength *\n (1 - progress(t, 132, 140));\n const y = centerY + wobble;\n const entry = ease(progress(t, 10, 39));\n const approach = ease(progress(t, 39, 48));\n const leave = ease(progress(t, 127, 151));\n const holdTip = mix(w * 0.28, edgeTip - 80 * unit, entry);\n const pullTip = edgeTip - extraction;\n const cursorX =\n t < 48 ? mix(holdTip, edgeTip, approach) : mix(pullTip, w * 0.25, leave);\n const cursorY =\n t < 39\n ? mix(h + 110 * unit, centerY + 70 * unit, entry)\n : t < 48\n ? mix(centerY + 70 * unit, centerY, approach)\n : mix(centerY, h + 110 * unit, leave);\n // Triangle points toward the edge while pulling; turns toward its exit afterward.\n const cursorAngle = t < 48 ? mix(-32, 0, approach) : mix(0, 115, leave);\n const effortPulse = (\n start: number,\n peak: number,\n hold: number,\n end: number,\n ) => ease(progress(t, start, peak)) * (1 - ease(progress(t, hold, end)));\n const cursorEffort =\n strength *\n (0.8 * effortPulse(48, 58, 64, 70) +\n effortPulse(70, 81, 87, 94) +\n 1.15 * effortPulse(94, 100, 104, 118));\n return {\n frame: t,\n unit,\n front,\n right: front + buttonWidth,\n buttonWidth,\n centerY: y,\n strain,\n neckHeight: 88 * unit * (1 - 0.58 * strain),\n bodyHeight: 88 * unit * (1 - 0.17 * strain),\n cursorX,\n cursorY,\n cursorAngle,\n cursorEffort,\n attached: t >= 48 && t <= 121,\n tetherOpacity: progress(t, 46, 49) * (1 - progress(t, 115, 122)),\n };\n}\n\n/** The tip stays fixed; the rear bows backward as each tug builds effort. */\nfunction getGravityCursorPath(effort: number) {\n const load = Math.max(0, Math.min(1.725, finite(effort, 0)));\n const shoulder = -62 - 30 * load;\n const rear = -70 - 40 * load;\n const halfHeight = 26 - 4 * load;\n return `M -5 -4 Q 3 0 -5 4\n C -24 ${11.333 - load * 3} ${shoulder + 19} ${halfHeight - 7.333} ${shoulder} ${halfHeight}\n Q ${rear} ${halfHeight + 4} ${rear} ${halfHeight - 6}\n C ${rear} 4 ${rear - 18 * load} 8 ${rear - 18 * load} 0\n C ${rear - 18 * load} -8 ${rear} -4 ${rear} ${-halfHeight + 6}\n Q ${rear} ${-halfHeight - 4} ${shoulder} ${-halfHeight}\n C ${shoulder + 19} ${-halfHeight + 7.333} -24 ${-11.333 + load * 3} -5 -4 Z`;\n}\n\n/** Rounded rectangle with a narrow leading edge: the pull deforms the surface. */\nfunction getGravityButtonPath(\n state: ReturnType<typeof getCursorGravityState>,\n) {\n const { buttonWidth: w, neckHeight, bodyHeight, unit } = state;\n const a = neckHeight / 2;\n const b = bodyHeight / 2;\n const r = Math.min(25 * unit, a * 0.9);\n const backRadius = 25 * unit;\n return `M ${r} ${-a}\n C ${w * 0.35} ${-a} ${w * 0.35} ${-b} ${w - backRadius} ${-b}\n Q ${w} ${-b} ${w} ${-b + backRadius}\n L ${w} ${b - backRadius} Q ${w} ${b} ${w - backRadius} ${b}\n C ${w * 0.35} ${b} ${w * 0.35} ${a} ${r} ${a}\n Q 0 ${a} 0 ${a - r} L 0 ${-a + r} Q 0 ${-a} ${r} ${-a} Z`;\n}\n\nfunction CursorGravityBase({\n children,\n label = \"Create something\",\n tension = 1,\n cursorColor = \"#fffaf0\",\n color = \"#fffaf0\",\n textColor = \"#32153c\",\n backgroundColor = \"#a800b7\",\n speed = 1,\n className,\n}: CursorGravityProps) {\n const frame = useCurrentFrame();\n const { width, height, fps } = useVideoConfig();\n const t = frame * (30 / fps) * Math.max(0, finite(speed, 1));\n const state = getCursorGravityState(t, { width, height, tension });\n const { unit } = state;\n // Content travels with the material, without stretching the lettering.\n const contentUnit = unit * Math.min(1, state.buttonWidth / (300 * unit));\n const contentX = state.front + state.buttonWidth - 150 * contentUnit;\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n backgroundColor,\n fontFamily: \"Arial, sans-serif\",\n }}\n >\n <svg\n width={width}\n height={height}\n viewBox={`0 0 ${width} ${height}`}\n aria-hidden=\"true\"\n style={{ position: \"absolute\", inset: 0 }}\n >\n <path\n d={getGravityButtonPath(state)}\n transform={`translate(${state.front} ${state.centerY})`}\n fill={color}\n />\n <path\n d={`M ${state.cursorX + 2 * unit} ${state.cursorY} Q ${mix(state.cursorX, state.front, 0.5)} ${state.centerY} ${state.front + 2 * unit} ${state.centerY}`}\n fill=\"none\"\n stroke={cursorColor}\n strokeWidth={2 * unit}\n strokeLinecap=\"round\"\n opacity={state.tetherOpacity}\n />\n </svg>\n <div\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n width: 300,\n height: 88,\n translate: `${contentX - 150 * contentUnit}px ${state.centerY - 44 * contentUnit}px`,\n scale: contentUnit,\n transformOrigin: \"top left\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: 20,\n color: textColor,\n fontWeight: 600,\n fontSize: 23,\n }}\n >\n {children ?? (\n <>\n <span\n style={{\n maxWidth: 220,\n overflow: \"hidden\",\n whiteSpace: \"nowrap\",\n textOverflow: \"ellipsis\",\n }}\n >\n {label}\n </span>\n <svg width=\"22\" height=\"22\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path\n d=\"M5 12H19M13 6L19 12L13 18\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </>\n )}\n </div>\n <svg\n width={190 * unit}\n height={70 * unit}\n viewBox=\"-180 -35 190 70\"\n role=\"img\"\n aria-label=\"Rounded triangular cursor\"\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n translate: `${state.cursorX - 180 * unit}px ${state.cursorY - 35 * unit}px`,\n transform: `rotate(${state.cursorAngle}deg)`,\n transformOrigin: `${180 * unit}px ${35 * unit}px`,\n }}\n >\n <path d={getGravityCursorPath(state.cursorEffort)} fill={cursorColor} />\n </svg>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n label: {\n type: \"text-content\",\n default: \"Create something\",\n description: \"Button label\",\n },\n tension: {\n type: \"number\",\n default: 1,\n min: 0,\n max: 1.5,\n step: 0.1,\n description: \"Pull tension\",\n hiddenFromList: false,\n },\n cursorColor: {\n type: \"color\",\n default: \"#fffaf0\",\n description: \"Cursor\",\n },\n color: {\n type: \"color\",\n default: \"#fffaf0\",\n description: \"Button\",\n },\n textColor: {\n type: \"color\",\n default: \"#32153c\",\n description: \"Button text\",\n },\n backgroundColor: {\n type: \"color\",\n default: \"#a800b7\",\n description: \"Background\",\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([\"label\",\"tension\",\"cursorColor\",\"color\",\"textColor\",\"backgroundColor\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n label: \"Create something\",\n tension: 1,\n cursorColor: \"#fffaf0\",\n color: \"#fffaf0\",\n textColor: \"#32153c\",\n backgroundColor: \"#a800b7\",\n speed: 1,\n};\n\ntype CursorGravityElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CursorGravityBase>;\n\nconst CursorGravityInner = forwardRef<\n HTMLDivElement,\n CursorGravityElementProps & { 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 ?? \"<CursorGravity>\"}\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 <CursorGravityBase\n {...(componentProps as unknown as ComponentProps<typeof CursorGravityBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CursorGravity = Interactive.withSchema({\n Component: CursorGravityInner,\n componentName: \"<CursorGravity>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n"+ },+ "durationInFrames": 151+}diff --git a/registry-artifacts/registry.json b/registry-artifacts/registry.jsonindex 385a2fed..8f07b871 100644--- a/registry-artifacts/registry.json+++ b/registry-artifacts/registry.json@@ -2207,6 +2207,20 @@],"type": "registry:component"},+ {+ "name": "cursor-gravity",+ "title": "Cursor Gravity",+ "description": "A rounded triangular cursor tugs a button out of the screen edge with pulsed elastic resistance.",+ "dependencies": ["remotion"],+ "files": [+ {+ "path": "registry/remocn/cursor-gravity/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/cursor-gravity.tsx"+ }+ ],+ "type": "registry:component"+ },{"name": "remocn-ui","title": "remocn UI Core",diff --git a/registry/__index__.tsx b/registry/__index__.tsxindex 752513b1..99e236e2 100644--- a/registry/__index__.tsx+++ b/registry/__index__.tsx@@ -2246,6 +2246,16 @@ const registry: Record<string, RegistryEntry> = {(m) => m.xFollowersOverviewConfig,),},+ "cursor-gravity": {+ load: () =>+ import("@/registry/remocn/cursor-gravity").then((m) => ({+ default: m.CursorGravity,+ })),+ loadConfig: () =>+ import("@/registry/remocn/cursor-gravity/config").then(+ (m) => m.cursorGravityConfig,+ ),+ },"radial-burst": {load: () =>import("@/registry/remocn/radial-burst").then((m) => ({diff --git a/registry/__manifest__.ts b/registry/__manifest__.tsindex e95adb1f..7d07c41e 100644--- a/registry/__manifest__.ts+++ b/registry/__manifest__.ts@@ -565,6 +565,21 @@ export const previewManifest: Record<string, PreviewManifestEntry> = {speed: 1,},},+ "cursor-gravity": {+ durationInFrames: 180,+ fps: 30,+ compositionWidth: 1280,+ compositionHeight: 720,+ defaults: {+ label: "Create something",+ tension: 1,+ cursorColor: "#fffaf0",+ color: "#fffaf0",+ textColor: "#32153c",+ backgroundColor: "#a800b7",+ speed: 1,+ },+ },dialog: {durationInFrames: 120,fps: 30,diff --git a/registry/remocn/cursor-gravity/__tests__/cursor-gravity.test.ts b/registry/remocn/cursor-gravity/__tests__/cursor-gravity.test.tsnew file mode 100644index 00000000..f848ebff--- /dev/null+++ b/registry/remocn/cursor-gravity/__tests__/cursor-gravity.test.ts@@ -0,0 +1,121 @@+import { describe, expect, test } from "bun:test";+import {+ cursorGravityLength,+ getCursorGravityDuration,+ getCursorGravityState,+ getGravityButtonPath,+ getGravityCursorPath,+} from "..";++describe("cursor gravity extraction", () => {+ test("starts with the cursor and entire button outside the real viewport", () => {+ for (const [width, height] of [+ [1280, 720],+ [720, 1280],+ [1080, 1080],+ ]) {+ for (const frame of [0, 5, 10]) {+ const pose = getCursorGravityState(frame, { width, height });+ expect(pose.front).toBeGreaterThan(width);+ expect(pose.cursorY - 70 * pose.unit).toBeGreaterThan(height);+ expect(pose.tetherOpacity).toBe(0);+ }+ }+ });+ test("first two tugs advance, hold and recoil while the back stays hidden", () => {+ for (const [pull, hold, recoil] of [+ [59, 64, 70],+ [83, 87, 94],+ ]) {+ const a = getCursorGravityState(pull);+ const b = getCursorGravityState(hold);+ const c = getCursorGravityState(recoil);+ expect(b.front).toBe(a.front);+ expect(c.front).toBeGreaterThan(a.front);+ expect(a.right).toBeGreaterThan(1280);+ expect(a.strain).toBeGreaterThan(0);+ expect(a.neckHeight).toBeLessThan(a.bodyHeight);+ }+ });+ test("button settles at center and cursor exits for the final hold", () => {+ for (const [width, height] of [+ [1280, 720],+ [720, 1280],+ [1080, 1080],+ ]) {+ const pose = getCursorGravityState(cursorGravityLength, {+ width,+ height,+ });+ expect((pose.front + pose.right) / 2).toBeCloseTo(width / 2, 5);+ expect(pose.buttonWidth).toBeCloseTo(300 * pose.unit, 5);+ expect(pose.strain).toBe(0);+ expect(pose.cursorY - 70 * pose.unit).toBeGreaterThan(height);+ expect(pose.tetherOpacity).toBe(0);+ const late = getCursorGravityState(1000, { width, height });+ expect(late.front).toBe(pose.front);+ expect(late.right).toBe(pose.right);+ expect(late.centerY).toBe(pose.centerY);+ }+ });+ test("phase boundaries stay continuous and seeking does not change the result", () => {+ for (const t of [+ 10, 39, 48, 59, 64, 70, 83, 87, 94, 112, 127, 132, 140, 151,+ ]) {+ const a = getCursorGravityState(t - 0.0001);+ const b = getCursorGravityState(t + 0.0001);+ for (const key of [+ "front",+ "right",+ "centerY",+ "cursorX",+ "cursorY",+ "cursorAngle",+ ] as const) {+ expect(Math.abs(a[key] - b[key])).toBeLessThan(0.05);+ }+ const expected = getCursorGravityState(t);+ getCursorGravityState(200);+ getCursorGravityState(0);+ expect(getCursorGravityState(t)).toEqual(expected);+ }+ });+ test("geometry stays finite at supported tensions and proportions", () => {+ for (const tension of [0, 1, 1.5, Number.NaN]) {+ for (let frame = 0; frame <= 180; frame++) {+ const pose = getCursorGravityState(frame, { tension });+ expect(getGravityButtonPath(pose)).not.toMatch(/NaN|Infinity/);+ expect(pose.neckHeight).toBeGreaterThan(0);+ expect(pose.buttonWidth).toBeGreaterThan(0);+ }+ }+ });+ test("cursor rear loads on each tug and relaxes without moving its tip", () => {+ for (const peak of [58, 81, 100]) {+ const pose = getCursorGravityState(peak);+ expect(pose.cursorEffort).toBeGreaterThan(0.7);+ expect(getGravityCursorPath(pose.cursorEffort)).toStartWith(+ "M -5 -4 Q 3 0 -5 4",+ );+ expect(getCursorGravityState(peak, { tension: 0 }).cursorEffort).toBe(0);+ }+ for (const rest of [0, 48, 70, 94, 118, 180]) {+ expect(getCursorGravityState(rest).cursorEffort).toBe(0);+ }+ for (const t of [48, 58, 64, 70, 81, 87, 94, 100, 104, 118]) {+ expect(+ Math.abs(+ getCursorGravityState(t - 0.0001).cursorEffort -+ getCursorGravityState(t + 0.0001).cursorEffort,+ ),+ ).toBeLessThan(0.001);+ }+ });+ test("speed scales the transition and final hold", () => {+ expect(getCursorGravityDuration()).toBe(180);+ expect(getCursorGravityDuration({ speed: 0.5 })).toBe(360);+ expect(getCursorGravityDuration({ speed: 2 })).toBe(90);+ expect(getCursorGravityDuration({ speed: 0 })).toBe(1);+ expect(getCursorGravityDuration({ speed: Number.NaN })).toBe(180);+ });+});diff --git a/registry/remocn/cursor-gravity/config.ts b/registry/remocn/cursor-gravity/config.tsnew file mode 100644index 00000000..937a52f0--- /dev/null+++ b/registry/remocn/cursor-gravity/config.ts@@ -0,0 +1,40 @@+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";+import { getCursorGravityDuration } from ".";++export const cursorGravityConfig: ComponentConfig = {+ componentName: "CursorGravity",+ importPath: "@/components/remocn/cursor-gravity",+ controls: {+ label: {+ type: "text-content",+ default: "Create something",+ description: "Button label",+ },+ tension: {+ type: "number",+ default: 1,+ min: 0,+ max: 1.5,+ step: 0.1,+ description: "Pull tension",+ hiddenFromList: false,+ },+ cursorColor: { type: "color", default: "#fffaf0", description: "Cursor" },+ color: { type: "color", default: "#fffaf0", description: "Button" },+ textColor: {+ type: "color",+ default: "#32153c",+ description: "Button text",+ },+ backgroundColor: {+ type: "color",+ default: "#a800b7",+ description: "Background",+ },+ },+ durationInFrames: 180,+ getDurationInFrames: (values) => getCursorGravityDuration(values),+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+};diff --git a/registry/remocn/cursor-gravity/index.tsx b/registry/remocn/cursor-gravity/index.tsxnew file mode 100644index 00000000..bc2379a4--- /dev/null+++ b/registry/remocn/cursor-gravity/index.tsx@@ -0,0 +1,294 @@+"use client";++import type { ReactNode } from "react";+import { Easing, useCurrentFrame, useVideoConfig } from "remotion";++export interface CursorGravityProps {+ /** Custom content in a 300 × 88 reference-pixel slot. */+ children?: ReactNode;+ label?: string;+ /** Strength of the elastic neck and recoil, 0–1.5. */+ tension?: number;+ cursorColor?: string;+ color?: string;+ textColor?: string;+ backgroundColor?: string;+ speed?: number;+ className?: string;+}++export const cursorGravityLength = 151;+const DURATION = 180;+const finite = (value: number, fallback: number) =>+ Number.isFinite(value) ? value : fallback;+const clamp = (value: number) => Math.max(0, Math.min(1, value));+const mix = (a: number, b: number, p: number) => a + (b - a) * p;+const progress = (frame: number, start: number, end: number) =>+ clamp((frame - start) / (end - start));+const ease = Easing.bezier(0.65, 0, 0.35, 1);+const pullEase = Easing.bezier(0.12, 0.8, 0.22, 1);++/** Complete transition plus a one-second hold, in frames at 30 fps. */+export function getCursorGravityDuration({+ speed = 1,+}: Pick<CursorGravityProps, "speed"> = {}) {+ const rate = Math.max(0, finite(speed, 1));+ return rate === 0 ? 1 : Math.max(1, Math.ceil(DURATION / rate));+}++/** A pull advances sharply, pauses under load, then recoils before the next tug. */+function pullDistance(t: number, strength: number) {+ const keys = [+ [48, 0],+ [59, 116],+ [64, 116],+ [70, 116 - 30 * strength],+ [83, 292],+ [87, 292],+ [94, 292 - 42 * strength],+ [112, 772],+ ];+ if (t <= keys[0][0]) return 0;+ for (let i = 1; i < keys.length; i++) {+ const [start, a] = keys[i - 1];+ const [end, b] = keys[i];+ if (t <= end)+ return mix(a, b, (b > a ? pullEase : ease)(progress(t, start, end)));+ }+ return 772;+}++/** Pure, resolution-aware pose. The right edge is the real composition boundary. */+export function getCursorGravityState(+ frame: number,+ {+ width = 1280,+ height = 720,+ tension = 1,+ }: { width?: number; height?: number; tension?: number } = {},+) {+ const w = Math.max(1, finite(width, 1280));+ const h = Math.max(1, finite(height, 720));+ const unit = Math.min(w / 1280, h / 720);+ const t = Math.max(0, finite(frame, 0));+ const strength = Math.max(0, Math.min(1.5, finite(tension, 1)));+ const centerY = h * 0.5;+ const finalLeft = w / 2 - 150 * unit;+ const finalRight = w / 2 + 150 * unit;+ const edgeTip = w - 24 * unit;+ const distance = pullDistance(t, strength) / 772;+ const extraction = distance * (edgeTip - (finalLeft - 14 * unit));+ // The back of the button resists the first two tugs beyond the frame edge.+ const releaseTime = progress(t, 94, 132);+ // Closed-form damped spring stays continuous at fractional frames too.+ const springRelease =+ 1 -+ Math.exp(-7 * releaseTime) *+ (Math.cos(10 * releaseTime) + 0.7 * Math.sin(10 * releaseTime));+ const release = mix(springRelease, 1, ease(progress(t, 122, 132)));+ const front = mix(w + 12 * unit, finalLeft, distance);+ const right = mix(w + 312 * unit - distance * 70 * unit, finalRight, release);+ const buttonWidth = Math.max(220 * unit, right - front);+ const strain = clamp((buttonWidth / (300 * unit) - 1) / 1.3) * strength;+ const wobble =+ t < 112+ ? 0+ : Math.sin((t - 112) * 0.48) *+ Math.exp(-(t - 112) * 0.14) *+ 5 *+ unit *+ strength *+ (1 - progress(t, 132, 140));+ const y = centerY + wobble;+ const entry = ease(progress(t, 10, 39));+ const approach = ease(progress(t, 39, 48));+ const leave = ease(progress(t, 127, 151));+ const holdTip = mix(w * 0.28, edgeTip - 80 * unit, entry);+ const pullTip = edgeTip - extraction;+ const cursorX =+ t < 48 ? mix(holdTip, edgeTip, approach) : mix(pullTip, w * 0.25, leave);+ const cursorY =+ t < 39+ ? mix(h + 110 * unit, centerY + 70 * unit, entry)+ : t < 48+ ? mix(centerY + 70 * unit, centerY, approach)+ : mix(centerY, h + 110 * unit, leave);+ // Triangle points toward the edge while pulling; turns toward its exit afterward.+ const cursorAngle = t < 48 ? mix(-32, 0, approach) : mix(0, 115, leave);+ const effortPulse = (+ start: number,+ peak: number,+ hold: number,+ end: number,+ ) => ease(progress(t, start, peak)) * (1 - ease(progress(t, hold, end)));+ const cursorEffort =+ strength *+ (0.8 * effortPulse(48, 58, 64, 70) ++ effortPulse(70, 81, 87, 94) ++ 1.15 * effortPulse(94, 100, 104, 118));+ return {+ frame: t,+ unit,+ front,+ right: front + buttonWidth,+ buttonWidth,+ centerY: y,+ strain,+ neckHeight: 88 * unit * (1 - 0.58 * strain),+ bodyHeight: 88 * unit * (1 - 0.17 * strain),+ cursorX,+ cursorY,+ cursorAngle,+ cursorEffort,+ attached: t >= 48 && t <= 121,+ tetherOpacity: progress(t, 46, 49) * (1 - progress(t, 115, 122)),+ };+}++/** The tip stays fixed; the rear bows backward as each tug builds effort. */+export function getGravityCursorPath(effort: number) {+ const load = Math.max(0, Math.min(1.725, finite(effort, 0)));+ const shoulder = -62 - 30 * load;+ const rear = -70 - 40 * load;+ const halfHeight = 26 - 4 * load;+ return `M -5 -4 Q 3 0 -5 4+ C -24 ${11.333 - load * 3} ${shoulder + 19} ${halfHeight - 7.333} ${shoulder} ${halfHeight}+ Q ${rear} ${halfHeight + 4} ${rear} ${halfHeight - 6}+ C ${rear} 4 ${rear - 18 * load} 8 ${rear - 18 * load} 0+ C ${rear - 18 * load} -8 ${rear} -4 ${rear} ${-halfHeight + 6}+ Q ${rear} ${-halfHeight - 4} ${shoulder} ${-halfHeight}+ C ${shoulder + 19} ${-halfHeight + 7.333} -24 ${-11.333 + load * 3} -5 -4 Z`;+}++/** Rounded rectangle with a narrow leading edge: the pull deforms the surface. */+export function getGravityButtonPath(+ state: ReturnType<typeof getCursorGravityState>,+) {+ const { buttonWidth: w, neckHeight, bodyHeight, unit } = state;+ const a = neckHeight / 2;+ const b = bodyHeight / 2;+ const r = Math.min(25 * unit, a * 0.9);+ const backRadius = 25 * unit;+ return `M ${r} ${-a}+ C ${w * 0.35} ${-a} ${w * 0.35} ${-b} ${w - backRadius} ${-b}+ Q ${w} ${-b} ${w} ${-b + backRadius}+ L ${w} ${b - backRadius} Q ${w} ${b} ${w - backRadius} ${b}+ C ${w * 0.35} ${b} ${w * 0.35} ${a} ${r} ${a}+ Q 0 ${a} 0 ${a - r} L 0 ${-a + r} Q 0 ${-a} ${r} ${-a} Z`;+}++export function CursorGravity({+ children,+ label = "Create something",+ tension = 1,+ cursorColor = "#fffaf0",+ color = "#fffaf0",+ textColor = "#32153c",+ backgroundColor = "#a800b7",+ speed = 1,+ className,+}: CursorGravityProps) {+ const frame = useCurrentFrame();+ const { width, height, fps } = useVideoConfig();+ const t = frame * (30 / fps) * Math.max(0, finite(speed, 1));+ const state = getCursorGravityState(t, { width, height, tension });+ const { unit } = state;+ // Content travels with the material, without stretching the lettering.+ const contentUnit = unit * Math.min(1, state.buttonWidth / (300 * unit));+ const contentX = state.front + state.buttonWidth - 150 * contentUnit;+ return (+ <div+ className={className}+ style={{+ position: "absolute",+ inset: 0,+ overflow: "hidden",+ backgroundColor,+ fontFamily: "Arial, sans-serif",+ }}+ >+ <svg+ width={width}+ height={height}+ viewBox={`0 0 ${width} ${height}`}+ aria-hidden="true"+ style={{ position: "absolute", inset: 0 }}+ >+ <path+ d={getGravityButtonPath(state)}+ transform={`translate(${state.front} ${state.centerY})`}+ fill={color}+ />+ <path+ d={`M ${state.cursorX + 2 * unit} ${state.cursorY} Q ${mix(state.cursorX, state.front, 0.5)} ${state.centerY} ${state.front + 2 * unit} ${state.centerY}`}+ fill="none"+ stroke={cursorColor}+ strokeWidth={2 * unit}+ strokeLinecap="round"+ opacity={state.tetherOpacity}+ />+ </svg>+ <div+ style={{+ position: "absolute",+ left: 0,+ top: 0,+ width: 300,+ height: 88,+ translate: `${contentX - 150 * contentUnit}px ${state.centerY - 44 * contentUnit}px`,+ scale: contentUnit,+ transformOrigin: "top left",+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ gap: 20,+ color: textColor,+ fontWeight: 600,+ fontSize: 23,+ }}+ >+ {children ?? (+ <>+ <span+ style={{+ maxWidth: 220,+ overflow: "hidden",+ whiteSpace: "nowrap",+ textOverflow: "ellipsis",+ }}+ >+ {label}+ </span>+ <svg width="22" height="22" viewBox="0 0 24 24" aria-hidden="true">+ <path+ d="M5 12H19M13 6L19 12L13 18"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ strokeLinecap="round"+ strokeLinejoin="round"+ />+ </svg>+ </>+ )}+ </div>+ <svg+ width={190 * unit}+ height={70 * unit}+ viewBox="-180 -35 190 70"+ role="img"+ aria-label="Rounded triangular cursor"+ style={{+ position: "absolute",+ left: 0,+ top: 0,+ translate: `${state.cursorX - 180 * unit}px ${state.cursorY - 35 * unit}px`,+ transform: `rotate(${state.cursorAngle}deg)`,+ transformOrigin: `${180 * unit}px ${35 * unit}px`,+ }}+ >+ <path d={getGravityCursorPath(state.cursorEffort)} fill={cursorColor} />+ </svg>+ </div>+ );+}diff --git a/registry/remocn/registry.json b/registry/remocn/registry.jsonindex c19ed3cb..2183de7c 100644--- a/registry/remocn/registry.json+++ b/registry/remocn/registry.json@@ -2206,6 +2206,20 @@"target": "components/remocn/search-reveal.tsx"}]+ },+ {+ "name": "cursor-gravity",+ "type": "registry:component",+ "title": "Cursor Gravity",+ "description": "A rounded triangular cursor tugs a button out of the screen edge with pulsed elastic resistance.",+ "dependencies": ["remotion"],+ "files": [+ {+ "path": "cursor-gravity/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/cursor-gravity.tsx"+ }+ ]}]}