Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
feat: hand count
kapishdima0b8a8e08dcfd
diff --git a/content/docs/components.mdx b/content/docs/components.mdxindex 301db625..9a3e0b75 100644--- a/content/docs/components.mdx+++ b/content/docs/components.mdx@@ -162,6 +162,12 @@ Text effects, reveals, and kinetic type.status: "stable",href: "/docs/typography/typewriter",},+ {+ name: "HandCount",+ description: "A number that counts up in stop-motion poses, rewritten by hand at every pose",+ status: "stable",+ href: "/docs/typography/hand-count",+ },{name: "SlotMachineRoll",description: "Numbers and characters roll into place like a casino reel",diff --git a/content/docs/typography/hand-count.mdx b/content/docs/typography/hand-count.mdxnew file mode 100644index 00000000..9464d838--- /dev/null+++ b/content/docs/typography/hand-count.mdx@@ -0,0 +1,205 @@+---+title: Hand Count+description: A number that counts up in stop-motion poses, rewritten by hand at every pose+---++<ComponentPreview name="hand-count" />++## Installation++<InstallBlock name="hand-count" />++## Usage++Every pose the value advances and the digits are **written again** — same+number, different hand. That re-drawing is the whole illusion, and it is what+separates this from every other number in the registry: `rolling-number` and+`number-wheel` glide a mechanical typeface, which is right for a product UI and+wrong for a paper scene.++The component fills its parent with `position: absolute; inset: 0`, so give it+a frame and it centres itself inside it.++```tsx+// src/Root.tsx+import { AbsoluteFill, Composition, Sequence } from "remotion";+import { HandCount, handCountDuration } from "@/components/remocn/hand-count";++const COUNT_AT = 12;+const COUNT_FOR = 14;+const COUNT_ENDS = handCountDuration({+ delay: COUNT_AT,+ durationSteps: COUNT_FOR,+});++const PricingScene = () => (+ <AbsoluteFill style={{ background: "#f1eee7" }}>+ <Sequence durationInFrames={COUNT_ENDS + 30}>+ <HandCount+ to={19}+ delay={COUNT_AT}+ durationSteps={COUNT_FOR}+ prefix="$"+ decimals={2}+ suffix="/mo"+ />+ </Sequence>+ </AbsoluteFill>+);++export const RemotionRoot = () => (+ <Composition+ id="HandCount"+ component={PricingScene}+ durationInFrames={COUNT_ENDS + 30}+ fps={30}+ width={1280}+ height={720}+ />+);+```++### A year-in-review stat++The affixes are written in the same hand as the digits, so a unit reads as part+of the number rather than a label stuck beside it.++```tsx+<div style={{ position: "relative", width: 720, height: 220 }}>+ <HandCount to={1284} suffix=" commits" durationSteps={18} fontSize={120} />+</div>+```++### Sizing the scene++`handCountDuration` returns the frame the number actually **settles** on, which+is not always `delay + durationSteps * step`. The stop-motion clock saturates on+the quantized frame, so an off-grid `delay` pushes the landing to the next pose+boundary — a `<Sequence>` sized by the naive sum can cut up to `step - 1` frames+before the number arrives.++```tsx+handCountDuration({ delay: 0, durationSteps: 12, step: 3 }); // 36+handCountDuration({ delay: 1, durationSteps: 12, step: 3 }); // 39, not 37+```++Keep `delay` a multiple of `step` and the two agree.++### Choosing the ease++`in-out` is the default and it is the one to keep for a headline number. It+opens on a barely-there move, does most of the counting through the middle, and+settles gently — so every pose in the run carries a visible digit change.++`out` front-loads the movement hard: at twelve poses it puts almost a quarter+of the count into the very first pose and leaves the last third of the run+barely moving. That is right when the number is a supporting detail arriving+under something else, and wrong when it is the thing being watched.++A literal spring is deliberately not on offer here. Springs start fast by+construction, which is the same problem as `out`, and the overshoot would show+a price climbing past its own figure before falling back to it.++### Landing and holding still++The value lands on `to` exactly — it never stops at 99.7 — and the jitter+freezes the moment it does. A headline number that keeps twitching for the rest+of the shot is a distraction, not a texture; ambient motion in this kit is+`paper-wobble`'s job.++## Props++<PropsTable+ rows={[+ {+ name: "to",+ type: "number",+ required: true,+ description: "Value the count lands on, exactly",+ },+ {+ name: "from",+ type: "number",+ default: "0",+ description: "Value it starts at; above `to` it counts down",+ },+ {+ name: "delay",+ type: "number",+ default: "0",+ description: "Local frame counting starts; keep it a multiple of step",+ },+ {+ name: "durationSteps",+ type: "number",+ default: "18",+ description: "Poses spent counting",+ },+ {+ name: "decimals",+ type: "number",+ default: "0",+ description: "Decimal places; 0 never renders a decimal point",+ },+ {+ name: "prefix",+ type: "string",+ default: "\"\"",+ description: "Written before the number in the same hand",+ },+ {+ name: "suffix",+ type: "string",+ default: "\"\"",+ description: "Written after the number in the same hand",+ },+ {+ name: "fontSize",+ type: "number",+ default: "96",+ description: "Size of the written number",+ },+ {+ name: "color",+ type: "string",+ default: "\"#26242c\"",+ description: "Ink colour",+ },+ {+ name: "weight",+ type: "400 | 500 | 600 | 700",+ default: "700",+ description: "Font weight",+ },+ {+ name: "ease",+ type: "\"in-out\" | \"out\" | \"linear\"",+ default: "\"in-out\"",+ description: "Shape of the count; `in-out` starts and settles gently, `out` front-loads the movement",+ },+ {+ name: "align",+ type: "\"left\" | \"center\"",+ default: "\"center\"",+ description: "Alignment inside the frame it fills",+ },+ {+ name: "fontFamily",+ type: "string",+ default: "Caveat",+ description: "Override the handwritten face",+ },+ {+ name: "seed",+ type: "string",+ default: "\"count\"",+ description: "Seed for the per-pose glyph jitter",+ },+ {+ name: "step",+ type: "number",+ default: "3",+ description: "Frames per stop-motion pose",+ },+ ]}+/>diff --git a/content/docs/typography/meta.json b/content/docs/typography/meta.jsonindex 0bce43cd..74af0a85 100644--- a/content/docs/typography/meta.json+++ b/content/docs/typography/meta.json@@ -29,6 +29,7 @@"shimmer-sweep","typewriter","handwrite",+ "hand-count","slot-machine-roll","number-wheel","rolling-number",diff --git a/registry-artifacts/hand-count.json b/registry-artifacts/hand-count.jsonnew file mode 100644index 00000000..99c00123--- /dev/null+++ b/registry-artifacts/hand-count.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "hand-count",+ "title": "Hand Count",+ "description": "A number that counts up in stop-motion poses, rewritten by hand at every pose and freezing still once it lands.",+ "dependencies": ["remotion", "@remotion/google-fonts"],+ "registryDependencies": ["@remocn/stop-motion"],+ "files": [+ {+ "path": "registry/remocn/hand-count/index.tsx",+ "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/Caveat\";\nimport { useCurrentFrame } from \"remotion\";\nimport {\n DEFAULT_STEP,\n hashRange,\n qstep,\n steppedRamp,\n} from \"@/lib/remocn/stop-motion\";\n\nconst { fontFamily: HAND_FAMILY } = loadFont(\"normal\", {\n subsets: [\"latin\"],\n weights: [\"400\", \"500\", \"600\", \"700\"],\n});\n\nconst easeOutCubic = (t: number) => 1 - (1 - t) ** 3;\n\nconst easeInOutCubic = (t: number) =>\n t < 0.5 ? 4 * t ** 3 : 1 - (-2 * t + 2) ** 3 / 2;\n\nconst DEFAULT_DURATION_STEPS = 18;\n\nexport type HandCountEase = \"in-out\" | \"out\" | \"linear\";\n\nconst EASES: Record<HandCountEase, (t: number) => number> = {\n \"in-out\": easeInOutCubic,\n out: easeOutCubic,\n linear: (t: number) => t,\n};\n\nexport type HandCountTiming = {\n delay?: number;\n durationSteps?: number;\n step?: number;\n};\n\nexport function handCountDuration(options?: HandCountTiming): number {\n const delay = options?.delay ?? 0;\n const durationSteps = options?.durationSteps ?? DEFAULT_DURATION_STEPS;\n const step = options?.step ?? DEFAULT_STEP;\n const end = delay + durationSteps * step;\n return Math.ceil(end / step) * step;\n}\n\nexport function handCountValue(\n args: HandCountTiming & {\n frame: number;\n to: number;\n from?: number;\n ease?: HandCountEase;\n },\n): number {\n const from = args.from ?? 0;\n const delay = args.delay ?? 0;\n const durationSteps = args.durationSteps ?? DEFAULT_DURATION_STEPS;\n const step = args.step ?? DEFAULT_STEP;\n const progress = steppedRamp(\n args.frame,\n delay,\n delay + durationSteps * step,\n {\n ease: EASES[args.ease ?? \"in-out\"],\n step,\n },\n );\n return from + (args.to - from) * progress;\n}\n\nexport function handCountText(\n value: number,\n options?: { decimals?: number; prefix?: string; suffix?: string },\n): string {\n return `${options?.prefix ?? \"\"}${value.toFixed(options?.decimals ?? 0)}${options?.suffix ?? \"\"}`;\n}\n\nexport function handCountPose(\n frame: number,\n options?: HandCountTiming,\n): number {\n const step = options?.step ?? DEFAULT_STEP;\n const settled = handCountDuration(options);\n return Math.min(qstep(Math.max(0, frame), step), qstep(settled, step));\n}\n\nexport function handCountJitter(\n args: HandCountTiming & { frame: number; index: number; seed?: string },\n): { rot: number; dy: number } {\n const seed = args.seed ?? \"count\";\n const pose = handCountPose(args.frame, args);\n return {\n rot: hashRange(`${seed}:${pose}:${args.index}:r`, -3.2, 3.2),\n dy: hashRange(`${seed}:${pose}:${args.index}:y`, -1.8, 1.8),\n };\n}\n\nexport interface HandCountProps {\n to: number;\n from?: number;\n delay?: number;\n durationSteps?: number;\n decimals?: number;\n prefix?: string;\n suffix?: string;\n fontSize?: number;\n color?: string;\n weight?: 400 | 500 | 600 | 700;\n ease?: HandCountEase;\n align?: \"left\" | \"center\";\n fontFamily?: string;\n seed?: string;\n step?: number;\n}\n\nexport function HandCount({\n to,\n from = 0,\n delay = 0,\n durationSteps = DEFAULT_DURATION_STEPS,\n decimals = 0,\n prefix = \"\",\n suffix = \"\",\n fontSize = 96,\n color = \"#26242c\",\n weight = 700,\n ease = \"in-out\",\n align = \"center\",\n fontFamily = HAND_FAMILY,\n seed = \"count\",\n step = DEFAULT_STEP,\n}: HandCountProps) {\n const frame = useCurrentFrame();\n const value = handCountValue({\n frame,\n to,\n from,\n delay,\n durationSteps,\n step,\n ease,\n });\n const chars = Array.from(handCountText(value, { decimals, prefix, suffix }));\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\",\n textAlign: align,\n }}\n >\n {chars.map((char, i) => {\n const { rot, dy } = handCountJitter({\n frame,\n index: i,\n seed,\n delay,\n durationSteps,\n step,\n });\n return (\n <span\n key={`${i}:${char}`}\n style={{\n display: \"inline-block\",\n whiteSpace: \"pre\",\n transform: `translateY(${dy}px) rotate(${rot}deg)`,\n }}\n >\n {char}\n </span>\n );\n })}\n </span>\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/hand-count.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry-artifacts/registry.json b/registry-artifacts/registry.jsonindex 171553f4..eee911d5 100644--- a/registry-artifacts/registry.json+++ b/registry-artifacts/registry.json@@ -1373,6 +1373,21 @@],"type": "registry:component"},+ {+ "name": "hand-count",+ "title": "Hand Count",+ "description": "A number that counts up in stop-motion poses, rewritten by hand at every pose and freezing still once it lands.",+ "dependencies": ["remotion", "@remotion/google-fonts"],+ "registryDependencies": ["@remocn/stop-motion"],+ "files": [+ {+ "path": "registry/remocn/hand-count/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/hand-count.tsx"+ }+ ],+ "type": "registry:component"+ },{"name": "brush","title": "Brush",diff --git a/registry/__index__.tsx b/registry/__index__.tsxindex c697bc4a..a8099011 100644--- a/registry/__index__.tsx+++ b/registry/__index__.tsx@@ -24,6 +24,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 { handCountConfig } from "@/registry/remocn/hand-count/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";@@ -369,6 +370,13 @@ const registry: Record<string, RegistryEntry> = {})),config: typewriterConfig,},+ "hand-count": {+ load: () =>+ import("@/registry/remocn/hand-count").then((m) => ({+ default: m.HandCount,+ })),+ config: handCountConfig,+ },handwrite: {load: () =>import("@/registry/remocn/handwrite").then((m) => ({diff --git a/registry/remocn/hand-count/__tests__/hand-count.test.ts b/registry/remocn/hand-count/__tests__/hand-count.test.tsnew file mode 100644index 00000000..e1ef4711--- /dev/null+++ b/registry/remocn/hand-count/__tests__/hand-count.test.ts@@ -0,0 +1,296 @@+import { describe, expect, it } from "bun:test";++import { handCountConfig } from "../config";+import {+ handCountDuration,+ handCountJitter,+ handCountPose,+ handCountText,+ handCountValue,+} from "../index";++const ON_GRID = { delay: 0, durationSteps: 12, step: 3 };+const OFF_GRID = { delay: 1, durationSteps: 12, step: 3 };+const EASES = ["in-out", "out", "linear"] as const;++const numberControl = (name: string) => {+ const control = handCountConfig.controls[name];+ if (control.type !== "number") {+ throw new Error(`${name} is not a number control`);+ }+ return control;+};++describe("handCountDuration", () => {+ it("equals the naive end when delay sits on the pose grid", () => {+ expect(handCountDuration(ON_GRID)).toBe(36);+ expect(handCountDuration({ delay: 9, durationSteps: 12, step: 3 })).toBe(+ 45,+ );+ });++ it("rounds up past the naive end when delay is off grid", () => {+ const naive = OFF_GRID.delay + OFF_GRID.durationSteps * OFF_GRID.step;+ expect(naive).toBe(37);+ expect(handCountDuration(OFF_GRID)).toBe(39);+ expect(handCountDuration(OFF_GRID)).toBeGreaterThan(naive);+ });++ it("rounds up rather than down, so a Sequence never cuts the landing", () => {+ for (let delay = 0; delay < 12; delay++) {+ const options = { delay, durationSteps: 12, step: 3 };+ const naive = delay + 36;+ const settled = handCountDuration(options);+ expect(settled).toBeGreaterThanOrEqual(naive);+ expect(settled % 3).toBe(0);+ expect(settled - naive).toBeLessThan(3);+ }+ });++ it("lands on the pose grid for every step in the control range", () => {+ const stepControl = numberControl("step");+ for (let step = stepControl.min; step <= stepControl.max; step++) {+ for (const delay of [0, 1, 5, 7]) {+ const settled = handCountDuration({ delay, durationSteps: 12, step });+ expect(settled % step).toBe(0);+ }+ }+ });+});++describe("handCountValue", () => {+ const at = (+ frame: number,+ options = ON_GRID,+ ease?: (typeof EASES)[number],+ ) => handCountValue({ frame, from: 0, to: 100, ...options, ease });++ it("holds at `from` up to and including the delay frame", () => {+ expect(at(0)).toBe(0);+ expect(+ handCountValue({ frame: 5, from: 20, to: 100, delay: 6, step: 3 }),+ ).toBe(20);+ expect(+ handCountValue({ frame: 6, from: 20, to: 100, delay: 6, step: 3 }),+ ).toBe(20);+ });++ it("never goes backwards", () => {+ let previous = -1;+ for (let frame = 0; frame <= 60; frame++) {+ const value = at(frame);+ expect(value).toBeGreaterThanOrEqual(previous);+ previous = value;+ }+ });++ it("holds constant for every frame inside one pose", () => {+ for (const base of [6, 15, 27]) {+ for (const offset of [0, 1, 2]) {+ expect(at(base + offset)).toBe(at(base));+ }+ }+ });++ it("lands exactly on `to` at handCountDuration, not at the naive end", () => {+ expect(at(handCountDuration(ON_GRID))).toBe(100);+ expect(at(handCountDuration(OFF_GRID), OFF_GRID)).toBe(100);+ });++ it("has NOT landed at the naive end when delay is off grid", () => {+ const naive = OFF_GRID.delay + OFF_GRID.durationSteps * OFF_GRID.step;+ expect(at(naive, OFF_GRID)).not.toBe(100);+ expect(at(naive, OFF_GRID, "linear")).toBeCloseTo((35 / 36) * 100, 6);+ expect(at(naive + 2, OFF_GRID)).toBe(100);+ });++ it("stays on `to` forever once it has landed", () => {+ for (const frame of [36, 60, 300]) {+ expect(at(frame)).toBe(100);+ }+ });++ it("agrees at both ends across eases and differs in the middle", () => {+ for (const ease of EASES) {+ expect(at(0, ON_GRID, ease)).toBe(0);+ expect(at(36, ON_GRID, ease)).toBe(100);+ }+ expect(at(15, ON_GRID, "out")).toBeGreaterThan(at(15, ON_GRID, "linear"));+ expect(at(15, ON_GRID, "in-out")).toBeLessThan(at(15, ON_GRID, "linear"));+ });++ it("opens on a small move under in-out, instead of dumping a quarter of the count into the first pose", () => {+ expect(at(3, ON_GRID, "out") / 100).toBeCloseTo(0.23, 2);+ expect(at(3, ON_GRID, "in-out") / 100).toBeLessThan(0.01);+ expect(at(3, ON_GRID, "in-out")).toBeGreaterThan(0);+ });++ it("keeps the tail alive under in-out, where out has already stopped moving", () => {+ const tailOf = (ease: "in-out" | "out") =>+ at(36, ON_GRID, ease) - at(24, ON_GRID, ease);+ expect(tailOf("out")).toBeLessThan(10);+ expect(tailOf("in-out")).toBeGreaterThan(tailOf("out"));+ });++ it("is symmetric under in-out, so the ramp up mirrors the settle", () => {+ for (const t of [3, 9, 15]) {+ const rise = at(t, ON_GRID, "in-out");+ const fall = 100 - at(36 - t, ON_GRID, "in-out");+ expect(rise).toBeCloseTo(fall, 6);+ }+ });++ it("advances on every counting pose under in-out, never stalling", () => {+ for (let pose = 1; pose <= 12; pose++) {+ expect(at(pose * 3, ON_GRID, "in-out")).toBeGreaterThan(+ at((pose - 1) * 3, ON_GRID, "in-out"),+ );+ }+ });++ it("counts down when `from` is above `to`", () => {+ const down = (frame: number) =>+ handCountValue({ frame, from: 100, to: 0, ...ON_GRID });+ expect(down(0)).toBe(100);+ expect(down(36)).toBe(0);+ expect(down(15)).toBeLessThan(100);+ });+});++describe("handCountText", () => {+ it("renders the requested decimal places", () => {+ expect(handCountText(12.3456, { decimals: 2 })).toBe("12.35");+ expect(handCountText(12.3456, { decimals: 1 })).toBe("12.3");+ });++ it("never emits a decimal point at decimals 0", () => {+ for (const value of [0, 7.4, 99.99, -3.2]) {+ expect(handCountText(value)).not.toContain(".");+ }+ expect(handCountText(99.99)).toBe("100");+ });++ it("wraps the value in the affixes", () => {+ expect(handCountText(19, { prefix: "$", suffix: "/mo" })).toBe("$19/mo");+ expect(handCountText(19, { prefix: "$", decimals: 2, suffix: "/mo" })).toBe(+ "$19.00/mo",+ );+ });++ it("keeps the sign on negative values", () => {+ expect(handCountText(-42)).toBe("-42");+ expect(handCountText(-42.5, { decimals: 1, prefix: "$" })).toBe("$-42.5");+ });++ it("defaults to a bare integer", () => {+ expect(handCountText(5)).toBe("5");+ });+});++describe("handCountPose", () => {+ it("advances one pose per step while counting", () => {+ expect(handCountPose(0, ON_GRID)).toBe(0);+ expect(handCountPose(3, ON_GRID)).toBe(1);+ expect(handCountPose(6, ON_GRID)).toBe(2);+ });++ it("stops at the settle pose", () => {+ const settled = handCountPose(handCountDuration(ON_GRID), ON_GRID);+ expect(handCountPose(1000, ON_GRID)).toBe(settled);+ });+});++describe("handCountJitter", () => {+ const jitter = (frame: number, options = ON_GRID, index = 0) =>+ handCountJitter({ frame, index, seed: "count", ...options });++ it("is identical for every frame inside one pose", () => {+ for (const offset of [0, 1, 2]) {+ expect(jitter(6 + offset)).toEqual(jitter(6));+ }+ });++ it("redraws the glyph on every counting pose", () => {+ expect(jitter(6)).not.toEqual(jitter(9));+ expect(jitter(9)).not.toEqual(jitter(12));+ });++ it("freezes at completion and stays frozen 30 frames later", () => {+ const settled = handCountDuration(ON_GRID);+ expect(jitter(settled + 30)).toEqual(jitter(settled));+ expect(jitter(settled + 300)).toEqual(jitter(settled));+ });++ it("freezes at completion for an off-grid delay too", () => {+ const settled = handCountDuration(OFF_GRID);+ expect(settled).toBe(39);+ expect(jitter(settled + 30, OFF_GRID)).toEqual(jitter(settled, OFF_GRID));+ });++ it("still moves on the pose right before it settles", () => {+ const settled = handCountDuration(ON_GRID);+ expect(jitter(settled - 3)).not.toEqual(jitter(settled));+ });++ it("gives each glyph its own hand", () => {+ expect(jitter(6, ON_GRID, 0)).not.toEqual(jitter(6, ON_GRID, 1));+ });++ it("stays inside the amplitudes handwrite uses", () => {+ for (let frame = 0; frame <= 40; frame++) {+ for (let index = 0; index < 6; index++) {+ const { rot, dy } = jitter(frame, ON_GRID, index);+ expect(Math.abs(rot)).toBeLessThanOrEqual(3.2);+ expect(Math.abs(dy)).toBeLessThanOrEqual(1.8);+ }+ }+ });++ it("is deterministic per seed and differs across seeds", () => {+ const a = handCountJitter({ frame: 6, index: 2, seed: "one", ...ON_GRID });+ const b = handCountJitter({ frame: 6, index: 2, seed: "one", ...ON_GRID });+ const c = handCountJitter({ frame: 6, index: 2, seed: "two", ...ON_GRID });+ expect(a).toEqual(b);+ expect(a).not.toEqual(c);+ });+});++describe("handCountConfig", () => {+ const defaultSettle = () =>+ handCountDuration({+ durationSteps: numberControl("durationSteps").default,+ step: numberControl("step").default,+ });++ it("fits the default count with a beat left to read the number", () => {+ expect(defaultSettle()).toBe(54);+ expect(+ handCountConfig.durationInFrames - defaultSettle(),+ ).toBeGreaterThanOrEqual(30);+ });++ it("does not hold a settled number for most of the preview", () => {+ expect(handCountConfig.durationInFrames).toBeLessThanOrEqual(+ defaultSettle() * 2,+ );+ });++ it("records exactly where a maxed-out slider outruns the preview", () => {+ const fits = (durationSteps: number, step: number) =>+ handCountDuration({ durationSteps, step }) <=+ handCountConfig.durationInFrames;+ expect(fits(18, 3)).toBe(true);+ expect(fits(24, 3)).toBe(true);+ expect(fits(15, 6)).toBe(true);+ expect(fits(18, 6)).toBe(false);+ expect(fits(24, 6)).toBe(false);+ });++ it("exposes ease as the two the component accepts", () => {+ const ease = handCountConfig.controls.ease;+ if (ease.type !== "select") {+ throw new Error("ease is not a select control");+ }+ expect(ease.options).toEqual(["in-out", "out", "linear"]);+ });+});diff --git a/registry/remocn/hand-count/config.ts b/registry/remocn/hand-count/config.tsnew file mode 100644index 00000000..97ec7cf9--- /dev/null+++ b/registry/remocn/hand-count/config.ts@@ -0,0 +1,71 @@+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const handCountConfig: ComponentConfig = {+ componentName: "HandCount",+ importPath: "@/components/remocn/hand-count",+ controls: {+ to: {+ type: "number",+ default: 1284,+ min: 0,+ max: 10000,+ step: 1,+ label: "Count to",+ },+ from: {+ type: "number",+ default: 0,+ min: 0,+ max: 1000,+ step: 1,+ label: "Count from",+ },+ durationSteps: {+ type: "number",+ default: 18,+ min: 2,+ max: 24,+ step: 1,+ label: "Poses counting",+ },+ decimals: {+ type: "number",+ default: 0,+ min: 0,+ max: 2,+ step: 1,+ label: "Decimals",+ },+ prefix: { type: "text", default: "", label: "Prefix" },+ suffix: { type: "text", default: "", label: "Suffix" },+ fontSize: {+ type: "number",+ default: 96,+ min: 32,+ max: 200,+ step: 2,+ label: "Font size",+ },+ color: { type: "color", default: "#26242c", label: "Color" },+ ease: {+ type: "select",+ default: "in-out",+ options: ["in-out", "out", "linear"],+ label: "Ease",+ },+ seed: { type: "text", default: "count", label: "Seed" },+ step: {+ type: "number",+ default: 3,+ min: 1,+ max: 6,+ step: 1,+ label: "Frames / pose",+ },+ },+ durationInFrames: 90,+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#f1eee7" },+};diff --git a/registry/remocn/hand-count/index.tsx b/registry/remocn/hand-count/index.tsxnew file mode 100644index 00000000..35156f17--- /dev/null+++ b/registry/remocn/hand-count/index.tsx@@ -0,0 +1,192 @@+"use client";++import { loadFont } from "@remotion/google-fonts/Caveat";+import { useCurrentFrame } from "remotion";+import {+ DEFAULT_STEP,+ hashRange,+ qstep,+ steppedRamp,+} from "@/lib/remocn/stop-motion";++const { fontFamily: HAND_FAMILY } = loadFont("normal", {+ subsets: ["latin"],+ weights: ["400", "500", "600", "700"],+});++const easeOutCubic = (t: number) => 1 - (1 - t) ** 3;++const easeInOutCubic = (t: number) =>+ t < 0.5 ? 4 * t ** 3 : 1 - (-2 * t + 2) ** 3 / 2;++const DEFAULT_DURATION_STEPS = 18;++export type HandCountEase = "in-out" | "out" | "linear";++const EASES: Record<HandCountEase, (t: number) => number> = {+ "in-out": easeInOutCubic,+ out: easeOutCubic,+ linear: (t: number) => t,+};++export type HandCountTiming = {+ delay?: number;+ durationSteps?: number;+ step?: number;+};++export function handCountDuration(options?: HandCountTiming): number {+ const delay = options?.delay ?? 0;+ const durationSteps = options?.durationSteps ?? DEFAULT_DURATION_STEPS;+ const step = options?.step ?? DEFAULT_STEP;+ const end = delay + durationSteps * step;+ return Math.ceil(end / step) * step;+}++export function handCountValue(+ args: HandCountTiming & {+ frame: number;+ to: number;+ from?: number;+ ease?: HandCountEase;+ },+): number {+ const from = args.from ?? 0;+ const delay = args.delay ?? 0;+ const durationSteps = args.durationSteps ?? DEFAULT_DURATION_STEPS;+ const step = args.step ?? DEFAULT_STEP;+ const progress = steppedRamp(+ args.frame,+ delay,+ delay + durationSteps * step,+ {+ ease: EASES[args.ease ?? "in-out"],+ step,+ },+ );+ return from + (args.to - from) * progress;+}++export function handCountText(+ value: number,+ options?: { decimals?: number; prefix?: string; suffix?: string },+): string {+ return `${options?.prefix ?? ""}${value.toFixed(options?.decimals ?? 0)}${options?.suffix ?? ""}`;+}++export function handCountPose(+ frame: number,+ options?: HandCountTiming,+): number {+ const step = options?.step ?? DEFAULT_STEP;+ const settled = handCountDuration(options);+ return Math.min(qstep(Math.max(0, frame), step), qstep(settled, step));+}++export function handCountJitter(+ args: HandCountTiming & { frame: number; index: number; seed?: string },+): { rot: number; dy: number } {+ const seed = args.seed ?? "count";+ const pose = handCountPose(args.frame, args);+ return {+ rot: hashRange(`${seed}:${pose}:${args.index}:r`, -3.2, 3.2),+ dy: hashRange(`${seed}:${pose}:${args.index}:y`, -1.8, 1.8),+ };+}++export interface HandCountProps {+ to: number;+ from?: number;+ delay?: number;+ durationSteps?: number;+ decimals?: number;+ prefix?: string;+ suffix?: string;+ fontSize?: number;+ color?: string;+ weight?: 400 | 500 | 600 | 700;+ ease?: HandCountEase;+ align?: "left" | "center";+ fontFamily?: string;+ seed?: string;+ step?: number;+}++export function HandCount({+ to,+ from = 0,+ delay = 0,+ durationSteps = DEFAULT_DURATION_STEPS,+ decimals = 0,+ prefix = "",+ suffix = "",+ fontSize = 96,+ color = "#26242c",+ weight = 700,+ ease = "in-out",+ align = "center",+ fontFamily = HAND_FAMILY,+ seed = "count",+ step = DEFAULT_STEP,+}: HandCountProps) {+ const frame = useCurrentFrame();+ const value = handCountValue({+ frame,+ to,+ from,+ delay,+ durationSteps,+ step,+ ease,+ });+ const chars = Array.from(handCountText(value, { decimals, prefix, suffix }));++ 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",+ textAlign: align,+ }}+ >+ {chars.map((char, i) => {+ const { rot, dy } = handCountJitter({+ frame,+ index: i,+ seed,+ delay,+ durationSteps,+ step,+ });+ return (+ <span+ key={`${i}:${char}`}+ style={{+ display: "inline-block",+ whiteSpace: "pre",+ transform: `translateY(${dy}px) rotate(${rot}deg)`,+ }}+ >+ {char}+ </span>+ );+ })}+ </span>+ </div>+ );+}diff --git a/registry/remocn/registry.json b/registry/remocn/registry.jsonindex f06c195b..df1bb6d8 100644--- a/registry/remocn/registry.json+++ b/registry/remocn/registry.json@@ -1373,6 +1373,21 @@}]},+ {+ "name": "hand-count",+ "type": "registry:component",+ "title": "Hand Count",+ "description": "A number that counts up in stop-motion poses, rewritten by hand at every pose and freezing still once it lands.",+ "dependencies": ["remotion", "@remotion/google-fonts"],+ "registryDependencies": ["@remocn/stop-motion"],+ "files": [+ {+ "path": "hand-count/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/hand-count.tsx"+ }+ ]+ },{"name": "brush","type": "registry:component",