Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
feat: added handwrite
kapishdima7321254716f7
diff --git a/content/docs/components.mdx b/content/docs/components.mdxindex ca9dcc3e..3c8a1a0d 100644--- a/content/docs/components.mdx+++ b/content/docs/components.mdx@@ -58,6 +58,12 @@ Text effects, reveals, and kinetic type.status: "stable",href: "/docs/typography/top-down-letters",},+ {+ name: "Handwrite",+ description: "Letters laid down one pose at a time, each with its own slant and baseline wobble",+ status: "stable",+ href: "/docs/typography/handwrite",+ },{name: "SpringScaleIn",description: "Words pop in with a soft overshoot scale, like a spring settling",diff --git a/content/docs/typography/handwrite.mdx b/content/docs/typography/handwrite.mdxnew file mode 100644index 00000000..da89e946--- /dev/null+++ b/content/docs/typography/handwrite.mdx@@ -0,0 +1,124 @@+---+title: Handwrite+description: Handwritten text laid down letter by letter on a quantized stop-motion clock+---++<ComponentPreview name="handwrite" />++## Installation++<InstallBlock name="handwrite" />++## Usage++```tsx+// src/Root.tsx+import { AbsoluteFill, Composition } from "remotion";+import { Handwrite } from "@/components/remocn/handwrite";++const HandwriteScene = () => (+ <AbsoluteFill style={{ background: "#f1eee7" }}>+ <Handwrite text="Made by hand" fontSize={72} />+ </AbsoluteFill>+);++export const RemotionRoot = () => (+ <Composition+ id="Handwrite"+ component={HandwriteScene}+ durationInFrames={120}+ fps={30}+ width={1280}+ height={720}+ />+);+```++The component is transparent — put the paper colour on the layer behind it.++`handwriteDuration` returns how many frames a string needs, so a `<Sequence>` can+be sized to the writing instead of guessed:++```tsx+import { Sequence } from "remotion";+import { Handwrite, handwriteDuration } from "@/components/remocn/handwrite";++const title = "Made by hand";+const subtitle = "one pose at a time";++const Titles = () => (+ <>+ <Sequence durationInFrames={handwriteDuration(title)}>+ <Handwrite text={title} fontSize={72} />+ </Sequence>+ <Sequence from={handwriteDuration(title)}>+ <Handwrite text={subtitle} fontSize={44} />+ </Sequence>+ </>+);+```++Letters arrive on the stop-motion clock, so `step` is the tempo control: `3`+frames per pose is ten poses a second at 30fps. Raise it for a slower, more+deliberate hand. The component holds still between poses — wrap it in+`paper-wobble` if the whole sheet should breathe.++## Props++<PropsTable+ rows={[+ {+ name: "text",+ type: "string",+ required: true,+ description: "The text to write out; newlines are honoured",+ },+ {+ name: "fontSize",+ type: "number",+ default: "54",+ description: "Font size in pixels",+ },+ {+ name: "color",+ type: "string",+ default: "\"#26242c\"",+ description: "Ink colour (any valid CSS color)",+ },+ {+ name: "delay",+ type: "number",+ default: "0",+ description: "Frames on the local clock before writing begins",+ },+ {+ name: "perStep",+ type: "number",+ default: "1.6",+ description: "Letters laid down per stop-motion pose",+ },+ {+ name: "weight",+ type: "400 | 500 | 600 | 700",+ default: "600",+ description: "Pen weight",+ },+ {+ name: "align",+ type: "\"left\" | \"center\"",+ default: "\"center\"",+ description: "Horizontal alignment of the written block",+ },+ {+ name: "fontFamily",+ type: "string",+ description: "Overrides the bundled Caveat family; falls back to cursive",+ },+ {+ name: "step",+ type: "number",+ default: "3",+ description: "Frames per stop-motion pose — the tempo control",+ },+ ]}+/>diff --git a/content/docs/typography/meta.json b/content/docs/typography/meta.jsonindex 5db938f1..c35629c7 100644--- a/content/docs/typography/meta.json+++ b/content/docs/typography/meta.json@@ -27,6 +27,7 @@"marker-highlight","shimmer-sweep","typewriter",+ "handwrite","slot-machine-roll","number-wheel","rolling-number",diff --git a/registry-artifacts/handwrite.json b/registry-artifacts/handwrite.jsonnew file mode 100644index 00000000..6c22f590--- /dev/null+++ b/registry-artifacts/handwrite.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "handwrite",+ "title": "Handwrite",+ "description": "Handwritten text laid down letter by letter on a quantized stop-motion clock, each glyph keeping its own slant and baseline wobble.",+ "dependencies": ["remotion", "@remotion/google-fonts"],+ "registryDependencies": ["@remocn/stop-motion"],+ "files": [+ {+ "path": "registry/remocn/handwrite/index.tsx",+ "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/Caveat\";\nimport { useCurrentFrame } from \"remotion\";\nimport { DEFAULT_STEP, hashRange, qf, qstep } from \"@/lib/remocn/stop-motion\";\n\nconst { fontFamily: HAND_FAMILY } = loadFont(\"normal\", {\n subsets: [\"latin\"],\n weights: [\"400\", \"500\", \"600\", \"700\"],\n});\n\nexport interface HandwriteProps {\n text: string;\n fontSize?: number;\n color?: string;\n delay?: number;\n perStep?: number;\n weight?: 400 | 500 | 600 | 700;\n align?: \"left\" | \"center\";\n fontFamily?: string;\n step?: number;\n}\n\nexport function Handwrite({\n text,\n fontSize = 54,\n color = \"#26242c\",\n delay = 0,\n perStep = 1.6,\n weight = 600,\n align = \"center\",\n fontFamily = HAND_FAMILY,\n step = DEFAULT_STEP,\n}: HandwriteProps) {\n const frame = useCurrentFrame();\n const steps = Math.max(0, qstep(Math.max(0, qf(frame, step) - delay), step));\n const shown = Math.floor(steps * perStep);\n const chars = Array.from(text);\n const freshFrom = shown - Math.ceil(perStep);\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: align === \"center\" ? \"center\" : \"flex-start\",\n background: \"transparent\",\n }}\n >\n <span\n style={{\n display: \"inline-block\",\n fontFamily: `${fontFamily}, cursive`,\n fontWeight: weight,\n fontSize,\n lineHeight: 1.15,\n color,\n whiteSpace: \"pre-wrap\",\n textAlign: align,\n }}\n >\n {chars.map((char, i) => {\n const visible = i < shown;\n const slant = hashRange(`hw:${text}:${i}:r`, -3.2, 3.2);\n const dy = hashRange(`hw:${text}:${i}:y`, -1.8, 1.8);\n const fresh = visible && i >= freshFrom;\n return (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n whiteSpace: \"pre\",\n opacity: visible ? 1 : 0,\n transform: visible\n ? `translateY(${dy}px) rotate(${slant}deg) scale(${fresh ? 1.06 : 1})`\n : undefined,\n }}\n >\n {char}\n </span>\n );\n })}\n </span>\n </div>\n );\n}\n\nexport function handwriteDuration(\n text: string,\n options?: { perStep?: number; step?: number },\n): number {\n const perStep = options?.perStep ?? 1.6;\n const step = options?.step ?? DEFAULT_STEP;\n return Math.ceil(Array.from(text).length / perStep) * step + step;\n}\n",+ "type": "registry:component",+ "target": "components/remocn/handwrite.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/registry.json b/registry-artifacts/registry.jsonindex 5742d111..0f4e5140 100644--- a/registry-artifacts/registry.json+++ b/registry-artifacts/registry.json@@ -1283,6 +1283,21 @@],"type": "registry:component"},+ {+ "name": "handwrite",+ "title": "Handwrite",+ "description": "Handwritten text laid down letter by letter on a quantized stop-motion clock, each glyph keeping its own slant and baseline wobble.",+ "dependencies": ["remotion", "@remotion/google-fonts"],+ "registryDependencies": ["@remocn/stop-motion"],+ "files": [+ {+ "path": "registry/remocn/handwrite/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/handwrite.tsx"+ }+ ],+ "type": "registry:component"+ },{"name": "stop-motion","title": "Stop Motion Clock",diff --git a/registry/__index__.tsx b/registry/__index__.tsxindex ab2331ae..bd2613d2 100644--- a/registry/__index__.tsx+++ b/registry/__index__.tsx@@ -23,6 +23,7 @@ import { githubStarsConfig } from "@/registry/remocn/github-stars/config";import { glassCodeBlockConfig } from "@/registry/remocn/glass-code-block/config";import { glassCodeWalkConfig } from "@/registry/remocn/glass-code-walk/config";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 { inlineHighlightConfig } from "@/registry/remocn/inline-highlight/config";@@ -360,6 +361,13 @@ const registry: Record<string, RegistryEntry> = {})),config: typewriterConfig,},+ handwrite: {+ load: () =>+ import("@/registry/remocn/handwrite").then((m) => ({+ default: m.Handwrite,+ })),+ config: handwriteConfig,+ },"inline-highlight": {load: () =>import("@/registry/remocn/inline-highlight").then((m) => ({diff --git a/registry/remocn/handwrite/__tests__/handwrite.test.ts b/registry/remocn/handwrite/__tests__/handwrite.test.tsnew file mode 100644index 00000000..9c0b7889--- /dev/null+++ b/registry/remocn/handwrite/__tests__/handwrite.test.ts@@ -0,0 +1,59 @@+import { describe, expect, it } from "bun:test";++import { qf, qstep } from "@/lib/remocn/stop-motion";+import { handwriteDuration } from "../index";++const shownAt = (frame: number, { perStep = 1.6, step = 3, delay = 0 } = {}) =>+ Math.floor(+ Math.max(0, qstep(Math.max(0, qf(frame, step) - delay), step)) * perStep,+ );++describe("handwriteDuration", () => {+ it("computes exact frame math with the defaults", () => {+ expect(handwriteDuration("hello")).toBe(15);+ expect(handwriteDuration("hi")).toBe(9);+ expect(handwriteDuration("")).toBe(3);+ });++ it("ends one step after the last letter lands", () => {+ for (const text of ["hello", "a", "Made by hand"]) {+ for (const opts of [{}, { perStep: 1 }, { perStep: 3, step: 5 }]) {+ const step = opts.step ?? 3;+ const total = Array.from(text).length;+ const duration = handwriteDuration(text, opts);+ expect(shownAt(duration - step, opts)).toBeGreaterThanOrEqual(total);+ expect(shownAt(duration - step - 1, opts)).toBeLessThan(total);+ }+ }+ });++ it("shortens as perStep grows", () => {+ expect(handwriteDuration("hello", { perStep: 1 })).toBe(18);+ expect(handwriteDuration("hello", { perStep: 5 })).toBe(6);+ expect(handwriteDuration("hello", { perStep: 4 })).toBe(9);+ });++ it("scales with step", () => {+ expect(handwriteDuration("hello", { step: 6 })).toBe(30);+ expect(handwriteDuration("hello", { step: 1 })).toBe(5);+ expect(handwriteDuration("hello", { perStep: 1, step: 2 })).toBe(12);+ });++ it("counts unicode glyphs, not UTF-16 code units", () => {+ expect("👋".length).toBe(2);+ expect(handwriteDuration("👋", { perStep: 1 })).toBe(6);+ expect(handwriteDuration("👋👋", { perStep: 1 })).toBe(9);+ expect(handwriteDuration("héllo", { perStep: 1 })).toBe(18);+ });++ it("counts newlines and spaces as glyphs", () => {+ expect(handwriteDuration("a b", { perStep: 1 })).toBe(12);+ expect(handwriteDuration("a\nb", { perStep: 1 })).toBe(12);+ });++ it("is deterministic", () => {+ expect(handwriteDuration("Made by hand")).toBe(+ handwriteDuration("Made by hand"),+ );+ });+});diff --git a/registry/remocn/handwrite/config.ts b/registry/remocn/handwrite/config.tsnew file mode 100644index 00000000..3583c1a6--- /dev/null+++ b/registry/remocn/handwrite/config.ts@@ -0,0 +1,57 @@+import {+ type ComponentConfig,+ FONT_WEIGHT_OPTIONS,+ FPS,+ H,+ W,+} from "@/lib/customizer-config";++export const handwriteConfig: ComponentConfig = {+ componentName: "Handwrite",+ importPath: "@/components/remocn/handwrite",+ controls: {+ text: { type: "text", default: "Made by hand", label: "Text" },+ fontSize: {+ type: "number",+ default: 72,+ min: 24,+ max: 120,+ step: 1,+ label: "Font size",+ },+ perStep: {+ type: "number",+ default: 1.6,+ min: 0.5,+ max: 4,+ step: 0.1,+ label: "Letters / pose",+ },+ weight: {+ type: "select",+ default: "600",+ options: FONT_WEIGHT_OPTIONS,+ label: "Font weight",+ },+ color: { type: "color", default: "#26242c", label: "Color" },+ align: {+ type: "select",+ default: "center",+ options: ["center", "left"],+ label: "Align",+ },+ step: {+ type: "number",+ default: 3,+ min: 1,+ max: 6,+ step: 1,+ label: "Frames / pose",+ },+ },+ durationInFrames: 120,+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#f1eee7" },+};diff --git a/registry/remocn/handwrite/index.tsx b/registry/remocn/handwrite/index.tsxnew file mode 100644index 00000000..f2fb68fc--- /dev/null+++ b/registry/remocn/handwrite/index.tsx@@ -0,0 +1,97 @@+"use client";++import { loadFont } from "@remotion/google-fonts/Caveat";+import { useCurrentFrame } from "remotion";+import { DEFAULT_STEP, hashRange, qf, qstep } from "@/lib/remocn/stop-motion";++const { fontFamily: HAND_FAMILY } = loadFont("normal", {+ subsets: ["latin"],+ weights: ["400", "500", "600", "700"],+});++export interface HandwriteProps {+ text: string;+ fontSize?: number;+ color?: string;+ delay?: number;+ perStep?: number;+ weight?: 400 | 500 | 600 | 700;+ align?: "left" | "center";+ fontFamily?: string;+ step?: number;+}++export function Handwrite({+ text,+ fontSize = 54,+ color = "#26242c",+ delay = 0,+ perStep = 1.6,+ weight = 600,+ align = "center",+ fontFamily = HAND_FAMILY,+ step = DEFAULT_STEP,+}: HandwriteProps) {+ const frame = useCurrentFrame();+ const steps = Math.max(0, qstep(Math.max(0, qf(frame, step) - delay), step));+ const shown = Math.floor(steps * perStep);+ const chars = Array.from(text);+ const freshFrom = shown - Math.ceil(perStep);++ return (+ <div+ style={{+ position: "absolute",+ inset: 0,+ display: "flex",+ alignItems: "center",+ justifyContent: align === "center" ? "center" : "flex-start",+ background: "transparent",+ }}+ >+ <span+ style={{+ display: "inline-block",+ fontFamily: `${fontFamily}, cursive`,+ fontWeight: weight,+ fontSize,+ lineHeight: 1.15,+ color,+ whiteSpace: "pre-wrap",+ textAlign: align,+ }}+ >+ {chars.map((char, i) => {+ const visible = i < shown;+ const slant = hashRange(`hw:${text}:${i}:r`, -3.2, 3.2);+ const dy = hashRange(`hw:${text}:${i}:y`, -1.8, 1.8);+ const fresh = visible && i >= freshFrom;+ return (+ <span+ key={i}+ style={{+ display: "inline-block",+ whiteSpace: "pre",+ opacity: visible ? 1 : 0,+ transform: visible+ ? `translateY(${dy}px) rotate(${slant}deg) scale(${fresh ? 1.06 : 1})`+ : undefined,+ }}+ >+ {char}+ </span>+ );+ })}+ </span>+ </div>+ );+}++export function handwriteDuration(+ text: string,+ options?: { perStep?: number; step?: number },+): number {+ const perStep = options?.perStep ?? 1.6;+ const step = options?.step ?? DEFAULT_STEP;+ return Math.ceil(Array.from(text).length / perStep) * step + step;+}diff --git a/registry/remocn/registry.json b/registry/remocn/registry.jsonindex 817dec6a..3453f27c 100644--- a/registry/remocn/registry.json+++ b/registry/remocn/registry.json@@ -1283,6 +1283,21 @@}]},+ {+ "name": "handwrite",+ "type": "registry:component",+ "title": "Handwrite",+ "description": "Handwritten text laid down letter by letter on a quantized stop-motion clock, each glyph keeping its own slant and baseline wobble.",+ "dependencies": ["remotion", "@remotion/google-fonts"],+ "registryDependencies": ["@remocn/stop-motion"],+ "files": [+ {+ "path": "handwrite/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/handwrite.tsx"+ }+ ]+ },{"name": "stop-motion","type": "registry:lib",