Skip to content

Production-ready animations, transitions, backgrounds, and scenes for Remotion

feat: ink arrow

kapishdima6f61a169ff6d
diff --git a/components/docs/examples/ink-arrow-example.tsx b/components/docs/examples/ink-arrow-example.tsx
new file mode 100644
index 00000000..6e9b133a
--- /dev/null
+++ b/components/docs/examples/ink-arrow-example.tsx
@@ -0,0 +1,118 @@
+"use client";
+
+import { AbsoluteFill } from "remotion";
+import { InkArrow } from "@/registry/remocn/ink-arrow";
+
+const INK = "#26242c";
+const PENCIL = "rgba(38,36,44,0.55)";
+
+const FONT_FAMILY =
+ "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif";
+
+const FROM = { x: 20, y: 20 };
+const TO = { x: 300, y: 210 };
+
+export function InkArrowExampleScene({
+ curvature,
+ color,
+ strokeWidth,
+ drawDur,
+ headSize,
+ headDur,
+ seed,
+ step,
+}: {
+ curvature?: number;
+ color?: string;
+ strokeWidth?: number;
+ drawDur?: number;
+ headSize?: number;
+ headDur?: number;
+ seed?: string;
+ step?: number;
+}) {
+ return (
+ <AbsoluteFill>
+ <div
+ style={{
+ position: "absolute",
+ left: 200,
+ top: 150,
+ fontFamily: FONT_FAMILY,
+ fontSize: 52,
+ fontWeight: 600,
+ color: INK,
+ }}
+ >
+ Start here
+ </div>
+
+ <div style={{ position: "absolute", left: 300, top: 210 }}>
+ <InkArrow
+ from={FROM}
+ to={TO}
+ curvature={curvature}
+ color={color}
+ strokeWidth={strokeWidth}
+ drawDur={drawDur}
+ headSize={headSize}
+ headDur={headDur}
+ seed={seed}
+ step={step}
+ />
+ </div>
+
+ <div
+ style={{
+ position: "absolute",
+ left: 600,
+ top: 400,
+ background: "#fdfcf8",
+ border: "1px solid rgba(38,36,44,0.12)",
+ borderRadius: 4,
+ padding: "24px 32px",
+ boxShadow: "0 8px 20px rgba(38,36,44,0.12)",
+ fontFamily: FONT_FAMILY,
+ }}
+ >
+ <div style={{ fontSize: 28, fontWeight: 600, color: INK }}>
+ The thing it points at
+ </div>
+ <div style={{ fontSize: 18, color: PENCIL, marginTop: 6 }}>
+ Positioned by you, drawn by the pen
+ </div>
+ </div>
+ </AbsoluteFill>
+ );
+}
+
+export const inkArrowExampleCode = (
+ values: Record<string, unknown>,
+): string => {
+ const curvature = (values.curvature as number) ?? 0.35;
+ const color = (values.color as string) ?? "#26242c";
+ const strokeWidth = (values.strokeWidth as number) ?? 3;
+ const drawDur = (values.drawDur as number) ?? 36;
+ const headSize = (values.headSize as number) ?? 24;
+ const headDur = (values.headDur as number) ?? 12;
+ const seed = (values.seed as string) ?? "arrow";
+ const step = (values.step as number) ?? 3;
+ return `import { InkArrow } from "@/components/remocn/ink-arrow";
+
+export const MyScene = () => (
+ <div style={{ position: "absolute", left: 300, top: 210 }}>
+ <InkArrow
+ from={{ x: ${FROM.x}, y: ${FROM.y} }}
+ to={{ x: ${TO.x}, y: ${TO.y} }}
+ curvature={${curvature}}
+ color="${color}"
+ strokeWidth={${strokeWidth}}
+ drawDur={${drawDur}}
+ headSize={${headSize}}
+ headDur={${headDur}}
+ seed="${seed}"
+ step={${step}}
+ />
+ </div>
+);`;
+};
diff --git a/content/docs/components.mdx b/content/docs/components.mdx
index 2e4e5066..d4704e42 100644
--- a/content/docs/components.mdx
+++ b/content/docs/components.mdx
@@ -446,6 +446,12 @@ Physical overlays and hand-made motion.
status: "stable",
href: "/docs/effects/paper-wobble",
},
+ {
+ name: "InkArrow",
+ description: "A hand-drawn arrow that draws itself from one point to another, head popping on the final pose",
+ status: "stable",
+ href: "/docs/effects/ink-arrow",
+ },
]}
/>
diff --git a/content/docs/effects/ink-arrow.mdx b/content/docs/effects/ink-arrow.mdx
new file mode 100644
index 00000000..f402629d
--- /dev/null
+++ b/content/docs/effects/ink-arrow.mdx
@@ -0,0 +1,131 @@
+---
+title: Ink Arrow
+description: A hand-drawn arrow that draws itself from one point to another in stop-motion poses
+---
+
+<ComponentPreview name="ink-arrow" />
+
+## Installation
+
+<InstallBlock name="ink-arrow" />
+
+## Usage
+
+`from` and `to` are in the arrow's own local space — you place the component,
+the arrow draws inside it. The SVG lets its contents overflow, so the bow and
+the head are never clipped.
+
+```tsx
+// src/Root.tsx
+import { AbsoluteFill, Composition } from "remotion";
+import { InkArrow } from "@/components/remocn/ink-arrow";
+
+const InkArrowScene = () => (
+ <AbsoluteFill style={{ background: "#f1eee7" }}>
+ <h1 style={{ position: "absolute", left: 200, top: 150 }}>Start here</h1>
+
+ <div style={{ position: "absolute", left: 300, top: 210 }}>
+ <InkArrow from={{ x: 20, y: 20 }} to={{ x: 300, y: 210 }} />
+ </div>
+
+ <div style={{ position: "absolute", left: 600, top: 400 }}>
+ <YourCard />
+ </div>
+ </AbsoluteFill>
+);
+
+export const RemotionRoot = () => (
+ <Composition
+ id="InkArrow"
+ component={InkArrowScene}
+ durationInFrames={120}
+ fps={30}
+ width={1280}
+ height={720}
+ />
+);
+```
+
+The pen drags the curve over `drawDur` frames, quantized to the stop-motion
+clock. When the line lands, the head is drawn rather than dropped in: one
+stroke out from the tip, then the other, over `headDur` frames split evenly
+between them.
+
+`curvature` is the perpendicular bow as a fraction of the distance between the
+two points, so the arc keeps its shape as the arrow gets longer. Flip its sign
+to bow the other way. Each control point also carries a small per-`seed`
+wobble, which is what stops the curve looking machine-drawn; the same seed
+always gives the same hand.
+
+## Props
+
+<PropsTable
+ rows={[
+ {
+ name: "from",
+ type: "{ x: number; y: number }",
+ required: true,
+ description: "Start point, in the component's local space",
+ },
+ {
+ name: "to",
+ type: "{ x: number; y: number }",
+ required: true,
+ description: "End point — where the head lands",
+ },
+ {
+ name: "curvature",
+ type: "number",
+ default: "0.35",
+ description: "Perpendicular bow as a fraction of the distance; negative bows the other way",
+ },
+ {
+ name: "color",
+ type: "string",
+ default: "\"#26242c\"",
+ description: "Ink colour (any valid CSS color)",
+ },
+ {
+ name: "strokeWidth",
+ type: "number",
+ default: "3",
+ description: "Pen width in pixels",
+ },
+ {
+ name: "delay",
+ type: "number",
+ default: "0",
+ description: "Frames on the local clock before the drag begins",
+ },
+ {
+ name: "drawDur",
+ type: "number",
+ default: "36",
+ description: "Frames the contour takes to draw",
+ },
+ {
+ name: "headSize",
+ type: "number",
+ default: "24",
+ description: "Length of each head stroke in pixels",
+ },
+ {
+ name: "headDur",
+ type: "number",
+ default: "step * 4",
+ description: "Frames to draw both head strokes, split evenly between them",
+ },
+ {
+ name: "seed",
+ type: "string",
+ default: "\"arrow\"",
+ description: "Seed for the curve wobble — same seed, same arrow",
+ },
+ {
+ name: "step",
+ type: "number",
+ default: "3",
+ description: "Frames per stop-motion pose — the tempo control",
+ },
+ ]}
+/>
diff --git a/content/docs/effects/meta.json b/content/docs/effects/meta.json
index e72e2dad..f8b32835 100644
--- a/content/docs/effects/meta.json
+++ b/content/docs/effects/meta.json
@@ -1,5 +1,5 @@
{
"title": "Effects",
"collapsible": false,
- "pages": ["index", "confetti", "paper-wobble"]
+ "pages": ["index", "confetti", "paper-wobble", "ink-arrow"]
}
diff --git a/registry-artifacts/ink-arrow.json b/registry-artifacts/ink-arrow.json
new file mode 100644
index 00000000..f8cd18cf
--- /dev/null
+++ b/registry-artifacts/ink-arrow.json
@@ -0,0 +1,17 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "ink-arrow",
+ "title": "Ink Arrow",
+ "description": "A hand-drawn arrow that draws itself from one point to another in stop-motion poses, with the head popping on the final pose.",
+ "dependencies": ["remotion"],
+ "registryDependencies": ["@remocn/stop-motion"],
+ "files": [
+ {
+ "path": "registry/remocn/ink-arrow/index.tsx",
+ "content": "\"use client\";\n\nimport { useCurrentFrame } from \"remotion\";\nimport { DEFAULT_STEP, hashRange, steppedRamp } from \"@/lib/remocn/stop-motion\";\n\nconst easeOutCubic = (t: number) => 1 - (1 - t) ** 3;\n\nconst HEAD_ANGLE = 0.6;\n\nexport type InkArrowPoint = { x: number; y: number };\n\nexport function inkArrowControls(\n from: InkArrowPoint,\n to: InkArrowPoint,\n curvature: number,\n seed: string,\n): { c1: InkArrowPoint; c2: InkArrowPoint } {\n const dx = to.x - from.x;\n const dy = to.y - from.y;\n const distance = Math.hypot(dx, dy) || 1;\n const normalX = -dy / distance;\n const normalY = dx / distance;\n const bow = curvature * distance;\n const wobble = distance * 0.06;\n\n const at = (t: number, key: string): InkArrowPoint => ({\n x:\n from.x +\n dx * t +\n normalX * bow +\n hashRange(`${seed}:${key}:x`, -wobble, wobble),\n y:\n from.y +\n dy * t +\n normalY * bow +\n hashRange(`${seed}:${key}:y`, -wobble, wobble),\n });\n\n return { c1: at(0.3, \"c1\"), c2: at(0.7, \"c2\") };\n}\n\nexport function inkArrowHead(\n c2: InkArrowPoint,\n to: InkArrowPoint,\n headSize: number,\n): { left: InkArrowPoint; right: InkArrowPoint } {\n const dx = to.x - c2.x;\n const dy = to.y - c2.y;\n const length = Math.hypot(dx, dy) || 1;\n const backX = -dx / length;\n const backY = -dy / length;\n\n const arm = (angle: number): InkArrowPoint => ({\n x: to.x + headSize * (backX * Math.cos(angle) - backY * Math.sin(angle)),\n y: to.y + headSize * (backX * Math.sin(angle) + backY * Math.cos(angle)),\n });\n\n return { left: arm(HEAD_ANGLE), right: arm(-HEAD_ANGLE) };\n}\n\nexport function inkArrowViewport(\n from: InkArrowPoint,\n to: InkArrowPoint,\n curvature: number,\n headSize: number,\n strokeWidth: number,\n): { width: number; height: number } {\n const distance = Math.hypot(to.x - from.x, to.y - from.y);\n const margin = headSize + Math.abs(curvature) * distance + strokeWidth;\n return {\n width: Math.max(margin, Math.max(from.x, to.x) + margin),\n height: Math.max(margin, Math.max(from.y, to.y) + margin),\n };\n}\n\nexport interface InkArrowProps {\n from: InkArrowPoint;\n to: InkArrowPoint;\n curvature?: number;\n color?: string;\n strokeWidth?: number;\n delay?: number;\n drawDur?: number;\n headSize?: number;\n headDur?: number;\n seed?: string;\n step?: number;\n}\n\nexport function InkArrow({\n from,\n to,\n curvature = 0.35,\n color = \"#26242c\",\n strokeWidth = 3,\n delay = 0,\n drawDur = 36,\n headSize = 24,\n headDur,\n seed = \"arrow\",\n step = DEFAULT_STEP,\n}: InkArrowProps) {\n const frame = useCurrentFrame();\n const progress = steppedRamp(frame, delay, delay + drawDur, {\n ease: easeOutCubic,\n step,\n });\n const { c1, c2 } = inkArrowControls(from, to, curvature, seed);\n const head = inkArrowHead(c2, to, headSize);\n\n const headFrames = headDur ?? step * 4;\n const headStart = delay + drawDur;\n const headMid = headStart + headFrames / 2;\n const leftArm = steppedRamp(frame, headStart, headMid, {\n ease: easeOutCubic,\n step,\n });\n const rightArm = steppedRamp(frame, headMid, headStart + headFrames, {\n ease: easeOutCubic,\n step,\n });\n\n const { width, height } = inkArrowViewport(\n from,\n to,\n curvature,\n headSize,\n strokeWidth,\n );\n\n return (\n <svg\n width={width}\n height={height}\n viewBox={`0 0 ${width} ${height}`}\n style={{\n display: \"block\",\n overflow: \"visible\",\n opacity: progress > 0 ? 1 : 0,\n }}\n >\n <path\n d={`M ${from.x} ${from.y} C ${c1.x} ${c1.y}, ${c2.x} ${c2.y}, ${to.x} ${to.y}`}\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n fill=\"none\"\n pathLength={1}\n strokeDasharray={1}\n strokeDashoffset={1 - progress}\n />\n <path\n d={`M ${to.x} ${to.y} L ${head.left.x} ${head.left.y}`}\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n fill=\"none\"\n pathLength={1}\n strokeDasharray={1}\n strokeDashoffset={1 - leftArm}\n />\n <path\n d={`M ${to.x} ${to.y} L ${head.right.x} ${head.right.y}`}\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n fill=\"none\"\n pathLength={1}\n strokeDasharray={1}\n strokeDashoffset={1 - rightArm}\n />\n </svg>\n );\n}\n",
+ "type": "registry:component",
+ "target": "components/remocn/ink-arrow.tsx"
+ }
+ ],
+ "type": "registry:component"
+}
diff --git a/registry-artifacts/registry.json b/registry-artifacts/registry.json
index 421e4bd4..eda8ea17 100644
--- a/registry-artifacts/registry.json
+++ b/registry-artifacts/registry.json
@@ -1328,6 +1328,21 @@
],
"type": "registry:component"
},
+ {
+ "name": "ink-arrow",
+ "title": "Ink Arrow",
+ "description": "A hand-drawn arrow that draws itself from one point to another in stop-motion poses, with the head popping on the final pose.",
+ "dependencies": ["remotion"],
+ "registryDependencies": ["@remocn/stop-motion"],
+ "files": [
+ {
+ "path": "registry/remocn/ink-arrow/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/ink-arrow.tsx"
+ }
+ ],
+ "type": "registry:component"
+ },
{
"name": "stop-motion",
"title": "Stop Motion Clock",
diff --git a/registry/__index__.tsx b/registry/__index__.tsx
index 6f5c28d7..94b7477c 100644
--- a/registry/__index__.tsx
+++ b/registry/__index__.tsx
@@ -26,6 +26,7 @@ import { grainDissolveConfig } from "@/registry/remocn/grain-dissolve/config";
import { handwriteConfig } from "@/registry/remocn/handwrite/config";
import { infiniteBentoPanConfig } from "@/registry/remocn/infinite-bento-pan/config";
import { infiniteMarqueeConfig } from "@/registry/remocn/infinite-marquee/config";
+import { inkArrowConfig } from "@/registry/remocn/ink-arrow/config";
import { inkUnderlineConfig } from "@/registry/remocn/ink-underline/config";
import { inlineHighlightConfig } from "@/registry/remocn/inline-highlight/config";
import { kineticCenterBuildConfig } from "@/registry/remocn/kinetic-center-build/config";
@@ -1539,6 +1540,13 @@ const registry: Record<string, RegistryEntry> = {
})),
config: paperWobbleConfig,
},
+ "ink-arrow": {
+ load: () =>
+ import("@/components/docs/examples/ink-arrow-example").then((m) => ({
+ default: m.InkArrowExampleScene,
+ })),
+ config: inkArrowConfig,
+ },
backdrop: {
load: () =>
import("@/components/docs/examples/backdrop-demo").then((m) => ({
diff --git a/registry/remocn/ink-arrow/__tests__/ink-arrow.test.ts b/registry/remocn/ink-arrow/__tests__/ink-arrow.test.ts
new file mode 100644
index 00000000..6a06b5f9
--- /dev/null
+++ b/registry/remocn/ink-arrow/__tests__/ink-arrow.test.ts
@@ -0,0 +1,135 @@
+import { describe, expect, it } from "bun:test";
+
+import { inkArrowControls, inkArrowHead, inkArrowViewport } from "../index";
+
+const FROM = { x: 0, y: 0 };
+const TO = { x: 100, y: 0 };
+
+const cross = (
+ a: { x: number; y: number },
+ b: { x: number; y: number },
+): number => a.x * b.y - a.y * b.x;
+
+const sideOf = (point: { x: number; y: number }) =>
+ Math.sign(cross({ x: TO.x - FROM.x, y: TO.y - FROM.y }, point));
+
+describe("inkArrowControls", () => {
+ it("is deterministic for identical inputs", () => {
+ expect(inkArrowControls(FROM, TO, 0.35, "arrow")).toEqual(
+ inkArrowControls(FROM, TO, 0.35, "arrow"),
+ );
+ });
+
+ it("differs across seeds", () => {
+ expect(inkArrowControls(FROM, TO, 0.35, "arrow")).not.toEqual(
+ inkArrowControls(FROM, TO, 0.35, "other"),
+ );
+ });
+
+ it("places the controls at 30% and 70% along the segment", () => {
+ const { c1, c2 } = inkArrowControls(FROM, TO, 0, "arrow");
+ expect(c1.x).toBeGreaterThan(20);
+ expect(c1.x).toBeLessThan(40);
+ expect(c2.x).toBeGreaterThan(60);
+ expect(c2.x).toBeLessThan(80);
+ });
+
+ it("bows to opposite sides for opposite curvature signs", () => {
+ const positive = inkArrowControls(FROM, TO, 0.5, "arrow");
+ const negative = inkArrowControls(FROM, TO, -0.5, "arrow");
+ expect(sideOf(positive.c1)).toBe(1);
+ expect(sideOf(negative.c1)).toBe(-1);
+ expect(sideOf(positive.c2)).toBe(-sideOf(negative.c2));
+ });
+
+ it("keeps the controls on the segment when curvature is 0", () => {
+ const { c1, c2 } = inkArrowControls(FROM, TO, 0, "arrow");
+ const maxWobble = 100 * 0.06;
+ expect(Math.abs(c1.y)).toBeLessThanOrEqual(maxWobble);
+ expect(Math.abs(c2.y)).toBeLessThanOrEqual(maxWobble);
+ });
+
+ it("scales the bow linearly with distance", () => {
+ const near = inkArrowControls(FROM, { x: 100, y: 0 }, 0.5, "arrow");
+ const far = inkArrowControls(FROM, { x: 400, y: 0 }, 0.5, "arrow");
+ expect(far.c1.y).toBeCloseTo(4 * near.c1.y, 6);
+ expect(far.c2.y).toBeCloseTo(4 * near.c2.y, 6);
+ });
+
+ it("survives a zero-length segment", () => {
+ const { c1 } = inkArrowControls(FROM, FROM, 0.35, "arrow");
+ expect(Number.isFinite(c1.x)).toBe(true);
+ expect(Number.isFinite(c1.y)).toBe(true);
+ });
+});
+
+describe("inkArrowViewport", () => {
+ it("stays positive for negative coordinates", () => {
+ const { width, height } = inkArrowViewport(
+ { x: -500, y: -500 },
+ { x: -400, y: -400 },
+ 0.35,
+ 24,
+ 3,
+ );
+ expect(width).toBeGreaterThan(0);
+ expect(height).toBeGreaterThan(0);
+ });
+
+ it("stays positive when `to` sits before `from`", () => {
+ const { width, height } = inkArrowViewport(
+ { x: 300, y: 200 },
+ { x: 0, y: 0 },
+ 0.35,
+ 24,
+ 3,
+ );
+ expect(width).toBeGreaterThan(300);
+ expect(height).toBeGreaterThan(200);
+ });
+
+ it("leaves room for the bow, the head and the pen width", () => {
+ const { width } = inkArrowViewport(FROM, TO, 0.5, 24, 3);
+ expect(width).toBeCloseTo(100 + 24 + 50 + 3, 6);
+ });
+});
+
+describe("inkArrowHead", () => {
+ const c2 = { x: 60, y: 0 };
+
+ it("anchors both arms headSize away from the tip", () => {
+ const { left, right } = inkArrowHead(c2, TO, 24);
+ expect(Math.hypot(left.x - TO.x, left.y - TO.y)).toBeCloseTo(24, 6);
+ expect(Math.hypot(right.x - TO.x, right.y - TO.y)).toBeCloseTo(24, 6);
+ });
+
+ it("puts both arms behind the tip along the end tangent", () => {
+ const { left, right } = inkArrowHead(c2, TO, 24);
+ const tangent = { x: TO.x - c2.x, y: TO.y - c2.y };
+ for (const arm of [left, right]) {
+ const back = { x: arm.x - TO.x, y: arm.y - TO.y };
+ expect(back.x * tangent.x + back.y * tangent.y).toBeLessThan(0);
+ }
+ });
+
+ it("opens the arms to opposite sides of the tangent", () => {
+ const { left, right } = inkArrowHead(c2, TO, 24);
+ expect(Math.sign(left.y - TO.y)).toBe(-Math.sign(right.y - TO.y));
+ });
+
+ it("scales with headSize", () => {
+ const small = inkArrowHead(c2, TO, 12);
+ const large = inkArrowHead(c2, TO, 24);
+ expect(Math.hypot(large.left.x - TO.x, large.left.y - TO.y)).toBeCloseTo(
+ 2 * Math.hypot(small.left.x - TO.x, small.left.y - TO.y),
+ 6,
+ );
+ });
+
+ it("follows the tangent direction, not the axis", () => {
+ const vertical = inkArrowHead({ x: 100, y: -60 }, TO, 24);
+ for (const arm of [vertical.left, vertical.right]) {
+ expect(arm.y).toBeLessThan(TO.y);
+ }
+ });
+});
diff --git a/registry/remocn/ink-arrow/config.ts b/registry/remocn/ink-arrow/config.ts
new file mode 100644
index 00000000..42804234
--- /dev/null
+++ b/registry/remocn/ink-arrow/config.ts
@@ -0,0 +1,65 @@
+import { inkArrowExampleCode } from "@/components/docs/examples/ink-arrow-example";
+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";
+
+export const inkArrowConfig: ComponentConfig = {
+ componentName: "InkArrow",
+ importPath: "@/components/remocn/ink-arrow",
+ controls: {
+ curvature: {
+ type: "number",
+ default: 0.35,
+ min: -1,
+ max: 1,
+ step: 0.05,
+ label: "Curvature",
+ },
+ strokeWidth: {
+ type: "number",
+ default: 3,
+ min: 1,
+ max: 10,
+ step: 1,
+ label: "Stroke width",
+ },
+ headSize: {
+ type: "number",
+ default: 24,
+ min: 8,
+ max: 48,
+ step: 1,
+ label: "Head size",
+ },
+ drawDur: {
+ type: "number",
+ default: 36,
+ min: 12,
+ max: 90,
+ step: 1,
+ label: "Draw frames",
+ },
+ headDur: {
+ type: "number",
+ default: 12,
+ min: 4,
+ max: 48,
+ step: 1,
+ label: "Head frames",
+ },
+ color: { type: "color", default: "#26242c", label: "Ink color" },
+ seed: { type: "text", default: "arrow", label: "Seed" },
+ step: {
+ type: "number",
+ default: 3,
+ min: 1,
+ max: 6,
+ step: 1,
+ label: "Frames / pose",
+ },
+ },
+ snippet: inkArrowExampleCode,
+ durationInFrames: 150,
+ fps: FPS,
+ compositionWidth: W,
+ compositionHeight: H,
+ previewBackdrop: { type: "color", value: "#f1eee7" },
+};
diff --git a/registry/remocn/ink-arrow/index.tsx b/registry/remocn/ink-arrow/index.tsx
new file mode 100644
index 00000000..cf187b01
--- /dev/null
+++ b/registry/remocn/ink-arrow/index.tsx
@@ -0,0 +1,174 @@
+"use client";
+
+import { useCurrentFrame } from "remotion";
+import { DEFAULT_STEP, hashRange, steppedRamp } from "@/lib/remocn/stop-motion";
+
+const easeOutCubic = (t: number) => 1 - (1 - t) ** 3;
+
+const HEAD_ANGLE = 0.6;
+
+export type InkArrowPoint = { x: number; y: number };
+
+export function inkArrowControls(
+ from: InkArrowPoint,
+ to: InkArrowPoint,
+ curvature: number,
+ seed: string,
+): { c1: InkArrowPoint; c2: InkArrowPoint } {
+ const dx = to.x - from.x;
+ const dy = to.y - from.y;
+ const distance = Math.hypot(dx, dy) || 1;
+ const normalX = -dy / distance;
+ const normalY = dx / distance;
+ const bow = curvature * distance;
+ const wobble = distance * 0.06;
+
+ const at = (t: number, key: string): InkArrowPoint => ({
+ x:
+ from.x +
+ dx * t +
+ normalX * bow +
+ hashRange(`${seed}:${key}:x`, -wobble, wobble),
+ y:
+ from.y +
+ dy * t +
+ normalY * bow +
+ hashRange(`${seed}:${key}:y`, -wobble, wobble),
+ });
+
+ return { c1: at(0.3, "c1"), c2: at(0.7, "c2") };
+}
+
+export function inkArrowHead(
+ c2: InkArrowPoint,
+ to: InkArrowPoint,
+ headSize: number,
+): { left: InkArrowPoint; right: InkArrowPoint } {
+ const dx = to.x - c2.x;
+ const dy = to.y - c2.y;
+ const length = Math.hypot(dx, dy) || 1;
+ const backX = -dx / length;
+ const backY = -dy / length;
+
+ const arm = (angle: number): InkArrowPoint => ({
+ x: to.x + headSize * (backX * Math.cos(angle) - backY * Math.sin(angle)),
+ y: to.y + headSize * (backX * Math.sin(angle) + backY * Math.cos(angle)),
+ });
+
+ return { left: arm(HEAD_ANGLE), right: arm(-HEAD_ANGLE) };
+}
+
+export function inkArrowViewport(
+ from: InkArrowPoint,
+ to: InkArrowPoint,
+ curvature: number,
+ headSize: number,
+ strokeWidth: number,
+): { width: number; height: number } {
+ const distance = Math.hypot(to.x - from.x, to.y - from.y);
+ const margin = headSize + Math.abs(curvature) * distance + strokeWidth;
+ return {
+ width: Math.max(margin, Math.max(from.x, to.x) + margin),
+ height: Math.max(margin, Math.max(from.y, to.y) + margin),
+ };
+}
+
+export interface InkArrowProps {
+ from: InkArrowPoint;
+ to: InkArrowPoint;
+ curvature?: number;
+ color?: string;
+ strokeWidth?: number;
+ delay?: number;
+ drawDur?: number;
+ headSize?: number;
+ headDur?: number;
+ seed?: string;
+ step?: number;
+}
+
+export function InkArrow({
+ from,
+ to,
+ curvature = 0.35,
+ color = "#26242c",
+ strokeWidth = 3,
+ delay = 0,
+ drawDur = 36,
+ headSize = 24,
+ headDur,
+ seed = "arrow",
+ step = DEFAULT_STEP,
+}: InkArrowProps) {
+ const frame = useCurrentFrame();
+ const progress = steppedRamp(frame, delay, delay + drawDur, {
+ ease: easeOutCubic,
+ step,
+ });
+ const { c1, c2 } = inkArrowControls(from, to, curvature, seed);
+ const head = inkArrowHead(c2, to, headSize);
+
+ const headFrames = headDur ?? step * 4;
+ const headStart = delay + drawDur;
+ const headMid = headStart + headFrames / 2;
+ const leftArm = steppedRamp(frame, headStart, headMid, {
+ ease: easeOutCubic,
+ step,
+ });
+ const rightArm = steppedRamp(frame, headMid, headStart + headFrames, {
+ ease: easeOutCubic,
+ step,
+ });
+
+ const { width, height } = inkArrowViewport(
+ from,
+ to,
+ curvature,
+ headSize,
+ strokeWidth,
+ );
+
+ return (
+ <svg
+ width={width}
+ height={height}
+ viewBox={`0 0 ${width} ${height}`}
+ style={{
+ display: "block",
+ overflow: "visible",
+ opacity: progress > 0 ? 1 : 0,
+ }}
+ >
+ <path
+ d={`M ${from.x} ${from.y} C ${c1.x} ${c1.y}, ${c2.x} ${c2.y}, ${to.x} ${to.y}`}
+ stroke={color}
+ strokeWidth={strokeWidth}
+ strokeLinecap="round"
+ fill="none"
+ pathLength={1}
+ strokeDasharray={1}
+ strokeDashoffset={1 - progress}
+ />
+ <path
+ d={`M ${to.x} ${to.y} L ${head.left.x} ${head.left.y}`}
+ stroke={color}
+ strokeWidth={strokeWidth}
+ strokeLinecap="round"
+ fill="none"
+ pathLength={1}
+ strokeDasharray={1}
+ strokeDashoffset={1 - leftArm}
+ />
+ <path
+ d={`M ${to.x} ${to.y} L ${head.right.x} ${head.right.y}`}
+ stroke={color}
+ strokeWidth={strokeWidth}
+ strokeLinecap="round"
+ fill="none"
+ pathLength={1}
+ strokeDasharray={1}
+ strokeDashoffset={1 - rightArm}
+ />
+ </svg>
+ );
+}
diff --git a/registry/remocn/registry.json b/registry/remocn/registry.json
index e2ccbca3..e7990f11 100644
--- a/registry/remocn/registry.json
+++ b/registry/remocn/registry.json
@@ -1328,6 +1328,21 @@
}
]
},
+ {
+ "name": "ink-arrow",
+ "type": "registry:component",
+ "title": "Ink Arrow",
+ "description": "A hand-drawn arrow that draws itself from one point to another in stop-motion poses, with the head popping on the final pose.",
+ "dependencies": ["remotion"],
+ "registryDependencies": ["@remocn/stop-motion"],
+ "files": [
+ {
+ "path": "ink-arrow/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/ink-arrow.tsx"
+ }
+ ]
+ },
{
"name": "stop-motion",
"type": "registry:lib",