Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
feat: perspective squeeze
kapishdima8c96ce4bb04f
diff --git a/content/docs/typography/meta.json b/content/docs/typography/meta.jsonindex 5cc42124..9d4d1130 100644--- a/content/docs/typography/meta.json+++ b/content/docs/typography/meta.json@@ -41,6 +41,7 @@"perspective-marquee","matrix-decode","rgb-glitch-text",- "gooey-morph"+ "gooey-morph",+ "perspective-squeeze"]}diff --git a/content/docs/typography/perspective-squeeze.mdx b/content/docs/typography/perspective-squeeze.mdxnew file mode 100644index 00000000..e8bd804b--- /dev/null+++ b/content/docs/typography/perspective-squeeze.mdx@@ -0,0 +1,160 @@+---+title: Perspective Squeeze+description: Two lines of heavy type endlessly trade height while corner-pinned perspective bends the flat stack into receding planes+component: perspective-squeeze+vibe: playful+length: 225+useWhen:+ - "A looping hold — an outro, a background title, a stream screen — needs constant, hypnotic typographic motion (the 225-frame track ends where it starts)."+ - "You want an editorial poster feel: heavy condensed type crushed and stretched like a print layout come alive."+ - "Two short words can share the frame — the two lines are forced to the same width, so pairs like a brand name and a tagline work best."+avoidWhen:+ - "You need an entrance or a reveal — this is a sustained loop, the type is fully visible from frame 0; use `kinetic-warp` for a punchy display moment."+ - "The copy must stay easily readable throughout — lines spend most of the loop crushed to a third of their height."+ - "You only need the vertical stretch without the perspective bend — drop-in alternatives like `per-character-rise` keep the type flat."+---++<ComponentPreview name="perspective-squeeze" />++## Installation++<InstallBlock name="perspective-squeeze" />++## Usage++```tsx+// src/Root.tsx+import { Composition } from "remotion";+import { PerspectiveSqueeze } from "@/components/remocn/perspective-squeeze";++const PerspectiveSqueezeScene = () => (+ <PerspectiveSqueeze+ upperText="REMOCN"+ lowerText="BEST"+ upperFontFamily="Impact, 'Arial Narrow', sans-serif"+ lowerFontFamily="Impact, 'Arial Narrow', sans-serif"+ />+);++export const RemotionRoot = () => (+ <Composition+ id="PerspectiveSqueeze"+ component={PerspectiveSqueezeScene}+ durationInFrames={225}+ fps={30}+ width={1920}+ height={1080}+ />+);+```++Both lines are forced to exactly the block's width via SVG `textLength`, so any+pair of words lines up flush. The vertical squeeze scales each line about its+own baseline, and the layout re-derives from the scaled heights every frame —+the gap between the lines never changes. The perspective is a true projective+corner-pin (`matrix3d`), interpolated on the corners, so straight lines stay+straight while parallels converge.++## Props++<PropsTable+ rows={[+ {+ name: "upperText / lowerText",+ type: "string",+ default: "\"REMOCN\" / \"BEST\"",+ description: "The two lines. Both are stretched to the block's full width",+ },+ {+ name: "upperFontFamily / lowerFontFamily",+ type: "string",+ default: "\"sans-serif\"",+ description: "Font of each line — heavy condensed faces read best",+ },+ {+ name: "upperFontSize / lowerFontSize",+ type: "number",+ default: "603 / 124",+ description: "Font size of each line in block pixels",+ },+ {+ name: "fill",+ type: "string",+ default: "\"#ffffff\"",+ description: "Fill color of the type",+ },+ {+ name: "width / height",+ type: "number",+ default: "1920 / 1080",+ description: "Design space all positions are authored in. The stage scales to fit the actual composition, centered",+ },+ {+ name: "blockWidth / blockHeight",+ type: "number",+ default: "990 / 546",+ description: "Size of the cropped block the corner pin acts on — cropping before pinning keeps the corners near the artwork",+ },+ {+ name: "upperBlockPosition / lowerBlockPosition",+ type: "[number, number]",+ default: "[960, 314] / [960, 860]",+ description: "Center of each pinned copy in comp pixels",+ },+ {+ name: "cornerKeyframes",+ type: "number[]",+ default: "[0, 45, 70]",+ description: "Frames at which the corner poses land",+ },+ {+ name: "upperCornersMid / upperCornersEnd",+ type: "Corners",+ default: "tutorial poses",+ description: "Corner poses of the upper copy, as four `[x, y]` points in block space",+ },+ {+ name: "lowerCornersMid / lowerCornersEnd",+ type: "Corners",+ default: "tutorial poses",+ description: "Corner poses of the lower copy",+ },+ {+ name: "cornersRest",+ type: "Corners",+ default: "the block's own rectangle",+ description: "Identity pose every departure is measured from",+ },+ {+ name: "scaleKeyframes",+ type: "number[]",+ default: "[0, 60, 118, 161, 196, 225]",+ description: "Frames of the squish track. The last keyframe repeats the first, closing the loop",+ },+ {+ name: "upperScaleY / lowerScaleY",+ type: "number[]",+ default: "tutorial tracks",+ description: "Vertical scale percentages at each keyframe — the lines trade height in opposition",+ },+ {+ name: "capRatio",+ type: "number",+ default: "0.65",+ description: "Cap height as a fraction of em, used to stack the two lines",+ },+ {+ name: "lineGap",+ type: "number",+ default: "50",+ description: "Constant gap between the lines in block pixels",+ },+ {+ name: "className",+ type: "string",+ description: "Optional className passed to the wrapper",+ },+ ]}+/>++Inspired by [5 Clean Text Animations](https://www.youtube.com/watch?v=Nmi7cE2wT54) by Mapal.diff --git a/registry/__index__.tsx b/registry/__index__.tsxindex de5579b1..c9f31b0e 100644--- a/registry/__index__.tsx+++ b/registry/__index__.tsx@@ -318,6 +318,16 @@ const registry: Record<string, RegistryEntry> = {(m) => m.gooeyMorphConfig,),},+ "perspective-squeeze": {+ load: () =>+ import("@/registry/remocn/perspective-squeeze").then((m) => ({+ default: m.PerspectiveSqueeze,+ })),+ loadConfig: () =>+ import("@/registry/remocn/perspective-squeeze/config").then(+ (m) => m.perspectiveSqueezeConfig,+ ),+ },"kinetic-warp": {load: () =>import("@/registry/remocn/kinetic-warp").then((m) => ({diff --git a/registry/remocn/perspective-squeeze/config.ts b/registry/remocn/perspective-squeeze/config.tsnew file mode 100644index 00000000..48591ed7--- /dev/null+++ b/registry/remocn/perspective-squeeze/config.ts@@ -0,0 +1,34 @@+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const perspectiveSqueezeConfig: ComponentConfig = {+ componentName: "PerspectiveSqueeze",+ importPath: "@/components/remocn/perspective-squeeze",+ controls: {+ upperText: { type: "text", default: "REMOCN", label: "Upper line" },+ lowerText: { type: "text", default: "BEST", label: "Lower line" },+ fill: { type: "color", default: "#f2f2f2", label: "Fill" },+ upperFontFamily: {+ type: "text",+ default: "Impact, 'Arial Narrow', sans-serif",+ label: "Upper font",+ },+ lowerFontFamily: {+ type: "text",+ default: "Impact, 'Arial Narrow', sans-serif",+ label: "Lower font",+ },+ lineGap: {+ type: "number",+ default: 50,+ min: 0,+ max: 120,+ step: 2,+ label: "Line gap",+ },+ },+ durationInFrames: 225,+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#141318" },+};diff --git a/registry/remocn/perspective-squeeze/index.tsx b/registry/remocn/perspective-squeeze/index.tsxnew file mode 100644index 00000000..e4ece79b--- /dev/null+++ b/registry/remocn/perspective-squeeze/index.tsx@@ -0,0 +1,259 @@+"use client";++import { Easing, interpolate, useCurrentFrame, useVideoConfig } from "remotion";++type Corners = [+ [number, number],+ [number, number],+ [number, number],+ [number, number],+];++export interface PerspectiveSqueezeProps {+ className?: string;+ width?: number;+ height?: number;+ blockWidth?: number;+ blockHeight?: number;+ lowerBlockPosition?: [number, number];+ upperBlockPosition?: [number, number];+ cornersRest?: Corners;+ cornerKeyframes?: number[];+ upperCornersMid?: Corners;+ upperCornersEnd?: Corners;+ lowerCornersMid?: Corners;+ lowerCornersEnd?: Corners;+ upperText?: string;+ lowerText?: string;+ upperFontFamily?: string;+ lowerFontFamily?: string;+ upperFontSize?: number;+ lowerFontSize?: number;+ capRatio?: number;+ lineGap?: number;+ scaleKeyframes?: number[];+ lowerScaleY?: number[];+ upperScaleY?: number[];+ fill?: string;+}++function cornerPinMatrix(src: Corners, dst: Corners): string {+ const a: number[][] = [];+ const rhs: number[] = [];++ for (let i = 0; i < 4; i++) {+ const [x, y] = src[i];+ const [u, v] = dst[i];+ a.push([x, y, 1, 0, 0, 0, -u * x, -u * y]);+ rhs.push(u);+ a.push([0, 0, 0, x, y, 1, -v * x, -v * y]);+ rhs.push(v);+ }++ const n = 8;+ for (let col = 0; col < n; col++) {+ let pivot = col;+ for (let r = col + 1; r < n; r++) {+ if (Math.abs(a[r][col]) > Math.abs(a[pivot][col])) pivot = r;+ }+ [a[col], a[pivot]] = [a[pivot], a[col]];+ [rhs[col], rhs[pivot]] = [rhs[pivot], rhs[col]];++ const d = a[col][col];+ if (Math.abs(d) < 1e-12) continue;+ for (let c = col; c < n; c++) a[col][c] /= d;+ rhs[col] /= d;++ for (let r = 0; r < n; r++) {+ if (r === col) continue;+ const f = a[r][col];+ if (f === 0) continue;+ for (let c = col; c < n; c++) a[r][c] -= f * a[col][c];+ rhs[r] -= f * rhs[col];+ }+ }++ const [m0, m1, m2, m3, m4, m5, m6, m7] = rhs;+ return `matrix3d(${m0}, ${m3}, 0, ${m6}, ${m1}, ${m4}, 0, ${m7}, 0, 0, 1, 0, ${m2}, ${m5}, 0, 1)`;+}++function lerpCorners(from: Corners, to: Corners, t: number): Corners {+ return from.map((p, i) => [+ p[0] + (to[i][0] - p[0]) * t,+ p[1] + (to[i][1] - p[1]) * t,+ ]) as Corners;+}++export function PerspectiveSqueeze({+ className,+ width = 1920,+ height = 1080,+ blockWidth = 990,+ blockHeight = 546,+ lowerBlockPosition = [960, 860],+ upperBlockPosition = [960, 314],+ cornersRest = [+ [0, 0],+ [990, 0],+ [0, 546],+ [990, 546],+ ],+ cornerKeyframes = [0, 45, 70],+ upperCornersMid = [+ [0, -326],+ [990, 0],+ [0, 546],+ [990, 546],+ ],+ upperCornersEnd = [+ [0, 352],+ [990, -428],+ [460, 546],+ [990, 546],+ ],+ lowerCornersMid = [+ [0, 0],+ [990, 0],+ [0, 225],+ [990, 546],+ ],+ lowerCornersEnd = [+ [0, 0],+ [990, 0],+ [0, 897],+ [990, 116],+ ],+ upperText = "REMOCN",+ lowerText = "BEST",+ upperFontFamily = "sans-serif",+ lowerFontFamily = "sans-serif",+ upperFontSize = 603,+ lowerFontSize = 124,+ capRatio = 0.65,+ lineGap = 50,+ scaleKeyframes = [0, 60, 118, 161, 196, 225],+ lowerScaleY = [100, 384.8, 270, 330, 150, 100],+ upperScaleY = [100, 35.8, 64, 45, 110, 100],+ fill = "#ffffff",+}: PerspectiveSqueezeProps) {+ const frame = useCurrentFrame();+ const { width: compWidth, height: compHeight } = useVideoConfig();+ const stageScale = Math.min(compWidth / width, compHeight / height);++ const squishEase = Easing.bezier(0.6, 0, 0.4, 1);++ const scaleAt = (track: number[]) =>+ interpolate(frame, scaleKeyframes, track, {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ easing: squishEase,+ }) / 100;++ const cornersAt = (mid: Corners, end: Corners): Corners => {+ const [k0, k1, k2] = cornerKeyframes;+ if (frame <= k0) return cornersRest;+ if (frame >= k2) return end;+ if (frame <= k1) {+ return lerpCorners(+ cornersRest,+ mid,+ squishEase((frame - k0) / Math.max(k1 - k0, 1)),+ );+ }+ return lerpCorners(+ mid,+ end,+ squishEase((frame - k1) / Math.max(k2 - k1, 1)),+ );+ };++ const upperScale = scaleAt(upperScaleY);+ const lowerScale = scaleAt(lowerScaleY);++ const upperBoxHeight = upperFontSize * capRatio * upperScale;+ const lowerBoxHeight = lowerFontSize * capRatio * lowerScale;+ const stackTop =+ (blockHeight - (upperBoxHeight + lineGap + lowerBoxHeight)) / 2;+ const upperBaseline = stackTop + upperBoxHeight;+ const lowerBaseline = upperBaseline + lineGap + lowerBoxHeight;++ const line = (+ text: string,+ family: string,+ size: number,+ baseline: number,+ scale: number,+ ) => (+ <text+ x={0}+ y={baseline}+ textLength={blockWidth}+ lengthAdjust="spacingAndGlyphs"+ fontFamily={family}+ fontSize={size}+ fontWeight={800}+ fill={fill}+ transform={`matrix(1, 0, 0, ${scale}, 0, ${baseline * (1 - scale)})`}+ >+ {text}+ </text>+ );++ const block = (corners: Corners, position: [number, number]) => (+ <div+ style={{+ position: "absolute",+ left: position[0] - blockWidth / 2,+ top: position[1] - blockHeight / 2,+ width: blockWidth,+ height: blockHeight,+ transformOrigin: "0 0",+ transform: cornerPinMatrix(cornersRest, corners),+ }}+ >+ <svg+ width={blockWidth}+ height={blockHeight}+ viewBox={`0 0 ${blockWidth} ${blockHeight}`}+ style={{ display: "block", overflow: "hidden" }}+ >+ {line(+ upperText,+ upperFontFamily,+ upperFontSize,+ upperBaseline,+ upperScale,+ )}+ {line(+ lowerText,+ lowerFontFamily,+ lowerFontSize,+ lowerBaseline,+ lowerScale,+ )}+ </svg>+ </div>+ );++ return (+ <div+ className={className}+ style={{ position: "absolute", inset: 0, overflow: "hidden" }}+ >+ <div+ style={{+ position: "absolute",+ left: (compWidth - width * stageScale) / 2,+ top: (compHeight - height * stageScale) / 2,+ width,+ height,+ transform: `scale(${stageScale})`,+ transformOrigin: "0 0",+ }}+ >+ {block(cornersAt(upperCornersMid, upperCornersEnd), upperBlockPosition)}+ {block(cornersAt(lowerCornersMid, lowerCornersEnd), lowerBlockPosition)}+ </div>+ </div>+ );+}diff --git a/registry/remocn/registry.json b/registry/remocn/registry.jsonindex 6b1d17cc..11223799 100644--- a/registry/remocn/registry.json+++ b/registry/remocn/registry.json@@ -1036,6 +1036,20 @@}]},+ {+ "name": "perspective-squeeze",+ "type": "registry:component",+ "title": "Perspective Squeeze",+ "description": "Two lines of heavy type endlessly trade height while corner-pinned perspective bends the flat stack into receding planes.",+ "dependencies": ["remotion"],+ "files": [+ {+ "path": "perspective-squeeze/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/perspective-squeeze.tsx"+ }+ ]+ },{"name": "ecosystem-constellation","type": "registry:component",