Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
{
"type": "remotion-element",
"version": 1,
"element": {
"assets": [],
"dependencies": [
{
"name": "@remotion/google-fonts",
"version": null
}
],
"dimensions": null,
"displayName": "Stripe Mask",
"initialProps": null,
"slug": "stripe-mask",
"sourceCode": "import { loadFont } from \"@remotion/google-fonts/Oswald\";\nimport { forwardRef, useId, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { AbsoluteFill, Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst { fontFamily: display } = loadFont(\"normal\", {\n weights: [\"500\"],\n subsets: [\"latin\"],\n});\n\ninterface StripeMaskProps {\n /** Headline. Breaks into a new line after each sentence. */\n title?: string;\n /** Stripe slant in degrees, leaning right. */\n slant?: number;\n accent?: string;\n theme?: \"dark\" | \"light\";\n speed?: number;\n}\n\n// Oswald 500, per 1000 em, chars 32–126 (harfbuzz): advance, left and right side bearing.\nconst ADV = [\n 243, 233, 315, 511, 488, 950, 587, 149, 319, 295, 411, 433, 213, 314, 217,\n 396, 534, 382, 497, 496, 504, 493, 521, 413, 510, 521, 239, 251, 386, 429,\n 386, 483, 928, 522, 557, 540, 557, 428, 413, 559, 586, 275, 326, 532, 421,\n 683, 545, 563, 527, 564, 561, 494, 430, 566, 516, 712, 499, 487, 425, 336,\n 396, 317, 460, 356, 293, 435, 477, 440, 473, 446, 304, 472, 478, 248, 250,\n 471, 252, 718, 474, 455, 476, 474, 353, 400, 330, 473, 404, 593, 416, 421,\n 370, 338, 251, 351, 465,\n];\nconst LSB = [\n 0, 48, 23, 40, 30, 41, 48, 23, 67, 32, 42, 26, 42, 36, 47, 36, 56, 26, 41, 39,\n 32, 45, 55, 21, 44, 41, 64, 63, 41, 59, 56, 40, 52, 20, 61, 49, 61, 61, 61,\n 49, 63, 65, 10, 61, 61, 59, 61, 49, 61, 49, 61, 41, 13, 55, 22, 31, 10, 10,\n 33, 57, 36, 23, 32, 0, 49, 22, 53, 41, 42, 41, 18, 23, 54, 56, -18, 53, 61,\n 52, 52, 41, 52, 43, 55, 22, 18, 47, 12, 24, 10, 7, 34, 44, 66, 40, 38,\n];\nconst RSB = [\n 243, 48, 12, 38, 31, 41, 48, 11, 33, 44, 20, 26, 38, 36, 38, 36, 56, 93, 32,\n 35, 17, 32, 43, 37, 43, 56, 45, 55, 46, 59, 31, 38, 32, 20, 35, 42, 48, 25,\n 19, 52, 63, 64, 62, 6, 16, 59, 62, 48, 21, 49, 38, 26, 13, 55, 22, 31, 9, 10,\n 24, 43, 36, 57, 31, 0, 48, 37, 42, 37, 51, 40, 8, -14, 48, 56, 51, 1, 56, 49,\n 48, 41, 42, 51, 15, 22, 23, 53, 11, 25, 5, 11, 25, 27, 67, 44, 34,\n];\nconst KERN = new Map(\n [\n \"&T-24 *J-18 *X-12 ,B-6 ,C-12 ,D-6 ,E-6 ,F-6 ,G-12 ,H-6 ,I-6 ,K-6 ,L-6\",\n \",N-6 ,O-12 ,P-6 ,Q-12 ,R-6 ,T-56 ,U-12 ,V-46 ,W-38 ,Y-60 ,t-18 ,v-10\",\n \",w-12 ,y-18 -T-30 -V-24 -W-6 -X-12 -Y-30 .B-6 .C-12 .D-6 .E-6 .F-6\",\n \".G-12 .H-6 .I-6 .K-6 .L-6 .N-6 .O-12 .P-6 .Q-12 .R-6 .T-56 .U-12 .V-46\",\n \".W-38 .Y-60 .t-18 .v-10 .w-12 .y-18 /C-12 /G-12 /O-12 /Q-12 /S-18 /c-36\",\n \"/d-36 /e-36 /o-36 /q-36 07-6 0X-6 0Y-12 17-8 24-12 41-12 47-14 57-12\",\n \"61-6 62-6 67-10 69-9 6Y-6 74-28 87-13 8Y-6 97-16 :T-66 :V-12 :W-18\",\n \":Y-46 ;T-66 ;V-12 ;W-18 ;Y-46 AC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 kV-8 kW-6 kY-32 kc-11 kd-11 ke-11 kg-6 ko-11 kq-11\",\n \"ks-6 lT16 lV8 lW8 lY12 mT-54 mV-30 mW-16 mY-52 nT-54 nV-30 nW-16 nY-52\",\n \"oT-58 oV-36 oW-20 oY-60 ox-8 pT-58 pV-36 pW-20 pY-60 px-8 qT-50 qV-14\",\n \"qY-37 r,-84 r.-84 rA-28 rJ-18 rT-48 rX-24 rY-22 rZ-20 ra-13 rg-8 rq-16\",\n \"sT-55 sV-32 sX-6 sY-57 tT-16 tV-13 tY-18 tg-6 uT-53 uV-20 uY-48 v,-29\",\n \"v.-30 vA-22 vJ-18 vT-62 vV-20 vW-6 vX-24 vY-36 vZ-20 va-9 vg-8 w,-17\",\n \"w.-20 wA-16 wJ-30 wT-58 wV-20 wW-6 wX-26 wY-36 wZ-12 wa-10 wg-6 xT-46\",\n \"xV-24 xW-6 xY-40 xc-10 xd-10 xe-10 xo-10 xq-10 y,-33 y.-33 yA-22 yJ-18\",\n \"yT-62 yV-20 yW-6 yX-24 yY-36 yZ-20 ya-9 yg-8 zT-46 zV-17 zY-32 zc-6\",\n \"zd-6 ze-6 zg-6 zo-6 zq-6\",\n ]\n .join(\" \")\n .split(\" \")\n .map((p) => [p.slice(0, 2), Number(p.slice(2)) / 1000] as const),\n);\nconst CAP = 0.81;\nconst DESC = 0.19;\nconst TRACK = -0.008;\nconst PITCH = 1.0;\n\n// Beat sheet (30fps, speed 1):\n// 0–40 three accent bars sweep in from the left, staggered, decelerating;\n// the headline drifts the other way and only shows inside the bars,\n// so its letters slide through them\n// 44–60 the bars widen and merge into one slab: the full headline on accent\n// 60–70 hold on the slab\n// 70–96 the slab breaks back into three thin bars that slide left and park\n// as a mark beside the headline, wiping it to ink on the stage\n// 96– poster hold\nconst SWEEP_AT = -6;\nconst SWEEP_LEN = 46;\nconst SWEEP_STAGGER = 5;\nconst DRIFT_LEN = 52;\nconst WIDEN_AT = 44;\nconst WIDEN_LEN = 13;\nconst WIDEN_STAGGER = 2;\nconst RETRACT_AT = 70;\nconst RETRACT_LEN = 24;\nconst RETRACT_STAGGER = 3;\n\nconst SWEEP = Easing.bezier(0.2, 0.8, 0.3, 1);\nconst DRIFT = Easing.bezier(0.3, 0.55, 0.35, 1);\nconst WIDEN = Easing.bezier(0.7, 0, 0.25, 1);\nconst MOVE = Easing.bezier(0.7, 0, 0.2, 1);\nconst THIN = Easing.bezier(0.3, 0.9, 0.3, 1);\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst THEMES = {\n dark: { stage: \"#0A0A0B\", ink: \"#F3F2EF\", onAccent: \"#F3F2EF\" },\n light: { stage: \"#F5F4F0\", ink: \"#121214\", onAccent: \"#F5F4F0\" },\n} as const;\n\n// gradients.sh \"beam\" (bg #02030a): deep indigo at the top of the frame,\n// through the accent, to pale blue at the bottom. It lives in frame space, so\n// the bars read as windows onto one beam of light. The light stage drops the\n// palest stop so the bars keep their edge on off-white.\nconst BEAM = [\"#1a1660\", \"#8fb4ff\", \"#f4f7ff\"] as const;\n\nfunction code(ch: string) {\n const c = ch.charCodeAt(0);\n if (c >= 32 && c < 127) return c - 32;\n if (ch === \"’\" || ch === \"‘\") return 7;\n return 46;\n}\n\n/** Advance and ink box of a line, in em, with tracking. */\nfunction measure(text: string) {\n let adv = 0;\n for (let i = 0; i < text.length; i++) {\n adv += ADV[code(text[i])] / 1000;\n if (i > 0) adv += (KERN.get(text[i - 1] + text[i]) ?? 0) + TRACK;\n }\n const lsb = LSB[code(text[0] ?? \" \")] / 1000;\n const rsb = RSB[code(text[text.length - 1] ?? \" \")] / 1000;\n return { lsb, ink: Math.max(0.2, adv - lsb - rsb) };\n}\n\n/** A slanted bar: center and width measured on the headline's center line. */\ninterface Bar {\n c: number;\n w: number;\n top: number;\n bottom: number;\n}\n\nconst mix = (a: number, b: number, p: number) => a + (b - a) * p;\n\nfunction StripeMaskBase({\n title = \"Faster. Every frame.\",\n slant = 18,\n accent = \"#3B5BFD\",\n theme = \"dark\",\n speed = 1,\n}: StripeMaskProps) {\n const t = useCurrentFrame() * speed;\n const { width: W, height: H } = useVideoConfig();\n const c = THEMES[theme];\n const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n const clipId = `sm${uid}`;\n const beamId = `smb${uid}`;\n\n const lines = title\n .split(/(?<=[.!?])\\s+/)\n .map((s) => s.trim())\n .filter(Boolean);\n const metrics = lines.map(measure);\n const k = Math.tan((slant * Math.PI) / 180);\n\n // Lockup in em: mark, gap, headline block.\n const blockEm = CAP + (lines.length - 1) * PITCH;\n const textEm = Math.max(...metrics.map((m) => m.ink));\n const stripeEm = 0.11;\n const stripeGapEm = 0.08;\n const markEm = 3 * stripeEm + 2 * stripeGapEm + blockEm * k;\n const gapEm = 0.3;\n const lockEm = markEm + gapEm + textEm;\n const fs = Math.min((0.8 * W) / lockEm, (0.52 * H) / (blockEm + DESC));\n\n const x0 = (W - lockEm * fs) / 2;\n const tx = x0 + (markEm + gapEm) * fs;\n const textW = textEm * fs;\n const blockTop = (H - blockEm * fs) / 2 - 0.02 * H;\n const blockBottom = blockTop + blockEm * fs;\n const yc = (blockTop + blockBottom) / 2;\n const baselines = lines.map((_, i) => blockTop + (CAP + i * PITCH) * fs);\n\n // A bar leans right toward the top; x offset of its edges at height y.\n const shift = (y: number) => (yc - y) * k;\n\n const fullTop = -0.08 * H;\n const fullBottom = 1.08 * H;\n const pad = 0.06 * fs;\n const slabL = tx - pad - shift(blockTop - pad);\n const slabR = tx + textW + pad - shift(blockBottom + DESC * fs + pad);\n const third = (slabR - slabL) / 3;\n const sw = stripeEm * fs;\n const sg = stripeGapEm * fs;\n\n const bars: Bar[] = [0, 1, 2].map((i) => {\n const restC = tx + textW * (1 / 6 + i / 3);\n const restW = textW * 0.17;\n const mergedC = slabL + (i + 0.5) * third;\n // Overlap generously so no hairline seams survive the merge.\n const mergedW = third * 1.2;\n const markC = x0 + i * (sw + sg) + sw / 2 - shift(blockBottom);\n\n // The rightmost bar leads the sweep; the leftmost leads the retreat, so\n // the bars spread apart on the way back and never overlap.\n const lead = 2 - i;\n const sweepFrom = SWEEP_AT + lead * SWEEP_STAGGER;\n const sweep = SWEEP(\n interpolate(t, [sweepFrom, sweepFrom + SWEEP_LEN], [0, 1], CLAMP),\n );\n const widenFrom = WIDEN_AT + Math.abs(i - 1) * WIDEN_STAGGER;\n const widen = WIDEN(\n interpolate(t, [widenFrom, widenFrom + WIDEN_LEN], [0, 1], CLAMP),\n );\n const retractFrom = RETRACT_AT + i * RETRACT_STAGGER;\n const local = interpolate(\n t,\n [retractFrom, retractFrom + RETRACT_LEN],\n [0, 1],\n CLAMP,\n );\n const move = MOVE(local);\n // Bars thin out ahead of the move, so the slab splits back into three.\n const thin = THIN(Math.min(1, local / 0.7));\n\n const center = mix(mix(restC, mergedC, widen), markC, move);\n return {\n c: center - (1 - sweep) * 1.15 * W,\n w: mix(mix(restW, mergedW, widen), sw, thin),\n top: mix(fullTop, blockTop, move),\n bottom: mix(fullBottom, blockBottom, move),\n };\n });\n\n const points = (b: Bar) =>\n [\n [b.c - b.w / 2 + shift(b.top), b.top],\n [b.c + b.w / 2 + shift(b.top), b.top],\n [b.c + b.w / 2 + shift(b.bottom), b.bottom],\n [b.c - b.w / 2 + shift(b.bottom), b.bottom],\n ]\n .map(([x, y]) => `${x.toFixed(2)},${y.toFixed(2)}`)\n .join(\" \");\n\n const drift =\n (1 -\n DRIFT(interpolate(t, [SWEEP_AT, SWEEP_AT + DRIFT_LEN], [0, 1], CLAMP))) *\n 0.5 *\n W;\n // The beam rises a few percent of the frame over the shot.\n const beamDrift = interpolate(t, [0, 120], [0, 0.06 * H], CLAMP);\n // The ink copy may only appear once the slab hides it completely.\n const merged = t >= WIDEN_AT + WIDEN_STAGGER + WIDEN_LEN;\n\n const headline = (fill: string, dx: number) =>\n lines.map((line, i) => (\n <text\n key={`${line}-${i}`}\n x={tx - metrics[i].lsb * fs + dx}\n y={baselines[i]}\n fill={fill}\n fontFamily={display}\n fontWeight={500}\n fontSize={fs}\n style={{ letterSpacing: `${TRACK}em`, fontKerning: \"normal\" }}\n >\n {line}\n </text>\n ));\n\n return (\n <AbsoluteFill style={{ background: c.stage }}>\n <svg\n width={W}\n height={H}\n viewBox={`0 0 ${W} ${H}`}\n style={{ position: \"absolute\", inset: 0 }}\n aria-label={title}\n role=\"img\"\n >\n <defs>\n <linearGradient\n id={beamId}\n gradientUnits=\"userSpaceOnUse\"\n x1={0}\n y1={fullTop - beamDrift}\n x2={0.12 * W}\n y2={fullBottom - beamDrift}\n >\n <stop offset=\"0\" stopColor={BEAM[0]} />\n <stop offset=\"0.62\" stopColor={accent} />\n <stop offset=\"0.94\" stopColor={BEAM[1]} />\n {theme === \"dark\" ? <stop offset=\"1\" stopColor={BEAM[2]} /> : null}\n </linearGradient>\n <clipPath id={clipId}>\n {bars.map((b, i) => (\n <polygon key={[\"a\", \"b\", \"c\"][i]} points={points(b)} />\n ))}\n </clipPath>\n </defs>\n {merged ? <g>{headline(c.ink, 0)}</g> : null}\n {bars.map((b, i) => (\n <polygon\n key={[\"a\", \"b\", \"c\"][i]}\n points={points(b)}\n fill={`url(#${beamId})`}\n />\n ))}\n <g clipPath={`url(#${clipId})`}>{headline(c.onAccent, drift)}</g>\n </svg>\n </AbsoluteFill>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n theme: {\n type: \"enum\",\n default: \"dark\",\n variants: {\n dark: {},\n light: {},\n },\n description: \"Theme\",\n },\n accent: {\n type: \"color\",\n default: \"#3B5BFD\",\n description: \"Accent\",\n },\n title: {\n type: \"text-content\",\n default: \"Faster. Every frame.\",\n description: \"Title\",\n },\n slant: {\n type: \"number\",\n default: 18,\n min: 0,\n max: 54,\n step: 1,\n description: \"Slant\",\n hiddenFromList: false,\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"theme\",\"accent\",\"title\",\"slant\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n theme: \"dark\",\n accent: \"#3B5BFD\",\n title: \"Faster. Every frame.\",\n slant: 18,\n speed: 1,\n};\n\ntype StripeMaskElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof StripeMaskBase>;\n\nconst StripeMaskInner = forwardRef<\n HTMLDivElement,\n StripeMaskElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<StripeMask>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <StripeMaskBase\n {...(componentProps as unknown as ComponentProps<typeof StripeMaskBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const StripeMask = Interactive.withSchema({\n Component: StripeMaskInner,\n componentName: \"<StripeMask>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 100,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 100
}