Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
feat: brush
kapishdima2dc4af2b8e97
diff --git a/components/docs/examples/scribble-circle-example.tsx b/components/docs/examples/scribble-circle-example.tsxnew file mode 100644index 00000000..52b95464--- /dev/null+++ b/components/docs/examples/scribble-circle-example.tsx@@ -0,0 +1,149 @@+"use client";++import { AbsoluteFill } from "remotion";+import { ScribbleCircle } from "@/registry/remocn/scribble-circle";++const FONT_FAMILY =+ "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif";++const INK = "#26242c";+const MUTED = "rgba(38,36,44,0.55)";++const CARD_WIDTH = 460;+const CARD_PAD = 24;+const ROW_PAD = 18;+const ROW_HEIGHT = 84;+const PRICE_WIDTH = 76;++const PLANS = [+ { name: "Hobby", price: "Free" },+ { name: "Pro", price: "$19" },+ { name: "Team", price: "$49" },+];++const TARGET = 1;++const CIRCLE_WIDTH = 108;+const CIRCLE_HEIGHT = 62;++const PRICE_LEFT = CARD_WIDTH - CARD_PAD - ROW_PAD - PRICE_WIDTH;+const CIRCLE_LEFT = PRICE_LEFT + (PRICE_WIDTH - CIRCLE_WIDTH) / 2;+const CIRCLE_TOP =+ CARD_PAD + TARGET * ROW_HEIGHT + (ROW_HEIGHT - CIRCLE_HEIGHT) / 2;++export function ScribbleCircleExampleScene({+ laps,+ strokeWidth,+ pressure,+ grain,+ durationSteps,+ color,+ seed,+ step,+}: {+ laps?: number;+ strokeWidth?: number;+ pressure?: number;+ grain?: number;+ durationSteps?: number;+ color?: string;+ seed?: string;+ step?: number;+}) {+ return (+ <AbsoluteFill style={{ alignItems: "center", justifyContent: "center" }}>+ <div+ style={{+ position: "relative",+ width: CARD_WIDTH,+ padding: CARD_PAD,+ borderRadius: 18,+ background: "#fdfcf8",+ fontFamily: FONT_FAMILY,+ }}+ >+ {PLANS.map((plan) => (+ <div+ key={plan.name}+ style={{+ display: "flex",+ alignItems: "center",+ justifyContent: "space-between",+ height: ROW_HEIGHT,+ padding: `0 ${ROW_PAD}px`,+ color: INK,+ }}+ >+ <span style={{ fontSize: 30, fontWeight: 600 }}>{plan.name}</span>+ <span+ style={{+ display: "inline-block",+ width: PRICE_WIDTH,+ textAlign: "center",+ fontSize: 26,+ color: MUTED,+ }}+ >+ {plan.price}+ </span>+ </div>+ ))}++ <div+ style={{+ position: "absolute",+ left: CIRCLE_LEFT,+ top: CIRCLE_TOP,+ }}+ >+ <ScribbleCircle+ width={CIRCLE_WIDTH}+ height={CIRCLE_HEIGHT}+ laps={laps}+ strokeWidth={strokeWidth}+ pressure={pressure}+ grain={grain}+ durationSteps={durationSteps}+ color={color}+ seed={seed}+ step={step}+ />+ </div>+ </div>+ </AbsoluteFill>+ );+}++export const scribbleCircleExampleCode = (+ values: Record<string, unknown>,+): string => {+ const laps = (values.laps as number) ?? 1.15;+ const strokeWidth = (values.strokeWidth as number) ?? 14;+ const pressure = (values.pressure as number) ?? 0.2;+ const grain = (values.grain as number) ?? 1;+ const durationSteps = (values.durationSteps as number) ?? 10;+ const color = (values.color as string) ?? "#6f7f35";+ const seed = (values.seed as string) ?? "scribble";+ const step = (values.step as number) ?? 3;+ return `import { ScribbleCircle } from "@/components/remocn/scribble-circle";++export const MyScene = () => (+ <div style={{ position: "relative" }}>+ <PricingCard />+ <div style={{ position: "absolute", left: ${CIRCLE_LEFT}, top: ${CIRCLE_TOP} }}>+ <ScribbleCircle+ width={${CIRCLE_WIDTH}}+ height={${CIRCLE_HEIGHT}}+ laps={${laps}}+ strokeWidth={${strokeWidth}}+ pressure={${pressure}}+ grain={${grain}}+ durationSteps={${durationSteps}}+ color="${color}"+ seed="${seed}"+ step={${step}}+ />+ </div>+ </div>+);`;+};diff --git a/content/docs/components.mdx b/content/docs/components.mdxindex 0b5c0d6d..301db625 100644--- a/content/docs/components.mdx+++ b/content/docs/components.mdx@@ -483,6 +483,12 @@ Physical overlays and hand-made motion.status: "stable",href: "/docs/effects/ink-arrow",},+ {+ name: "ScribbleCircle",+ description: "A brush circle that sweeps itself around a region of the frame, opening thin and closing thick",+ status: "stable",+ href: "/docs/effects/scribble-circle",+ },{name: "Confetti",description: "A one-shot burst of paper confetti for milestone and celebration beats",diff --git a/content/docs/effects/meta.json b/content/docs/effects/meta.jsonindex f8b32835..39cfc9c6 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", "ink-arrow"]+ "pages": ["index", "confetti", "paper-wobble", "ink-arrow", "scribble-circle"]}diff --git a/content/docs/effects/scribble-circle.mdx b/content/docs/effects/scribble-circle.mdxnew file mode 100644index 00000000..be2ff8ee--- /dev/null+++ b/content/docs/effects/scribble-circle.mdx@@ -0,0 +1,192 @@+---+title: Scribble Circle+description: A brush circle that sweeps itself around a region of the frame, opening thin and closing thick+---++<ComponentPreview name="scribble-circle" />++## Installation++<InstallBlock name="scribble-circle" />++## Usage++Position it absolutely over whatever you are pointing at. The component draws+nothing but the loop — no background, no children — so it composes over a+screenshot, a card, or a number without touching the layout underneath.++```tsx+// src/Root.tsx+import { AbsoluteFill, Composition } from "remotion";+import { ScribbleCircle } from "@/components/remocn/scribble-circle";++const ScribbleScene = () => (+ <AbsoluteFill+ style={{+ background: "#f1eee7",+ alignItems: "center",+ justifyContent: "center",+ }}+ >+ <div style={{ position: "relative" }}>+ <PricingCard />+ <div style={{ position: "absolute", left: 326, top: 119 }}>+ <ScribbleCircle width={108} height={62} delay={18} />+ </div>+ </div>+ </AbsoluteFill>+);++export const RemotionRoot = () => (+ <Composition+ id="ScribbleCircle"+ component={ScribbleScene}+ durationInFrames={150}+ fps={30}+ width={1280}+ height={720}+ />+);+```++### Circle it, then point at it++Pairing with `ink-arrow` is the full annotation beat — the loop lands first,+then the arrow arrives to explain it. Give the arrow a `delay` past the end of+the circle's draw, which is `durationSteps * step` frames after its own delay.++```tsx+const CIRCLE_AT = 18;+const CIRCLE_DRAW = 10 * 3;++<>+ <div style={{ position: "absolute", left: 326, top: 119 }}>+ <ScribbleCircle width={108} height={62} delay={CIRCLE_AT} />+ </div>+ <div style={{ position: "absolute", left: 470, top: 40 }}>+ <InkArrow+ from={{ x: 180, y: 0 }}+ to={{ x: 20, y: 120 }}+ delay={CIRCLE_AT + CIRCLE_DRAW}+ />+ </div>+</>;+```++### It is a brush, not a pen++The mark is a filled ribbon whose width follows a pressure profile, not a+constant-width stroke. `pressure` is where the brush starts, as a fraction of+`strokeWidth`: at the default `0.2` the loop opens at a fifth of full weight+and thickens all the way round to a blunt, fully loaded end. `pressure: 1`+turns the taper off and gives a uniform band.++`grain` roughens the edges. It is worth understanding what it does, because it+is what keeps the mark from looking printed: the ribbon is displaced by a noise+field whose amplitude is proportional to `strokeWidth`. Where the ribbon is+thicker than that amplitude the edges merely go ragged; where it is thinner —+which is exactly the opening, by construction — the ribbon breaks apart into+dry-brush flecks. So the stroke is never uniformly filled in, and the thin+opening fades rather than ending abruptly. `grain: 0` switches the filter off+and leaves clean vector edges.++### Tuning the gesture++`laps` is a float and it is the character knob. The default `1.15` sends the+brush once round and about 54° past where it started — that overshoot is what+stops the loop reading as a drawn `<ellipse>`. `2` gives the double-loop+scribble; `0.9` leaves an open arc. Where the brush passes its own starting+angle the two passes sit at slightly different radii, because the radius noise+is keyed on the sample index rather than the angle, so the laps never retrace+each other.++The loop draws in equal arcs per pose, so you watch the brush travel rather+than seeing the circle appear nearly finished on its first frame. More+`durationSteps` means more, smaller poses.++### Why there is no children API++`<ScribbleCircle>{target}</ScribbleCircle>`, measuring its child and sizing+itself, is the nicer-looking API and it does not work here. Measurement needs+`useLayoutEffect` and `getBoundingClientRect`, neither of which runs during+Remotion's server-side render: the ellipse would size correctly in the browser+preview and collapse in the exported video. Explicit `width` and `height` is+the honest contract, the same call `ink-underline` makes with its required+`width`.++The root element keeps exactly the `width` and `height` you pass, so your+positioning math stays predictable. Only the SVG overflows, by enough to cover+the radius noise, the centre nudge, and the stroke.++## Props++<PropsTable+ rows={[+ {+ name: "width",+ type: "number",+ required: true,+ description: "Nominal width of the loop and of the root element",+ },+ {+ name: "height",+ type: "number",+ required: true,+ description: "Nominal height of the loop and of the root element",+ },+ {+ name: "color",+ type: "string",+ default: "\"#6f7f35\"",+ description: "Ink colour of the stroke",+ },+ {+ name: "strokeWidth",+ type: "number",+ default: "14",+ description: "Brush width at full pressure; the grain amplitude scales from it",+ },+ {+ name: "pressure",+ type: "number",+ default: "0.2",+ description: "Weight the brush opens on, as a fraction of strokeWidth; 1 removes the taper",+ },+ {+ name: "grain",+ type: "number",+ default: "1",+ description: "Edge roughness; breaks the thin opening into dry-brush flecks, 0 gives clean edges",+ },+ {+ name: "delay",+ type: "number",+ default: "0",+ description: "Local frame the pen starts moving",+ },+ {+ name: "durationSteps",+ type: "number",+ default: "10",+ description: "Poses the loop takes to draw, each advancing an equal arc",+ },+ {+ name: "laps",+ type: "number",+ default: "1.15",+ description: "How far round the pen travels; above 1 it overshoots its start",+ },+ {+ name: "seed",+ type: "string",+ default: "\"scribble\"",+ description: "Seed for the radius noise, the centre nudge, and the grain field",+ },+ {+ name: "step",+ type: "number",+ default: "3",+ description: "Frames per stop-motion pose",+ },+ ]}+/>diff --git a/registry-artifacts/registry.json b/registry-artifacts/registry.jsonindex 60656226..9914f6e2 100644--- a/registry-artifacts/registry.json+++ b/registry-artifacts/registry.json@@ -1373,6 +1373,21 @@],"type": "registry:component"},+ {+ "name": "scribble-circle",+ "title": "Scribble Circle",+ "description": "A brush circle swept around a region of the frame, opening thin and closing thick, with grain breaking up the dry opening.",+ "dependencies": ["remotion"],+ "registryDependencies": ["@remocn/stop-motion"],+ "files": [+ {+ "path": "registry/remocn/scribble-circle/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/scribble-circle.tsx"+ }+ ],+ "type": "registry:component"+ },{"name": "check-list","title": "Check List",diff --git a/registry-artifacts/scribble-circle.json b/registry-artifacts/scribble-circle.jsonnew file mode 100644index 00000000..ba99d5ba--- /dev/null+++ b/registry-artifacts/scribble-circle.json@@ -0,0 +1,17 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "scribble-circle",+ "title": "Scribble Circle",+ "description": "A brush circle swept around a region of the frame, opening thin and closing thick, with grain breaking up the dry opening.",+ "dependencies": ["remotion"],+ "registryDependencies": ["@remocn/stop-motion"],+ "files": [+ {+ "path": "registry/remocn/scribble-circle/index.tsx",+ "content": "\"use client\";\n\nimport { useCurrentFrame } from \"remotion\";\nimport {\n DEFAULT_STEP,\n hash01,\n hashRange,\n steppedRamp,\n} from \"@/lib/remocn/stop-motion\";\n\nconst SAMPLES_PER_LAP = 48;\nconst NOISE = 0.035;\nconst CENTRE = 0.02;\nconst GRAIN_RATIO = 0.5;\n\nexport type ScribblePoint = { x: number; y: number };\n\nexport type ScribbleCircleGeometry = {\n width: number;\n height: number;\n strokeWidth: number;\n laps?: number;\n pressure?: number;\n grain?: number;\n seed?: string;\n points?: number;\n progress?: number;\n};\n\nexport function scribbleCircleCentre(\n width: number,\n height: number,\n seed = \"scribble\",\n): ScribblePoint {\n return {\n x: width / 2 + hashRange(`${seed}:cx`, -CENTRE, CENTRE) * width,\n y: height / 2 + hashRange(`${seed}:cy`, -CENTRE, CENTRE) * height,\n };\n}\n\nexport function scribbleCirclePoints(args: {\n width: number;\n height: number;\n laps?: number;\n seed?: string;\n points?: number;\n}): ScribblePoint[] {\n const laps = args.laps ?? 1.15;\n const seed = args.seed ?? \"scribble\";\n const points = args.points ?? SAMPLES_PER_LAP;\n\n const count = Math.max(2, Math.ceil(laps * points));\n const rx = args.width / 2;\n const ry = args.height / 2;\n const { x: cx, y: cy } = scribbleCircleCentre(args.width, args.height, seed);\n\n return Array.from({ length: count }, (_, i) => {\n const angle = laps * Math.PI * 2 * (i / (count - 1));\n const scale = 1 + hashRange(`${seed}:r${i}`, -NOISE, NOISE);\n return {\n x: cx + rx * scale * Math.cos(angle),\n y: cy + ry * scale * Math.sin(angle),\n };\n });\n}\n\nexport function scribbleCircleHalfWidth(\n strokeWidth: number,\n pressure: number,\n t: number,\n): number {\n return (strokeWidth / 2) * (pressure + (1 - pressure) * t);\n}\n\nexport function scribbleCircleGrainScale(\n strokeWidth: number,\n grain: number,\n): number {\n return strokeWidth * GRAIN_RATIO * grain;\n}\n\nconst normalAt = (points: ScribblePoint[], i: number): ScribblePoint => {\n const before = points[i - 1] ?? points[i];\n const after = points[i + 1] ?? points[i];\n const tx = after.x - before.x;\n const ty = after.y - before.y;\n const length = Math.hypot(tx, ty) || 1;\n return { x: -ty / length, y: tx / length };\n};\n\nconst curveSegments = (points: ScribblePoint[]): string =>\n points\n .slice(0, -1)\n .map((p1, i) => {\n const p0 = points[i - 1] ?? p1;\n const p2 = points[i + 1];\n const p3 = points[i + 2] ?? p2;\n return `C ${p1.x + (p2.x - p0.x) / 6} ${p1.y + (p2.y - p0.y) / 6}, ${p2.x - (p3.x - p1.x) / 6} ${p2.y - (p3.y - p1.y) / 6}, ${p2.x} ${p2.y}`;\n })\n .join(\" \");\n\nexport function scribbleCirclePath(args: ScribbleCircleGeometry): {\n d: string;\n viewBox: string;\n marginX: number;\n marginY: number;\n} {\n const pressure = args.pressure ?? 0.2;\n const grain = args.grain ?? 1;\n const progress = args.progress ?? 1;\n const spine = scribbleCirclePoints(args);\n const drawn = Math.max(2, Math.round(progress * (spine.length - 1)) + 1);\n\n const left: ScribblePoint[] = [];\n const right: ScribblePoint[] = [];\n for (let i = 0; i < drawn; i++) {\n const half = scribbleCircleHalfWidth(\n args.strokeWidth,\n pressure,\n i / (spine.length - 1),\n );\n const normal = normalAt(spine, i);\n left.push({\n x: spine[i].x + normal.x * half,\n y: spine[i].y + normal.y * half,\n });\n right.push({\n x: spine[i].x - normal.x * half,\n y: spine[i].y - normal.y * half,\n });\n }\n const back = right.slice().reverse();\n\n const reach =\n args.strokeWidth / 2 +\n scribbleCircleGrainScale(args.strokeWidth, grain) / 2;\n const marginX = reach + (args.width / 2) * NOISE + args.width * CENTRE;\n const marginY = reach + (args.height / 2) * NOISE + args.height * CENTRE;\n\n return {\n d: `M ${left[0].x} ${left[0].y} ${curveSegments(left)} L ${back[0].x} ${back[0].y} ${curveSegments(back)} Z`,\n viewBox: `${-marginX} ${-marginY} ${args.width + marginX * 2} ${args.height + marginY * 2}`,\n marginX,\n marginY,\n };\n}\n\nexport function scribbleCircleProgress(\n frame: number,\n options?: { delay?: number; durationSteps?: number; step?: number },\n): number {\n const delay = options?.delay ?? 0;\n const durationSteps = options?.durationSteps ?? 10;\n const step = options?.step ?? DEFAULT_STEP;\n return steppedRamp(frame, delay, delay + durationSteps * step, { step });\n}\n\nexport interface ScribbleCircleProps {\n width: number;\n height: number;\n color?: string;\n strokeWidth?: number;\n pressure?: number;\n grain?: number;\n delay?: number;\n durationSteps?: number;\n laps?: number;\n seed?: string;\n step?: number;\n}\n\nexport function ScribbleCircle({\n width,\n height,\n color = \"#6f7f35\",\n strokeWidth = 14,\n pressure = 0.2,\n grain = 1,\n delay = 0,\n durationSteps = 10,\n laps = 1.15,\n seed = \"scribble\",\n step = DEFAULT_STEP,\n}: ScribbleCircleProps) {\n const frame = useCurrentFrame();\n const progress = scribbleCircleProgress(frame, {\n delay,\n durationSteps,\n step,\n });\n const { d, viewBox, marginX, marginY } = scribbleCirclePath({\n width,\n height,\n strokeWidth,\n laps,\n pressure,\n grain,\n seed,\n progress,\n });\n\n const grainScale = scribbleCircleGrainScale(strokeWidth, grain);\n const filterId = `scribble-grain-${Math.floor(hash01(seed) * 1e9)}`;\n\n return (\n <div\n style={{\n position: \"relative\",\n width,\n height,\n opacity: progress > 0 ? 1 : 0,\n }}\n >\n <svg\n width={width + marginX * 2}\n height={height + marginY * 2}\n viewBox={viewBox}\n style={{\n position: \"absolute\",\n left: -marginX,\n top: -marginY,\n display: \"block\",\n overflow: \"visible\",\n }}\n >\n <title>Scribbled circle</title>\n <defs>\n <filter\n id={filterId}\n x=\"-30%\"\n y=\"-30%\"\n width=\"160%\"\n height=\"160%\"\n filterUnits=\"objectBoundingBox\"\n >\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"0.7\"\n numOctaves={3}\n seed={Math.floor(hash01(`${seed}:grain`) * 1000)}\n result=\"grain\"\n />\n <feDisplacementMap\n in=\"SourceGraphic\"\n in2=\"grain\"\n scale={grainScale}\n xChannelSelector=\"R\"\n yChannelSelector=\"G\"\n />\n </filter>\n </defs>\n <path\n d={d}\n fill={color}\n opacity={0.85}\n filter={grain > 0 ? `url(#${filterId})` : undefined}\n />\n </svg>\n </div>\n );\n}\n",+ "type": "registry:component",+ "target": "components/remocn/scribble-circle.tsx"+ }+ ],+ "type": "registry:component"+}diff --git a/registry/__index__.tsx b/registry/__index__.tsxindex e0b3baa6..c697bc4a 100644--- a/registry/__index__.tsx+++ b/registry/__index__.tsx@@ -55,6 +55,7 @@ import { rippleZoomConfig } from "@/registry/remocn/ripple-zoom/config";import { rollingNumberConfig } from "@/registry/remocn/rolling-number/config";import { rolodexFlipConfig } from "@/registry/remocn/rolodex-flip/config";import { scaleDownFadeConfig } from "@/registry/remocn/scale-down-fade/config";+import { scribbleCircleConfig } from "@/registry/remocn/scribble-circle/config";import { shaderColorPanelsConfig } from "@/registry/remocn/shader-color-panels/config";import { shaderDitheringConfig } from "@/registry/remocn/shader-dithering/config";import { shaderDotOrbitConfig } from "@/registry/remocn/shader-dot-orbit/config";@@ -1565,6 +1566,15 @@ const registry: Record<string, RegistryEntry> = {})),config: checkListConfig,},+ "scribble-circle": {+ load: () =>+ import("@/components/docs/examples/scribble-circle-example").then(+ (m) => ({+ default: m.ScribbleCircleExampleScene,+ }),+ ),+ config: scribbleCircleConfig,+ },"page-turn": {load: () =>import("@/components/docs/examples/page-turn-example").then((m) => ({diff --git a/registry/remocn/registry.json b/registry/remocn/registry.jsonindex 96be4f7c..8732b35c 100644--- a/registry/remocn/registry.json+++ b/registry/remocn/registry.json@@ -1373,6 +1373,21 @@}]},+ {+ "name": "scribble-circle",+ "type": "registry:component",+ "title": "Scribble Circle",+ "description": "A brush circle swept around a region of the frame, opening thin and closing thick, with grain breaking up the dry opening.",+ "dependencies": ["remotion"],+ "registryDependencies": ["@remocn/stop-motion"],+ "files": [+ {+ "path": "scribble-circle/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/scribble-circle.tsx"+ }+ ]+ },{"name": "check-list","type": "registry:component",diff --git a/registry/remocn/scribble-circle/__tests__/scribble-circle.test.ts b/registry/remocn/scribble-circle/__tests__/scribble-circle.test.tsnew file mode 100644index 00000000..71bcb314--- /dev/null+++ b/registry/remocn/scribble-circle/__tests__/scribble-circle.test.ts@@ -0,0 +1,312 @@+import { describe, expect, it } from "bun:test";++import { scribbleCircleConfig } from "../config";+import {+ scribbleCircleCentre,+ scribbleCircleGrainScale,+ scribbleCircleHalfWidth,+ scribbleCirclePath,+ scribbleCirclePoints,+ scribbleCircleProgress,+} from "../index";++const W = 420;+const H = 240;+const STROKE = 14;++const numberControl = (name: string) => {+ const control = scribbleCircleConfig.controls[name];+ if (control.type !== "number") {+ throw new Error(`${name} is not a number control`);+ }+ return control;+};++const controlValues = (name: string) => {+ const { min, max, step } = numberControl(name);+ return Array.from(+ { length: Math.floor((max - min) / step + 1e-9) + 1 },+ (_, i) => min + i * step,+ );+};++const radiusFrom = (+ point: { x: number; y: number },+ centre: { x: number; y: number },+) => Math.hypot((point.x - centre.x) / (W / 2), (point.y - centre.y) / (H / 2));++const numbersIn = (d: string) =>+ d.match(/-?\d+(\.\d+)?(e-?\d+)?/g)?.map(Number) ?? [];++describe("scribbleCircleProgress", () => {+ const poses = (opts: { durationSteps: number; step: number }) =>+ Array.from({ length: opts.durationSteps + 1 }, (_, i) =>+ scribbleCircleProgress(i * opts.step, opts),+ );++ it("stays hidden until the first pose lands", () => {+ for (const frame of [0, 1, 2]) {+ expect(scribbleCircleProgress(frame)).toBe(0);+ }+ expect(scribbleCircleProgress(3)).toBeGreaterThan(0);+ });++ it("opens on a small arc rather than jumping most of the way round", () => {+ const first = scribbleCircleProgress(3);+ expect(first).toBeCloseTo(0.1);+ expect(first).toBeLessThan(0.2);+ });++ it("advances an equal arc every pose, so the pen reads as travelling", () => {+ const drawn = poses({ durationSteps: 10, step: 3 });+ const deltas = drawn.slice(1).map((value, i) => value - drawn[i]);+ for (const delta of deltas) {+ expect(delta).toBeCloseTo(0.1, 9);+ }+ expect(drawn.at(-1)).toBe(1);+ });++ it("holds each pose for the whole step, never moving between them", () => {+ for (const offset of [0, 1, 2]) {+ expect(scribbleCircleProgress(6 + offset)).toBe(+ scribbleCircleProgress(6),+ );+ }+ });++ it("keeps every pose distinct across the durationSteps control range", () => {+ for (const durationSteps of controlValues("durationSteps")) {+ const drawn = poses({ durationSteps, step: 3 });+ expect(new Set(drawn).size).toBe(durationSteps + 1);+ }+ });+});++describe("scribbleCircleHalfWidth", () => {+ it("opens at the pressure fraction and closes at the full brush", () => {+ expect(scribbleCircleHalfWidth(STROKE, 0.2, 0)).toBeCloseTo(1.4);+ expect(scribbleCircleHalfWidth(STROKE, 0.2, 1)).toBeCloseTo(7);+ });++ it("thickens monotonically along the stroke", () => {+ let previous = -1;+ for (let i = 0; i <= 20; i++) {+ const half = scribbleCircleHalfWidth(STROKE, 0.2, i / 20);+ expect(half).toBeGreaterThan(previous);+ previous = half;+ }+ });++ it("gives a uniform brush at pressure 1", () => {+ for (const t of [0, 0.3, 0.7, 1]) {+ expect(scribbleCircleHalfWidth(STROKE, 1, t)).toBeCloseTo(STROKE / 2);+ }+ });++ it("stays thinner than the grain displacement at the opening, so the tail breaks up", () => {+ const opening = scribbleCircleHalfWidth(STROKE, 0.2, 0);+ expect(opening * 2).toBeLessThan(scribbleCircleGrainScale(STROKE, 1));+ });+});++describe("scribbleCirclePath", () => {+ it("is deterministic for a seed", () => {+ const a = scribbleCirclePath({ width: W, height: H, strokeWidth: STROKE });+ const b = scribbleCirclePath({ width: W, height: H, strokeWidth: STROKE });+ expect(a.d).toBe(b.d);+ expect(a.viewBox).toBe(b.viewBox);+ });++ it("gives a different loop for a different seed", () => {+ const a = scribbleCirclePath({+ width: W,+ height: H,+ strokeWidth: STROKE,+ seed: "one",+ });+ const b = scribbleCirclePath({+ width: W,+ height: H,+ strokeWidth: STROKE,+ seed: "two",+ });+ expect(a.d).not.toBe(b.d);+ });++ it("is a closed ribbon with one subpath, not a stroked polyline", () => {+ const { d } = scribbleCirclePath({+ width: W,+ height: H,+ strokeWidth: STROKE,+ });+ expect(d.match(/M/g)).toHaveLength(1);+ expect(d.match(/Z/g)).toHaveLength(1);+ expect(d.trimEnd().endsWith("Z")).toBe(true);+ });++ it("widens the ribbon when strokeWidth grows", () => {+ const spread = (strokeWidth: number) => {+ const xs = numbersIn(+ scribbleCirclePath({ width: W, height: H, strokeWidth }).d,+ ).filter((_, i) => i % 2 === 0);+ return Math.max(...xs) - Math.min(...xs);+ };+ expect(spread(28)).toBeGreaterThan(spread(8));+ });++ it("grows the spine with laps", () => {+ const one = scribbleCirclePoints({ width: W, height: H, laps: 1 });+ const two = scribbleCirclePoints({ width: W, height: H, laps: 2 });+ expect(one).toHaveLength(48);+ expect(two).toHaveLength(96);+ });++ it("derives both margins separately, since one scalar cannot bound both axes", () => {+ const { marginX, marginY } = scribbleCirclePath({+ width: W,+ height: H,+ strokeWidth: STROKE,+ });+ const reach = STROKE / 2 + scribbleCircleGrainScale(STROKE, 1) / 2;+ expect(marginX).toBeCloseTo(reach + (W / 2) * 0.035 + W * 0.02);+ expect(marginY).toBeCloseTo(reach + (H / 2) * 0.035 + H * 0.02);+ expect(marginX).not.toBeCloseTo(marginY);+ });++ it("keeps every ribbon coordinate inside the padded viewBox", () => {+ for (const strokeWidth of controlValues("strokeWidth")) {+ for (const grain of controlValues("grain")) {+ for (const pressure of [0.05, 0.5, 1]) {+ const { d, marginX, marginY } = scribbleCirclePath({+ width: W,+ height: H,+ strokeWidth,+ grain,+ pressure,+ });+ const values = numbersIn(d);+ const xs = values.filter((_, i) => i % 2 === 0);+ const ys = values.filter((_, i) => i % 2 === 1);+ expect(Math.min(...xs)).toBeGreaterThanOrEqual(-marginX);+ expect(Math.max(...xs)).toBeLessThanOrEqual(W + marginX);+ expect(Math.min(...ys)).toBeGreaterThanOrEqual(-marginY);+ expect(Math.max(...ys)).toBeLessThanOrEqual(H + marginY);+ }+ }+ }+ });++ it("never produces a degenerate viewBox", () => {+ for (const grain of controlValues("grain")) {+ const [, , w, h] = scribbleCirclePath({+ width: W,+ height: H,+ strokeWidth: STROKE,+ grain,+ })+ .viewBox.split(" ")+ .map(Number);+ expect(w).toBeGreaterThan(0);+ expect(h).toBeGreaterThan(0);+ }+ });+});++describe("scribbleCirclePath drawing", () => {+ it("grows the ribbon as progress advances", () => {+ let previous = 0;+ for (const progress of [0.1, 0.3, 0.6, 1]) {+ const length = numbersIn(+ scribbleCirclePath({+ width: W,+ height: H,+ strokeWidth: STROKE,+ progress,+ }).d,+ ).length;+ expect(length).toBeGreaterThan(previous);+ previous = length;+ }+ });++ it("anchors the pressure profile to the whole gesture, not the drawn part", () => {+ const partial = scribbleCirclePath({+ width: W,+ height: H,+ strokeWidth: STROKE,+ progress: 0.5,+ });+ const full = scribbleCirclePath({+ width: W,+ height: H,+ strokeWidth: STROKE,+ progress: 1,+ });+ expect(full.d.startsWith(partial.d.slice(0, 40))).toBe(true);+ });++ it("stays a valid ribbon at the smallest possible progress", () => {+ const { d } = scribbleCirclePath({+ width: W,+ height: H,+ strokeWidth: STROKE,+ progress: 0,+ });+ expect(d.match(/M/g)).toHaveLength(1);+ expect(numbersIn(d).every(Number.isFinite)).toBe(true);+ });+});++describe("scribbleCirclePoints", () => {+ it("keeps a fixed hand-made irregularity now that wobble is gone", () => {+ const centre = scribbleCircleCentre(W, H);+ const radii = scribbleCirclePoints({ width: W, height: H }).map((point) =>+ radiusFrom(point, centre),+ );+ const spread = Math.max(...radii) - Math.min(...radii);+ expect(spread).toBeGreaterThan(0);+ expect(spread).toBeLessThan(0.08);+ });++ it("nudges the centre off the nominal one", () => {+ expect(scribbleCircleCentre(W, H)).not.toEqual({ x: W / 2, y: H / 2 });+ });++ it("passes its own starting angle at a different radius on the second lap", () => {+ const laps = 1.15;+ const points = scribbleCirclePoints({ width: W, height: H, laps });+ const centre = scribbleCircleCentre(W, H);+ const crossing = Math.round((points.length - 1) / laps);+ expect(crossing).toBe(48);+ expect(radiusFrom(points[crossing], centre)).not.toBeCloseTo(+ radiusFrom(points[0], centre),+ 3,+ );+ });++ it("overshoots a full turn at the default laps", () => {+ expect(+ scribbleCirclePoints({ width: W, height: H }).length / 48,+ ).toBeGreaterThan(1);+ });+});++describe("scribbleCircleConfig", () => {+ it("exposes no wobble control", () => {+ expect(scribbleCircleConfig.controls.wobble).toBeUndefined();+ });++ it("lets grain be switched off entirely", () => {+ expect(numberControl("grain").min).toBe(0);+ });++ it("reaches a uniform brush at the top of the pressure range", () => {+ expect(numberControl("pressure").max).toBe(1);+ });++ it("covers the draw at the control maxima", () => {+ const longest =+ numberControl("durationSteps").max * numberControl("step").max;+ expect(longest).toBeLessThanOrEqual(scribbleCircleConfig.durationInFrames);+ });+});diff --git a/registry/remocn/scribble-circle/config.ts b/registry/remocn/scribble-circle/config.tsnew file mode 100644index 00000000..0947fc06--- /dev/null+++ b/registry/remocn/scribble-circle/config.ts@@ -0,0 +1,65 @@+import { scribbleCircleExampleCode } from "@/components/docs/examples/scribble-circle-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const scribbleCircleConfig: ComponentConfig = {+ componentName: "ScribbleCircle",+ importPath: "@/components/remocn/scribble-circle",+ controls: {+ laps: {+ type: "number",+ default: 1.15,+ min: 0.5,+ max: 3,+ step: 0.05,+ label: "Laps",+ },+ strokeWidth: {+ type: "number",+ default: 14,+ min: 4,+ max: 32,+ step: 1,+ label: "Brush width",+ },+ pressure: {+ type: "number",+ default: 0.2,+ min: 0.05,+ max: 1,+ step: 0.05,+ label: "Opening pressure",+ },+ grain: {+ type: "number",+ default: 1,+ min: 0,+ max: 2,+ step: 0.1,+ label: "Grain",+ },+ durationSteps: {+ type: "number",+ default: 10,+ min: 2,+ max: 20,+ step: 1,+ label: "Poses to draw",+ },+ color: { type: "color", default: "#6f7f35", label: "Ink color" },+ seed: { type: "text", default: "scribble", label: "Seed" },+ step: {+ type: "number",+ default: 3,+ min: 1,+ max: 6,+ step: 1,+ label: "Frames / pose",+ },+ },+ snippet: scribbleCircleExampleCode,+ durationInFrames: 150,+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#f1eee7" },+};diff --git a/registry/remocn/scribble-circle/index.tsx b/registry/remocn/scribble-circle/index.tsxnew file mode 100644index 00000000..510b8fbc--- /dev/null+++ b/registry/remocn/scribble-circle/index.tsx@@ -0,0 +1,261 @@+"use client";++import { useCurrentFrame } from "remotion";+import {+ DEFAULT_STEP,+ hash01,+ hashRange,+ steppedRamp,+} from "@/lib/remocn/stop-motion";++const SAMPLES_PER_LAP = 48;+const NOISE = 0.035;+const CENTRE = 0.02;+const GRAIN_RATIO = 0.5;++export type ScribblePoint = { x: number; y: number };++export type ScribbleCircleGeometry = {+ width: number;+ height: number;+ strokeWidth: number;+ laps?: number;+ pressure?: number;+ grain?: number;+ seed?: string;+ points?: number;+ progress?: number;+};++export function scribbleCircleCentre(+ width: number,+ height: number,+ seed = "scribble",+): ScribblePoint {+ return {+ x: width / 2 + hashRange(`${seed}:cx`, -CENTRE, CENTRE) * width,+ y: height / 2 + hashRange(`${seed}:cy`, -CENTRE, CENTRE) * height,+ };+}++export function scribbleCirclePoints(args: {+ width: number;+ height: number;+ laps?: number;+ seed?: string;+ points?: number;+}): ScribblePoint[] {+ const laps = args.laps ?? 1.15;+ const seed = args.seed ?? "scribble";+ const points = args.points ?? SAMPLES_PER_LAP;++ const count = Math.max(2, Math.ceil(laps * points));+ const rx = args.width / 2;+ const ry = args.height / 2;+ const { x: cx, y: cy } = scribbleCircleCentre(args.width, args.height, seed);++ return Array.from({ length: count }, (_, i) => {+ const angle = laps * Math.PI * 2 * (i / (count - 1));+ const scale = 1 + hashRange(`${seed}:r${i}`, -NOISE, NOISE);+ return {+ x: cx + rx * scale * Math.cos(angle),+ y: cy + ry * scale * Math.sin(angle),+ };+ });+}++export function scribbleCircleHalfWidth(+ strokeWidth: number,+ pressure: number,+ t: number,+): number {+ return (strokeWidth / 2) * (pressure + (1 - pressure) * t);+}++export function scribbleCircleGrainScale(+ strokeWidth: number,+ grain: number,+): number {+ return strokeWidth * GRAIN_RATIO * grain;+}++const normalAt = (points: ScribblePoint[], i: number): ScribblePoint => {+ const before = points[i - 1] ?? points[i];+ const after = points[i + 1] ?? points[i];+ const tx = after.x - before.x;+ const ty = after.y - before.y;+ const length = Math.hypot(tx, ty) || 1;+ return { x: -ty / length, y: tx / length };+};++const curveSegments = (points: ScribblePoint[]): string =>+ points+ .slice(0, -1)+ .map((p1, i) => {+ const p0 = points[i - 1] ?? p1;+ const p2 = points[i + 1];+ const p3 = points[i + 2] ?? p2;+ return `C ${p1.x + (p2.x - p0.x) / 6} ${p1.y + (p2.y - p0.y) / 6}, ${p2.x - (p3.x - p1.x) / 6} ${p2.y - (p3.y - p1.y) / 6}, ${p2.x} ${p2.y}`;+ })+ .join(" ");++export function scribbleCirclePath(args: ScribbleCircleGeometry): {+ d: string;+ viewBox: string;+ marginX: number;+ marginY: number;+} {+ const pressure = args.pressure ?? 0.2;+ const grain = args.grain ?? 1;+ const progress = args.progress ?? 1;+ const spine = scribbleCirclePoints(args);+ const drawn = Math.max(2, Math.round(progress * (spine.length - 1)) + 1);++ const left: ScribblePoint[] = [];+ const right: ScribblePoint[] = [];+ for (let i = 0; i < drawn; i++) {+ const half = scribbleCircleHalfWidth(+ args.strokeWidth,+ pressure,+ i / (spine.length - 1),+ );+ const normal = normalAt(spine, i);+ left.push({+ x: spine[i].x + normal.x * half,+ y: spine[i].y + normal.y * half,+ });+ right.push({+ x: spine[i].x - normal.x * half,+ y: spine[i].y - normal.y * half,+ });+ }+ const back = right.slice().reverse();++ const reach =+ args.strokeWidth / 2 ++ scribbleCircleGrainScale(args.strokeWidth, grain) / 2;+ const marginX = reach + (args.width / 2) * NOISE + args.width * CENTRE;+ const marginY = reach + (args.height / 2) * NOISE + args.height * CENTRE;++ return {+ d: `M ${left[0].x} ${left[0].y} ${curveSegments(left)} L ${back[0].x} ${back[0].y} ${curveSegments(back)} Z`,+ viewBox: `${-marginX} ${-marginY} ${args.width + marginX * 2} ${args.height + marginY * 2}`,+ marginX,+ marginY,+ };+}++export function scribbleCircleProgress(+ frame: number,+ options?: { delay?: number; durationSteps?: number; step?: number },+): number {+ const delay = options?.delay ?? 0;+ const durationSteps = options?.durationSteps ?? 10;+ const step = options?.step ?? DEFAULT_STEP;+ return steppedRamp(frame, delay, delay + durationSteps * step, { step });+}++export interface ScribbleCircleProps {+ width: number;+ height: number;+ color?: string;+ strokeWidth?: number;+ pressure?: number;+ grain?: number;+ delay?: number;+ durationSteps?: number;+ laps?: number;+ seed?: string;+ step?: number;+}++export function ScribbleCircle({+ width,+ height,+ color = "#6f7f35",+ strokeWidth = 14,+ pressure = 0.2,+ grain = 1,+ delay = 0,+ durationSteps = 10,+ laps = 1.15,+ seed = "scribble",+ step = DEFAULT_STEP,+}: ScribbleCircleProps) {+ const frame = useCurrentFrame();+ const progress = scribbleCircleProgress(frame, {+ delay,+ durationSteps,+ step,+ });+ const { d, viewBox, marginX, marginY } = scribbleCirclePath({+ width,+ height,+ strokeWidth,+ laps,+ pressure,+ grain,+ seed,+ progress,+ });++ const grainScale = scribbleCircleGrainScale(strokeWidth, grain);+ const filterId = `scribble-grain-${Math.floor(hash01(seed) * 1e9)}`;++ return (+ <div+ style={{+ position: "relative",+ width,+ height,+ opacity: progress > 0 ? 1 : 0,+ }}+ >+ <svg+ width={width + marginX * 2}+ height={height + marginY * 2}+ viewBox={viewBox}+ style={{+ position: "absolute",+ left: -marginX,+ top: -marginY,+ display: "block",+ overflow: "visible",+ }}+ >+ <title>Scribbled circle</title>+ <defs>+ <filter+ id={filterId}+ x="-30%"+ y="-30%"+ width="160%"+ height="160%"+ filterUnits="objectBoundingBox"+ >+ <feTurbulence+ type="fractalNoise"+ baseFrequency="0.7"+ numOctaves={3}+ seed={Math.floor(hash01(`${seed}:grain`) * 1000)}+ result="grain"+ />+ <feDisplacementMap+ in="SourceGraphic"+ in2="grain"+ scale={grainScale}+ xChannelSelector="R"+ yChannelSelector="G"+ />+ </filter>+ </defs>+ <path+ d={d}+ fill={color}+ opacity={0.85}+ filter={grain > 0 ? `url(#${filterId})` : undefined}+ />+ </svg>+ </div>+ );+}