Skip to content

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

feat: streatch-in

kapishdimaa136a1e6868c
diff --git a/bun.lock b/bun.lock
index 8fa9a18e..a88a1769 100644
--- a/bun.lock
+++ b/bun.lock
@@ -33,6 +33,7 @@
"next": "16.3.0",
"next-themes": "^0.4.6",
"nuqs": "^2.8.9",
+ "opentype.js": "^2.0.0",
"p-limit": "^6.2.0",
"react": "19.2.4",
"react-dom": "19.2.4",
@@ -53,6 +54,7 @@
"@types/bun": "latest",
"@types/culori": "^4.0.0",
"@types/node": "^20",
+ "@types/opentype.js": "^1.3.10",
"@types/react": "^19",
"@types/react-dom": "^19",
"shadcn": "^4.11.0",
@@ -627,6 +629,8 @@
"@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-orrrD74MBUyK8jOAD/r0+lfa1I2MO6I+vAkmAWzMYbCcgrN4lCrmK52gRFQq/JRxfYPfonkr4b0jcY7Olqdqbw=="],
+ "@types/opentype.js": ["@types/[email protected]", "", {}, "sha512-F67EFyk6j02okHz5JCgata3ZRAcZi9GLnzmkHw/rzJq3OCc8/ZVdoKrxMTYjcQP6IYHGBz2cav1cpzkOkPiPCQ=="],
+
"@types/react": ["@types/[email protected]", "", { "dependencies": { "csstype": "^3.2.2" } }, "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w=="],
"@types/react-dom": ["@types/[email protected]", "", { "peerDependencies": { "@types/react": "^19.2.0" } }, "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ=="],
@@ -1321,6 +1325,8 @@
"open": ["[email protected]", "", { "dependencies": { "default-browser": "^5.4.0", "define-lazy-prop": "^3.0.0", "is-in-ssh": "^1.0.0", "is-inside-container": "^1.0.0", "powershell-utils": "^0.1.0", "wsl-utils": "^0.3.0" } }, "sha512-smsWv2LzFjP03xmvFoJ331ss6h+jixfA4UUV/Bsiyuu4YJPfN+FIQGOIiv4w9/+MoHkfkJ22UIaQWRVFRfH6Vw=="],
+ "opentype.js": ["[email protected]", "", { "bin": { "ot": "bin/ot" } }, "sha512-kCyjv6xdDY1W/jLWZ/L3QhhTlKUqDZMQ5+Jdlw12b3dXkKNpYBqqlMMj0YDQPShWFTMwgZI1hG14kN3XUDSg/A=="],
+
"ora": ["[email protected]", "", { "dependencies": { "chalk": "^5.3.0", "cli-cursor": "^5.0.0", "cli-spinners": "^2.9.2", "is-interactive": "^2.0.0", "is-unicode-supported": "^2.0.0", "log-symbols": "^6.0.0", "stdin-discarder": "^0.2.2", "string-width": "^7.2.0", "strip-ansi": "^7.1.0" } }, "sha512-weP+BZ8MVNnlCm8c0Qdc1WSWq4Qn7I+9CJGm7Qali6g44e/PUzbjNqJX5NJ9ljlNMosfJvg1fKEGILklK9cwnw=="],
"p-limit": ["[email protected]", "", { "dependencies": { "yocto-queue": "^1.1.1" } }, "sha512-kuUqqHNUqoIWp/c467RI4X6mmyuojY5jGutNU0wVTmEOOfcuwLqyMVoAi9MKi2Ak+5i9+nhmrK4ufZE8069kHA=="],
diff --git a/content/docs/typography/meta.json b/content/docs/typography/meta.json
index 8909dda8..796024ec 100644
--- a/content/docs/typography/meta.json
+++ b/content/docs/typography/meta.json
@@ -44,6 +44,7 @@
"gooey-morph",
"perspective-squeeze",
"extrude-pop",
- "chromatic-wave"
+ "chromatic-wave",
+ "stretch-in"
]
}
diff --git a/content/docs/typography/stretch-in.mdx b/content/docs/typography/stretch-in.mdx
new file mode 100644
index 00000000..528ea753
--- /dev/null
+++ b/content/docs/typography/stretch-in.mdx
@@ -0,0 +1,151 @@
+---
+title: Stretch In
+description: Letters fly in from off-canvas and smear horizontally on the way — a vertex-lag deformation, not a scale
+component: stretch-in
+vibe: playful
+length: 48
+useWhen:
+ - "A heavy display word needs a fast, physical entrance where the letterforms visibly deform — bars stretch long while stems keep their exact width."
+ - "You want per-letter rhythm: each letter enters on its own beat and snaps to rest crisp (tune `entryStagger` and `travelFrames`)."
+ - "Any text and any font should work — glyph contours are extracted from a real font file at runtime via `opentype.js`."
+avoidWhen:
+ - "The type is small or body-size — the smear reads at display sizes; use `per-character-rise` for smaller text."
+ - "You can't ship or reach a font file URL — the deformation needs real glyph outlines; use `short-slide-right` for a plain slide-in."
+ - "The look should be soft or blurred rather than elastic — use `soft-blur-in`."
+---
+
+<ComponentPreview name="stretch-in" />
+
+## Installation
+
+<InstallBlock name="stretch-in" />
+
+## Usage
+
+```tsx
+// src/Root.tsx
+import { Composition } from "remotion";
+import { StretchIn } from "@/components/remocn/stretch-in";
+
+const StretchInScene = () => <StretchIn text="REMOCN" />;
+
+export const RemotionRoot = () => (
+ <Composition
+ id="StretchIn"
+ component={StretchInScene}
+ durationInFrames={60}
+ fps={30}
+ width={1920}
+ height={1080}
+ />
+);
+```
+
+The letters are geometry, not text: glyph contours are parsed out of the font
+file (`opentype.js`), so the animation can reach inside the letterforms. Each
+vertex starts its travel late in proportion to how far it sits from the
+letter's leading edge — the leading edge lands first, the trailing edge catches
+up, and the letter smears without its stems changing width. Counters (the holes
+in P, O, R) go through the same deformation, so they never detach.
+
+`fontUrl` defaults to Anton served from Google Fonts' static CDN, so it works
+out of the box; point it at any `.ttf`/`.otf` URL to change the face. The
+render is held until the font file has loaded.
+
+## Props
+
+<PropsTable
+ rows={[
+ {
+ name: "text",
+ type: "string",
+ default: "\"REMOCN\"",
+ description: "The text to fly in — short display words read best",
+ },
+ {
+ name: "fontUrl",
+ type: "string",
+ default: "Anton (gstatic ttf)",
+ description: "URL of a .ttf/.otf font file the glyph outlines are parsed from",
+ },
+ {
+ name: "fontSize",
+ type: "number",
+ default: "510",
+ description: "Font size in comp pixels",
+ },
+ {
+ name: "letterSpacing",
+ type: "number",
+ default: "0",
+ description: "Extra spacing between letters in comp pixels",
+ },
+ {
+ name: "fill",
+ type: "string",
+ default: "\"#ffffff\"",
+ description: "Fill of the letterforms",
+ },
+ {
+ name: "strokeWidth / stroke",
+ type: "number / string",
+ default: "0 / \"#ffffff\"",
+ description: "Set `fill` to \"none\" and `strokeWidth` to 2 for the wireframe authoring view",
+ },
+ {
+ name: "width / height",
+ type: "number",
+ default: "1920 / 1080",
+ description: "Coordinate space of the composition. The word centers horizontally",
+ },
+ {
+ name: "baselineY",
+ type: "number",
+ default: "vertically centered",
+ description: "Baseline of the word in comp pixels",
+ },
+ {
+ name: "entryStart",
+ type: "number",
+ default: "0",
+ description: "Frame the first letter starts its travel",
+ },
+ {
+ name: "entryStagger",
+ type: "number",
+ default: "3",
+ description: "Frames between consecutive letters' entries",
+ },
+ {
+ name: "travelFrames",
+ type: "number",
+ default: "33",
+ description: "Frames one letter takes from off-canvas to rest",
+ },
+ {
+ name: "travelDistance",
+ type: "number",
+ default: "1500",
+ description: "How far off-canvas right the letters start, in comp pixels",
+ },
+ {
+ name: "vertexLagFrames",
+ type: "number",
+ default: "3.5",
+ description: "Frames the trailing edge lags the leading edge. This is the smear",
+ },
+ {
+ name: "curveSteps",
+ type: "number",
+ default: "8",
+ description: "Line segments each glyph curve is sampled into — every vertex must take part in the deformation",
+ },
+ {
+ name: "className",
+ type: "string",
+ description: "Optional className passed to the wrapper",
+ },
+ ]}
+/>
+
+Inspired by [Stretched Type In After Effects](https://www.youtube.com/watch?v=H_z6XJ-b9bE) by Ben Marriott.
diff --git a/package.json b/package.json
index 12104102..6038c911 100644
--- a/package.json
+++ b/package.json
@@ -52,6 +52,7 @@
"next": "16.3.0",
"next-themes": "^0.4.6",
"nuqs": "^2.8.9",
+ "opentype.js": "^2.0.0",
"p-limit": "^6.2.0",
"react": "19.2.4",
"react-dom": "19.2.4",
@@ -72,6 +73,7 @@
"@types/bun": "latest",
"@types/culori": "^4.0.0",
"@types/node": "^20",
+ "@types/opentype.js": "^1.3.10",
"@types/react": "^19",
"@types/react-dom": "^19",
"shadcn": "^4.11.0",
diff --git a/registry/__index__.tsx b/registry/__index__.tsx
index 57796ec2..1d4df436 100644
--- a/registry/__index__.tsx
+++ b/registry/__index__.tsx
@@ -318,6 +318,16 @@ const registry: Record<string, RegistryEntry> = {
(m) => m.gooeyMorphConfig,
),
},
+ "stretch-in": {
+ load: () =>
+ import("@/registry/remocn/stretch-in").then((m) => ({
+ default: m.StretchIn,
+ })),
+ loadConfig: () =>
+ import("@/registry/remocn/stretch-in/config").then(
+ (m) => m.stretchInConfig,
+ ),
+ },
"chromatic-wave": {
load: () =>
import("@/registry/remocn/chromatic-wave").then((m) => ({
diff --git a/registry/remocn/registry.json b/registry/remocn/registry.json
index 226fdcc2..33db9168 100644
--- a/registry/remocn/registry.json
+++ b/registry/remocn/registry.json
@@ -312,6 +312,20 @@
}
]
},
+ {
+ "name": "stretch-in",
+ "type": "registry:component",
+ "title": "Stretch In",
+ "description": "Letters fly in from off-canvas and smear horizontally on the way — a vertex-lag deformation, not a scale.",
+ "dependencies": ["remotion", "opentype.js"],
+ "files": [
+ {
+ "path": "stretch-in/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/stretch-in.tsx"
+ }
+ ]
+ },
{
"name": "strikethrough-replace",
"type": "registry:component",
diff --git a/registry/remocn/stretch-in/config.ts b/registry/remocn/stretch-in/config.ts
new file mode 100644
index 00000000..399822e8
--- /dev/null
+++ b/registry/remocn/stretch-in/config.ts
@@ -0,0 +1,47 @@
+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";
+
+export const stretchInConfig: ComponentConfig = {
+ componentName: "StretchIn",
+ importPath: "@/components/remocn/stretch-in",
+ controls: {
+ text: { type: "text", default: "REMOCN", label: "Text" },
+ fill: { type: "color", default: "#ffffff", label: "Fill" },
+ fontSize: {
+ type: "number",
+ default: 510,
+ min: 100,
+ max: 700,
+ step: 10,
+ label: "Font size",
+ },
+ entryStagger: {
+ type: "number",
+ default: 3,
+ min: 0,
+ max: 12,
+ step: 1,
+ label: "Letter stagger",
+ },
+ travelFrames: {
+ type: "number",
+ default: 33,
+ min: 4,
+ max: 40,
+ step: 1,
+ label: "Travel (frames)",
+ },
+ vertexLagFrames: {
+ type: "number",
+ default: 3.5,
+ min: 0,
+ max: 8,
+ step: 0.5,
+ label: "Smear lag (frames)",
+ },
+ },
+ durationInFrames: 60,
+ fps: FPS,
+ compositionWidth: W,
+ compositionHeight: H,
+ previewBackdrop: { type: "color", value: "#141318" },
+};
diff --git a/registry/remocn/stretch-in/index.tsx b/registry/remocn/stretch-in/index.tsx
new file mode 100644
index 00000000..e3550d50
--- /dev/null
+++ b/registry/remocn/stretch-in/index.tsx
@@ -0,0 +1,218 @@
+"use client";
+
+import { type Font, parse } from "opentype.js";
+import { useEffect, useMemo, useState } from "react";
+import {
+ continueRender,
+ delayRender,
+ Easing,
+ interpolate,
+ useCurrentFrame,
+} from "remotion";
+
+export interface StretchInProps {
+ className?: string;
+ width?: number;
+ height?: number;
+ text?: string;
+ fontUrl?: string;
+ fontSize?: number;
+ letterSpacing?: number;
+ baselineY?: number;
+ entryStart?: number;
+ entryStagger?: number;
+ travelFrames?: number;
+ travelDistance?: number;
+ vertexLagFrames?: number;
+ curveSteps?: number;
+ fill?: string;
+ strokeWidth?: number;
+ stroke?: string;
+}
+
+type Contour = [number, number][];
+
+function flattenPath(
+ commands: ReturnType<Font["getPath"]>["commands"],
+ steps: number,
+): Contour[] {
+ const contours: Contour[] = [];
+ let current: Contour = [];
+ let cx = 0;
+ let cy = 0;
+
+ for (const cmd of commands) {
+ if (cmd.type === "M") {
+ if (current.length > 0) contours.push(current);
+ current = [[cmd.x, cmd.y]];
+ cx = cmd.x;
+ cy = cmd.y;
+ } else if (cmd.type === "L") {
+ current.push([cmd.x, cmd.y]);
+ cx = cmd.x;
+ cy = cmd.y;
+ } else if (cmd.type === "Q") {
+ for (let i = 1; i <= steps; i++) {
+ const t = i / steps;
+ const mt = 1 - t;
+ current.push([
+ mt * mt * cx + 2 * mt * t * cmd.x1 + t * t * cmd.x,
+ mt * mt * cy + 2 * mt * t * cmd.y1 + t * t * cmd.y,
+ ]);
+ }
+ cx = cmd.x;
+ cy = cmd.y;
+ } else if (cmd.type === "C") {
+ for (let i = 1; i <= steps; i++) {
+ const t = i / steps;
+ const mt = 1 - t;
+ current.push([
+ mt * mt * mt * cx +
+ 3 * mt * mt * t * cmd.x1 +
+ 3 * mt * t * t * cmd.x2 +
+ t * t * t * cmd.x,
+ mt * mt * mt * cy +
+ 3 * mt * mt * t * cmd.y1 +
+ 3 * mt * t * t * cmd.y2 +
+ t * t * t * cmd.y,
+ ]);
+ }
+ cx = cmd.x;
+ cy = cmd.y;
+ } else if (cmd.type === "Z") {
+ if (current.length > 0) contours.push(current);
+ current = [];
+ }
+ }
+ if (current.length > 0) contours.push(current);
+ return contours;
+}
+
+export function StretchIn({
+ className,
+ width = 1920,
+ height = 1080,
+ text = "REMOCN",
+ fontUrl = "https://fonts.gstatic.com/s/anton/v27/1Ptgg87LROyAm0K0.ttf",
+ fontSize = 510,
+ letterSpacing = 0,
+ baselineY,
+ entryStart = 0,
+ entryStagger = 3,
+ travelFrames = 33,
+ travelDistance = 1500,
+ vertexLagFrames = 3.5,
+ curveSteps = 8,
+ fill = "#ffffff",
+ strokeWidth = 0,
+ stroke = "#ffffff",
+}: StretchInProps) {
+ const frame = useCurrentFrame();
+ const [font, setFont] = useState<Font | null>(null);
+
+ useEffect(() => {
+ const handle = delayRender("stretch-in: loading font");
+ let cancelled = false;
+ fetch(fontUrl)
+ .then((res) => res.arrayBuffer())
+ .then((buffer) => {
+ if (!cancelled) setFont(parse(buffer));
+ continueRender(handle);
+ })
+ .catch(() => {
+ continueRender(handle);
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, [fontUrl]);
+
+ const letters = useMemo(() => {
+ if (!font) return null;
+ const scale = fontSize / font.unitsPerEm;
+ const glyphs = font.stringToGlyphs(text);
+ let x = 0;
+ const items = glyphs.map((glyph, i) => {
+ if (i > 0) x += font.getKerningValue(glyphs[i - 1], glyph) * scale;
+ const left = x;
+ const advance = (glyph.advanceWidth ?? 0) * scale;
+ const contours = flattenPath(
+ glyph.getPath(x, 0, fontSize).commands,
+ curveSteps,
+ );
+ x += advance + letterSpacing;
+ return { left, width: advance, contours };
+ });
+ return { items, totalWidth: Math.max(0, x - letterSpacing) };
+ }, [font, text, fontSize, letterSpacing, curveSteps]);
+
+ if (!letters) return null;
+
+ const startX = (width - letters.totalWidth) / 2;
+ const resolvedBaseline = baselineY ?? (height + fontSize * 0.72) / 2;
+
+ return (
+ <div
+ className={className}
+ style={{ position: "absolute", inset: 0, overflow: "hidden" }}
+ >
+ <svg
+ width="100%"
+ height="100%"
+ viewBox={`0 0 ${width} ${height}`}
+ preserveAspectRatio="xMidYMid meet"
+ style={{ display: "block" }}
+ >
+ {letters.items.map((glyph, i) => {
+ const entry = entryStart + entryStagger * i;
+ const run = Math.max(1, travelFrames - vertexLagFrames);
+
+ const d = glyph.contours
+ .map((contour) => {
+ const pts = contour.map(([px, py]) => {
+ const u =
+ glyph.width === 0
+ ? 0
+ : Math.min(1, Math.max(0, (px - glyph.left) / glyph.width));
+ const start = entry + u * vertexLagFrames;
+ const remaining = interpolate(
+ frame,
+ [start, start + run],
+ [1, 0],
+ {
+ extrapolateLeft: "clamp",
+ extrapolateRight: "clamp",
+ easing: Easing.bezier(0.2, 0.9, 0.25, 1),
+ },
+ );
+ return [
+ startX + px + travelDistance * remaining,
+ resolvedBaseline + py,
+ ];
+ });
+ return (
+ `M${pts[0][0].toFixed(2)},${pts[0][1].toFixed(2)}` +
+ pts
+ .slice(1)
+ .map((p) => `L${p[0].toFixed(2)},${p[1].toFixed(2)}`)
+ .join("") +
+ "Z"
+ );
+ })
+ .join(" ");
+
+ return (
+ <path
+ key={`${i}-${glyph.left}`}
+ d={d}
+ fill={fill}
+ fillRule="evenodd"
+ stroke={strokeWidth > 0 ? stroke : "none"}
+ strokeWidth={strokeWidth}
+ />
+ );
+ })}
+ </svg>
+ </div>
+ );
+}