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": "Concentric Scale",
"initialProps": null,
"slug": "concentric-scale",
"sourceCode": "import { loadFont } from \"@remotion/google-fonts/Sora\";\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: sora } = loadFont(\"normal\", {\n weights: [\"300\", \"400\", \"500\"],\n subsets: [\"latin\"],\n});\n\n// gradients.sh \"limb\" palette: the final disc glows at its rim like a planet limb.\nconst LIMB = [\"#e9ecff\", \"#8a8bff\", \"#4b2bd6\", \"#160c3a\"] as const;\n\ninterface ScaleStep {\n value: string;\n label?: string;\n}\n\ninterface ConcentricScaleProps {\n steps?: ScaleStep[];\n accent?: string;\n theme?: \"dark\" | \"light\";\n speed?: number;\n}\n\nconst DEFAULT_STEPS: ScaleStep[] = [\n { value: \"1\" },\n { value: \"10\" },\n { value: \"1,000\" },\n { value: \"100,000\", label: \"creators\" },\n];\n\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst EASE_RING = Easing.bezier(0.22, 0.8, 0.3, 1);\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\nconst TAU = Math.PI * 2;\nconst G = 1.9;\nconst FIRST = 18;\nconst STEP = 30;\nconst NODE_A = (-45 * Math.PI) / 180;\n\nconst THEMES = {\n dark: {\n bg: \"#0A0A0B\",\n fg: \"#F3F2EF\",\n muted: \"#8B8A90\",\n hair: \"rgba(255,255,255,0.2)\",\n hairStrong: \"rgba(255,255,255,0.5)\",\n // [offset, colour, alpha] from the centre out to the rim.\n limb: [\n [0, LIMB[3], 0],\n [0.45, LIMB[3], 0.55],\n [0.8, LIMB[2], 0.55],\n [0.95, LIMB[1], 0.7],\n [1, LIMB[0], 0.82],\n ],\n dotIn: LIMB[1],\n dotOut: LIMB[0],\n arc: LIMB[0],\n grain: 0.06,\n },\n light: {\n bg: \"#F5F4F0\",\n fg: \"#121214\",\n muted: \"#6E6C67\",\n hair: \"rgba(18,18,20,0.2)\",\n hairStrong: \"rgba(18,18,20,0.5)\",\n limb: [\n [0, LIMB[0], 0],\n [0.5, LIMB[0], 0.5],\n [0.8, LIMB[1], 0.4],\n [0.94, LIMB[2], 0.55],\n [1, LIMB[2], 0.85],\n ],\n dotIn: LIMB[1],\n dotOut: LIMB[2],\n arc: LIMB[2],\n grain: 0.045,\n },\n} as const;\n\nfunction hash(n: number) {\n const s = Math.sin(n * 127.1 + 311.7) * 43758.5453;\n return s - Math.floor(s);\n}\n\nfunction beadCount(k: number) {\n return k === 1 ? 10 : Math.round(10 * 3.4 ** (k - 1));\n}\n\nconst FIELD_N = 520;\nconst FIELD = Array.from({ length: FIELD_N }, (_, i) => {\n const turn = (i * 0.381966 + (hash(i * 3 + 1) - 0.5) * 0.004) % 1;\n return {\n id: i,\n a: turn,\n r: Math.min(\n 1,\n Math.max(0, (i + 0.5) / FIELD_N + (hash(i * 7 + 2) - 0.5) * 0.02),\n ),\n o: 0.45 + 0.4 * hash(i * 11 + 5),\n };\n});\n\nfunction Grain({ opacity }: { opacity: number }) {\n const id = `g${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n return (\n <svg\n width=\"100%\"\n height=\"100%\"\n style={{ position: \"absolute\", inset: 0, opacity }}\n aria-hidden\n >\n <filter id={id}>\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"0.9\"\n numOctaves={2}\n seed={53}\n stitchTiles=\"stitch\"\n />\n <feColorMatrix values=\"0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.9 0\" />\n </filter>\n <rect width=\"100%\" height=\"100%\" filter={`url(#${id})`} />\n </svg>\n );\n}\n\nfunction RingLabel({\n x,\n y,\n step,\n size,\n color,\n sub,\n opacity,\n shift,\n}: {\n x: number;\n y: number;\n step: ScaleStep;\n size: number;\n color: string;\n sub: string;\n opacity: number;\n shift: number;\n}) {\n return (\n <div\n style={{\n position: \"absolute\",\n left: x,\n top: y,\n transform: `translate(calc(-100% + ${shift}px), -100%)`,\n display: \"flex\",\n alignItems: \"baseline\",\n gap: size * 0.32,\n whiteSpace: \"nowrap\",\n opacity,\n }}\n >\n <span\n style={{\n fontFamily: sora,\n fontWeight: 500,\n fontSize: size,\n letterSpacing: \"-0.03em\",\n fontVariantNumeric: \"tabular-nums\",\n color,\n }}\n >\n {step.value}\n </span>\n {step.label ? (\n <span\n style={{\n fontFamily: sora,\n fontWeight: 400,\n fontSize: size * 0.78,\n color: sub,\n }}\n >\n {step.label}\n </span>\n ) : null}\n </div>\n );\n}\n\nfunction ConcentricScaleBase({\n steps = DEFAULT_STEPS,\n accent = \"#3B5BFD\",\n theme = \"dark\",\n speed = 1,\n}: ConcentricScaleProps) {\n const t = useCurrentFrame() * speed;\n const { width, height } = useVideoConfig();\n const u = Math.min(width / 1280, height / 720);\n const p = THEMES[theme];\n const list = steps.length >= 2 ? steps.slice(0, 7) : DEFAULT_STEPS;\n const last = list.length - 1;\n\n const startOf = (k: number) => FIRST + (k - 1) * STEP;\n const T_FINAL = startOf(last);\n const SWEEP = 30;\n const HIT = T_FINAL + SWEEP;\n\n let lc = 0;\n for (let k = 1; k < last; k++) {\n lc += interpolate(t, [startOf(k) + 12, startOf(k) + 40], [0, 1], {\n ...CLAMP,\n easing: EASE_IO,\n });\n }\n lc += interpolate(t, [T_FINAL + 8, HIT + 22], [0, 0.14], {\n ...CLAMP,\n easing: EASE_IO,\n });\n\n const pan = interpolate(t, [T_FINAL + 16, HIT + 18], [0, 1], {\n ...CLAMP,\n easing: EASE_IO,\n });\n const cx = interpolate(pan, [0, 1], [width * 0.5, width * 0.34]);\n const cy = height * 0.5;\n const RH = height * 0.38;\n const screenR = (x: number) => RH * G ** (x - 1 - lc);\n\n const ringX = (k: number) => {\n if (k === last) return k;\n const s = startOf(k);\n const e = interpolate(t, [s, s + 28], [0, 1], {\n ...CLAMP,\n easing: EASE_RING,\n });\n const from = k === 1 ? -2.6 : k - 1;\n return from + (k - from) * e;\n };\n\n const dotIn = interpolate(t, [2, 16], [0, 1], { ...CLAMP, easing: EASE_OUT });\n const sweep = interpolate(t, [T_FINAL, HIT], [0, 1], {\n ...CLAMP,\n easing: EASE_IO,\n });\n const lead = interpolate(t, [HIT - 4, HIT + 12], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const hero = interpolate(t, [HIT + 2, HIT + 24], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const sub = interpolate(t, [HIT + 10, HIT + 30], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const settle = interpolate(t, [T_FINAL, T_FINAL + 20], [0, 1], {\n ...CLAMP,\n easing: EASE_IO,\n });\n\n const rFinal = screenR(last);\n const rInner = last > 1 ? screenR(last - 1) * 1.14 : 18 * u;\n const hw = Math.max(1, u);\n const arcEnd = TAU * sweep;\n const startA = Math.PI / 2;\n const arcPt = (a: number) => ({\n x: cx + rFinal * Math.sin(startA + a),\n y: cy - rFinal * Math.cos(startA + a),\n });\n const ae = arcPt(arcEnd);\n const as = arcPt(0);\n const arcD =\n sweep >= 0.999\n ? `M ${cx + rFinal} ${cy} A ${rFinal} ${rFinal} 0 1 1 ${cx - rFinal} ${cy} A ${rFinal} ${rFinal} 0 1 1 ${cx + rFinal} ${cy}`\n : `M ${as.x} ${as.y} A ${rFinal} ${rFinal} 0 ${arcEnd > Math.PI ? 1 : 0} 1 ${ae.x} ${ae.y}`;\n const wedgeD = `M ${cx} ${cy} L ${as.x} ${as.y} A ${rFinal} ${rFinal} 0 ${arcEnd > Math.PI ? 1 : 0} 1 ${ae.x} ${ae.y} Z`;\n const gid = `cs${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n const leadX0 = cx + rFinal + 14 * u;\n const textLeft = width * 0.6;\n const leadX1 = leadX0 + (textLeft - 22 * u - leadX0) * lead;\n\n const rings = Array.from({ length: last - 1 }, (_, i) => i + 1);\n const finalStep = list[last];\n\n return (\n <AbsoluteFill style={{ background: p.bg, overflow: \"hidden\" }}>\n <svg\n width={width}\n height={height}\n style={{ position: \"absolute\", inset: 0 }}\n aria-hidden\n >\n {rings.map((k) => {\n const s = startOf(k);\n const vis = interpolate(t, [s, s + 8], [0, 1], CLAMP);\n if (vis <= 0) return null;\n const r = screenR(ringX(k));\n const newest = k === last - 1 || t < startOf(k + 1);\n return (\n <g key={`r${k}`} opacity={vis}>\n <circle\n cx={cx}\n cy={cy}\n r={r}\n fill=\"none\"\n stroke={newest && settle < 1 ? p.hairStrong : p.hair}\n strokeOpacity={newest ? 1 - 0.5 * settle : 1}\n strokeWidth={hw * 1.25}\n />\n {Array.from({ length: beadCount(k) }, (_, j) => {\n const count = beadCount(k);\n const jitter = j === 0 ? 0 : (hash(k * 97 + j) - 0.5) * 0.5;\n const a = NODE_A + ((j + jitter) / count) * TAU;\n const delay = (j / count) * 14;\n const b = interpolate(\n t,\n [s + 4 + delay, s + 12 + delay],\n [0, 1],\n {\n ...CLAMP,\n easing: EASE_OUT,\n },\n );\n if (b <= 0) return null;\n return (\n <circle\n key={`b${j}`}\n cx={cx + r * Math.sin(a)}\n cy={cy - r * Math.cos(a)}\n r={(j === 0 ? 3.4 : 2.4) * u * (0.5 + 0.5 * b)}\n fill={p.fg}\n opacity={(j === 0 ? 1 : 0.62) * b}\n />\n );\n })}\n </g>\n );\n })}\n {sweep > 0 ? (\n <>\n <defs>\n <radialGradient\n id={`${gid}l`}\n gradientUnits=\"userSpaceOnUse\"\n cx={cx + Math.sin(t / 50) * 4 * u}\n cy={cy + Math.cos(t / 60) * 4 * u}\n r={rFinal}\n >\n {p.limb.map(([o, col, a]) => (\n <stop\n key={`s${o}`}\n offset={o}\n stopColor={col}\n stopOpacity={a}\n />\n ))}\n </radialGradient>\n <radialGradient\n id={`${gid}d`}\n gradientUnits=\"userSpaceOnUse\"\n cx={cx}\n cy={cy}\n r={rFinal}\n >\n <stop offset={rInner / rFinal} stopColor={p.dotIn} />\n <stop offset={1} stopColor={p.dotOut} />\n </radialGradient>\n <clipPath id={`${gid}w`}>\n <path d={wedgeD} />\n </clipPath>\n </defs>\n <circle\n cx={cx}\n cy={cy}\n r={rFinal}\n fill={`url(#${gid}l)`}\n clipPath={sweep >= 0.999 ? undefined : `url(#${gid}w)`}\n opacity={0.55 + 0.45 * lead}\n />\n <circle\n cx={cx}\n cy={cy}\n r={rFinal}\n fill=\"none\"\n stroke={p.hair}\n strokeWidth={hw}\n strokeOpacity={0.6}\n />\n {FIELD.map((d) => {\n const k = interpolate(\n sweep,\n [d.a * 0.92, d.a * 0.92 + 0.08],\n [0, 1],\n CLAMP,\n );\n if (k <= 0) return null;\n const ro = rFinal * 0.95;\n const rr = Math.sqrt(rInner ** 2 + (ro ** 2 - rInner ** 2) * d.r);\n const a = startA + d.a * TAU;\n return (\n <circle\n key={d.id}\n cx={cx + rr * Math.sin(a)}\n cy={cy - rr * Math.cos(a)}\n r={1.6 * u}\n fill={`url(#${gid}d)`}\n opacity={k * d.o}\n />\n );\n })}\n <path\n d={arcD}\n fill=\"none\"\n stroke={p.arc}\n strokeWidth={2.5 * u}\n strokeLinecap=\"round\"\n />\n <circle\n cx={sweep >= 0.999 ? cx + rFinal : ae.x}\n cy={sweep >= 0.999 ? cy : ae.y}\n r={5 * u}\n fill={p.arc}\n />\n </>\n ) : null}\n {lead > 0 ? (\n <line\n x1={leadX0}\n y1={cy}\n x2={leadX1}\n y2={cy}\n stroke={p.hairStrong}\n strokeWidth={hw}\n />\n ) : null}\n <circle\n cx={cx}\n cy={cy}\n r={5 * u * (0.6 + 0.4 * dotIn)}\n fill={p.fg}\n opacity={dotIn}\n />\n </svg>\n\n <RingLabel\n x={cx - 10 * u}\n y={cy - 10 * u}\n step={list[0]}\n size={\n interpolate(t, [startOf(1), startOf(1) + 20], [40, 20], {\n ...CLAMP,\n easing: EASE_IO,\n }) * u\n }\n color={p.fg}\n sub={p.muted}\n opacity={interpolate(t, [6, 20], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n })}\n shift={0}\n />\n {rings.map((k) => {\n const s = startOf(k);\n const a = interpolate(t, [s + 10, s + 26], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n if (a <= 0) return null;\n const r = screenR(ringX(k));\n const newer = interpolate(\n t,\n [startOf(k + 1), startOf(k + 1) + 20],\n [0, 1],\n {\n ...CLAMP,\n easing: EASE_IO,\n },\n );\n const qx = cx + r * Math.sin(NODE_A) - 10 * u;\n const qy = cy - r * Math.cos(NODE_A) - 8 * u;\n return (\n <RingLabel\n key={`l${k}`}\n x={qx}\n y={qy}\n step={list[k]}\n size={(28 - 8 * newer) * u}\n color={p.fg}\n sub={p.muted}\n opacity={a}\n shift={(1 - a) * 10 * u}\n />\n );\n })}\n\n <div\n style={{\n position: \"absolute\",\n left: textLeft,\n top: cy,\n transform: \"translateY(-50%)\",\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"flex-start\",\n }}\n >\n <div\n style={{\n fontFamily: sora,\n fontWeight: 300,\n fontSize: 112 * u,\n lineHeight: 0.9,\n letterSpacing: \"-0.055em\",\n color: p.fg,\n fontVariantNumeric: \"tabular-nums\",\n whiteSpace: \"nowrap\",\n opacity: hero,\n filter: hero < 0.99 ? `blur(${(1 - hero) * 8 * u}px)` : undefined,\n transform: `translateX(${(1 - hero) * -22 * u}px)`,\n }}\n >\n {finalStep.value}\n </div>\n {finalStep.label ? (\n <div\n style={{\n marginTop: 18 * u,\n display: \"flex\",\n alignItems: \"center\",\n gap: 10 * u,\n fontFamily: sora,\n fontWeight: 400,\n fontSize: 26 * u,\n letterSpacing: \"-0.015em\",\n color: p.muted,\n whiteSpace: \"nowrap\",\n opacity: sub,\n transform: `translateY(${(1 - sub) * 8 * u}px)`,\n }}\n >\n <span\n style={{\n width: 10 * u,\n height: 10 * u,\n borderRadius: \"50%\",\n background: accent,\n flexShrink: 0,\n }}\n />\n {finalStep.label}\n </div>\n ) : null}\n </div>\n\n <AbsoluteFill\n style={{\n background: `radial-gradient(ellipse 80% 80% at 50% 50%, transparent 62%, ${p.bg} 100%)`,\n opacity: 0.6,\n }}\n />\n <Grain opacity={p.grain} />\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 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\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n theme: \"dark\",\n accent: \"#3B5BFD\",\n speed: 1,\n};\n\ntype ConcentricScaleElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ConcentricScaleBase>;\n\nconst ConcentricScaleInner = forwardRef<\n HTMLDivElement,\n ConcentricScaleElementProps & { 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 ?? \"<ConcentricScale>\"}\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 <ConcentricScaleBase\n {...(componentProps as unknown as ComponentProps<typeof ConcentricScaleBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ConcentricScale = Interactive.withSchema({\n Component: ConcentricScaleInner,\n componentName: \"<ConcentricScale>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 138,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 138
}