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": "Share Donut",
"initialProps": null,
"slug": "share-donut",
"sourceCode": "import { loadFont } from \"@remotion/google-fonts/DMSans\";\nimport { loadFont as loadDisplay } from \"@remotion/google-fonts/Fraunces\";\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport { forwardRef, useId, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { AbsoluteFill, Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst { fontFamily: sans } = loadFont(\"normal\", {\n weights: [\"400\", \"500\"],\n subsets: [\"latin\"],\n});\nconst { fontFamily: display } = loadDisplay(\"normal\", {\n weights: [\"300\", \"400\"],\n subsets: [\"latin\"],\n});\nloadDisplay(\"italic\", { weights: [\"300\"], subsets: [\"latin\"] });\nconst manrope = loadManrope(\"normal\", {\n weights: [\"500\", \"600\"],\n subsets: [\"latin\"],\n});\n\nconst REMOCN_R_PATH =\n \"M 0.01 0.81 C 0.01 1.73, 0.36 2.79, 1.09 4.13 C 4.91 11.04, 13.45 17.16, 21.7 18.9 C 22.94 19.16, 23.18 19.16, 51.39 19.27 C 76.07 19.36, 80.02 19.4, 81.32 19.57 C 89.89 20.69, 96.2 24.68, 99.38 31.01 C 103.19 38.56, 102.53 50.1, 97.91 57.07 C 94.66 61.96, 89.68 64.99, 83.26 66 C 82.81 66.07, 70.18 66.83, 55.2 67.69 C 24.82 69.43, 27.03 69.23, 24.18 70.4 C 19.9 72.15, 14.84 75.7, 10.65 79.89 C 4.86 85.68, 1.3 91.91, 0.25 98.13 C 0.12 98.85, 0.08 103.13, 0.04 116.66 L 0 134.26 9.5 134.26 L 19 134.26 19.05 119.41 C 19.1 103.27, 19.08 103.82, 19.82 101.04 C 21.79 93.65, 27.86 88.75, 36.45 87.63 C 37.23 87.53, 39.41 87.5, 43.57 87.53 C 50.12 87.59, 50.75 87.65, 53.22 88.45 C 56.61 89.56, 59.67 91.86, 62.02 95.07 C 62.52 95.76, 69.35 103.85, 77.2 113.07 C 85.04 122.28, 91.63 130.04, 91.85 130.32 C 92.07 130.59, 92.5 131.34, 92.82 131.97 C 93.52 133.35, 94.11 133.93, 95.06 134.13 C 95.5 134.23, 98.97 134.26, 106.36 134.23 L 117.01 134.19 100.82 113.07 C 91.91 101.45, 84.52 91.78, 84.39 91.57 C 83.36 89.89, 83.66 87.53, 85.09 86 C 85.79 85.25, 86.36 84.94, 88.07 84.38 C 96.18 81.72, 104.15 76.62, 109.97 70.36 C 120.59 58.93, 124.06 44.32, 119.44 30.43 C 114.59 15.81, 101.93 4.02, 87.64 0.83 C 83.93 0.01, 88.09 0.08, 41.85 0.04 L 0.01 0 0.01 0.81 Z\";\n\n/** Full logo as on remocn.dev: R mark (0.76em tall, baseline-aligned) + \"emocn\" in Manrope 600, tracking-tight. */\nfunction RemocnLogo({ fontSize, color }: { fontSize: number; color: string }) {\n return (\n <div\n style={{\n display: \"flex\",\n alignItems: \"baseline\",\n color,\n fontFamily: manrope.fontFamily,\n fontWeight: 600,\n fontSize,\n letterSpacing: \"-0.025em\",\n lineHeight: 1,\n }}\n >\n <svg\n viewBox=\"0 0 124.06 134.26\"\n style={{ height: \"0.76em\", width: \"auto\" }}\n aria-hidden\n >\n <path fill=\"currentColor\" d={REMOCN_R_PATH} />\n </svg>\n <span style={{ marginLeft: \"0.04em\" }}>emocn</span>\n </div>\n );\n}\n\nconst isBrand = (label: string) => label.trim().toLowerCase() === \"remocn\";\n\ninterface DonutSegment {\n label: string;\n value: number;\n}\n\ninterface ShareDonutProps {\n segments?: DonutSegment[];\n highlight?: number;\n accent?: string;\n theme?: \"dark\" | \"light\";\n speed?: number;\n}\n\nconst DEFAULT_SEGMENTS: DonutSegment[] = [\n { label: \"remocn\", value: 38 },\n { label: \"Kitebase\", value: 24 },\n { label: \"Lumen\", value: 17 },\n { label: \"Fernway\", value: 12 },\n { label: \"Other\", value: 9 },\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_SEG = Easing.bezier(0.55, 0, 0.25, 1);\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst THEMES = {\n dark: {\n bg: \"#0A0A0B\",\n fg: \"#F3F2EF\",\n muted: \"#8B8A90\",\n hair: \"rgba(255,255,255,0.22)\",\n track: \"rgba(255,255,255,0.05)\",\n grays: [\"#B9B7B2\", \"#85848A\", \"#5C5B61\", \"#3E3D43\"],\n // gradients.sh \"halo\": the highlighted share burns accent → rose → amber.\n halo: [\"#E2457A\", \"#FFB36B\"],\n haze: [\"rgba(226,69,122,0.12)\", \"rgba(61,77,255,0.09)\"],\n grain: 0.06,\n },\n light: {\n bg: \"#F5F4F0\",\n fg: \"#121214\",\n muted: \"#6E6C67\",\n hair: \"rgba(18,18,20,0.22)\",\n track: \"rgba(18,18,20,0.05)\",\n grays: [\"#4F4D49\", \"#85837E\", \"#AEACA6\", \"#D0CEC8\"],\n halo: [\"#E2457A\", \"#FF9A4D\"],\n haze: [\"rgba(226,69,122,0.08)\", \"rgba(61,77,255,0.05)\"],\n grain: 0.045,\n },\n} as const;\n\nconst DRAW_START = 6;\nconst DRAW_LEN = 52;\nconst TAU = Math.PI * 2;\n\nfunction pt(cx: number, cy: number, r: number, a: number) {\n return { x: cx + r * Math.sin(a), y: cy - r * Math.cos(a) };\n}\n\nfunction arc(cx: number, cy: number, r: number, a0: number, a1: number) {\n const s = pt(cx, cy, r, a0);\n const e = pt(cx, cy, r, a1);\n const large = a1 - a0 > Math.PI ? 1 : 0;\n return `M ${s.x.toFixed(2)} ${s.y.toFixed(2)} A ${r} ${r} 0 ${large} 1 ${e.x.toFixed(2)} ${e.y.toFixed(2)}`;\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={29}\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 ShareDonutBase({\n segments = DEFAULT_SEGMENTS,\n highlight = 0,\n accent = \"#3B5BFD\",\n theme = \"dark\",\n speed = 1,\n}: ShareDonutProps) {\n const t = useCurrentFrame() * speed;\n const { width, height, fps } = useVideoConfig();\n const u = Math.min(width / 1280, height / 720);\n const p = THEMES[theme];\n const list = segments.slice(0, 5);\n const hl = Math.min(Math.max(0, Math.round(highlight)), list.length - 1);\n const total = list.reduce((s, x) => s + Math.max(0, x.value), 0) || 1;\n\n const cx = width / 2;\n const cy = height / 2;\n const R = height * 0.3;\n const sw = 12 * u;\n const gapA = (6 * u) / R;\n\n let acc = 0;\n let grayIdx = 0;\n let clock = DRAW_START;\n const segs = list.map((s, i) => {\n const frac = Math.max(0, s.value) / total;\n const a0 = acc * TAU;\n acc += frac;\n const a1 = acc * TAU;\n const dur = Math.max(9, DRAW_LEN * frac);\n const start = clock;\n clock += dur - 2;\n const color = i === hl ? accent : p.grays[Math.min(grayIdx++, 3)];\n return {\n ...s,\n i,\n frac,\n a0: a0 + gapA / 2,\n a1: a1 - gapA / 2,\n mid: (a0 + a1) / 2,\n start,\n end: start + dur,\n color,\n pct: Math.round(frac * 100),\n };\n });\n const drawEnd = segs.length ? segs[segs.length - 1].end : DRAW_START;\n const HIT = drawEnd + 8;\n\n const detach = spring({\n frame: t - HIT,\n fps,\n config: { damping: 15, stiffness: 150, mass: 0.7 },\n });\n const dim = interpolate(t, [HIT, HIT + 16], [0, 1], {\n ...CLAMP,\n easing: EASE_IO,\n });\n const land = interpolate(t, [HIT + 4, HIT + 24], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const count = interpolate(t, [HIT + 4, HIT + 30], [0.55, 1], {\n ...CLAMP,\n easing: Easing.bezier(0.22, 1, 0.36, 1),\n });\n const labIn = interpolate(t, [HIT + 12, HIT + 30], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const stage = interpolate(t, [0, 10], [0.4, 1], CLAMP);\n const spin = interpolate(t, [0, HIT + 10], [-14, 0], {\n ...CLAMP,\n easing: EASE_IO,\n });\n const push = interpolate(t, [0, HIT + 60], [0, 1], {\n ...CLAMP,\n easing: EASE_IO,\n });\n const scale = 0.97 + 0.04 * push;\n\n const target = segs[hl];\n const gradId = `h${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n const g0 = target ? pt(cx, cy, R, target.a0) : { x: cx, y: cy - R };\n const g1 = target ? pt(cx, cy, R, target.a1) : { x: cx + R, y: cy };\n const off = detach * 18 * u;\n const hx = target ? Math.sin(target.mid) * off : 0;\n const hy = target ? -Math.cos(target.mid) * off : 0;\n\n return (\n <AbsoluteFill style={{ background: p.bg, overflow: \"hidden\" }}>\n <AbsoluteFill\n style={{\n background: `radial-gradient(circle at 50% 50%, transparent ${R * 0.62}px, ${p.haze[0]} ${R * 1.02}px, ${p.haze[1]} ${R * 1.3}px, transparent ${R * 1.85}px)`,\n opacity: 0.25 + 0.75 * land,\n transform: `rotate(${spin}deg)`,\n }}\n />\n <AbsoluteFill\n style={{\n transform: `scale(${scale})`,\n transformOrigin: \"50% 50%\",\n }}\n >\n <svg\n width={width}\n height={height}\n style={{ position: \"absolute\", inset: 0, opacity: stage }}\n aria-hidden\n >\n <defs>\n <linearGradient\n id={gradId}\n gradientUnits=\"userSpaceOnUse\"\n x1={g0.x}\n y1={g0.y}\n x2={g1.x}\n y2={g1.y}\n >\n <stop offset=\"0\" stopColor={accent} />\n <stop offset=\"0.58\" stopColor={p.halo[0]} />\n <stop offset=\"1\" stopColor={p.halo[1]} />\n </linearGradient>\n </defs>\n <g transform={`rotate(${spin} ${cx} ${cy})`}>\n <circle\n cx={cx}\n cy={cy}\n r={R}\n fill=\"none\"\n stroke={p.track}\n strokeWidth={sw}\n opacity={1 - dim}\n />\n {segs.map((s) => {\n const k = interpolate(t, [s.start, s.end], [0, 1], {\n ...CLAMP,\n easing: EASE_SEG,\n });\n if (k <= 0 || s.a1 <= s.a0) return null;\n const isHl = s.i === hl;\n const a1 = s.a0 + (s.a1 - s.a0) * k;\n return (\n <path\n key={s.label}\n d={arc(cx, cy, R, s.a0, a1)}\n fill=\"none\"\n stroke={isHl ? `url(#${gradId})` : s.color}\n strokeLinecap={isHl ? \"round\" : \"butt\"}\n strokeWidth={isHl ? sw * (1 + 0.5 * detach) : sw}\n opacity={isHl ? 1 : 1 - 0.5 * dim}\n transform={isHl ? `translate(${hx} ${hy})` : undefined}\n />\n );\n })}\n {segs.map((s) => {\n const a = interpolate(t, [s.end - 6, s.end + 8], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const p0 = pt(cx, cy, R + sw / 2 + 8 * u, s.mid);\n const p1 = pt(cx, cy, R + sw / 2 + 8 * u + 14 * u * a, s.mid);\n const fade = s.i === hl ? 1 - dim : 1 - 0.55 * dim;\n return (\n <line\n key={s.label}\n x1={p0.x}\n y1={p0.y}\n x2={p1.x}\n y2={p1.y}\n stroke={p.hair}\n strokeWidth={Math.max(1, u)}\n opacity={a * fade}\n />\n );\n })}\n </g>\n </svg>\n\n {segs.map((s) => {\n const a = interpolate(t, [s.end - 4, s.end + 12], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const ang = s.mid + (spin * Math.PI) / 180;\n const q = pt(cx, cy, R + sw / 2 + 38 * u + (1 - a) * -8 * u, ang);\n const right = Math.sin(ang) >= -0.05;\n const fade = s.i === hl ? 1 - dim : 1 - 0.6 * dim;\n return (\n <div\n key={s.label}\n style={{\n position: \"absolute\",\n left: q.x,\n top: q.y,\n transform: `translate(${right ? 0 : -100}%, -50%)`,\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: right ? \"flex-start\" : \"flex-end\",\n gap: 2 * u,\n opacity: a * fade * stage,\n whiteSpace: \"nowrap\",\n }}\n >\n <span\n style={{\n fontFamily: sans,\n fontWeight: 500,\n fontSize: 22 * u,\n letterSpacing: \"-0.02em\",\n color: p.fg,\n fontVariantNumeric: \"tabular-nums\",\n }}\n >\n {s.pct}%\n </span>\n {isBrand(s.label) ? (\n <RemocnLogo fontSize={15 * u} color={p.muted} />\n ) : (\n <span\n style={{\n fontFamily: sans,\n fontWeight: 400,\n fontSize: 15 * u,\n color: p.muted,\n }}\n >\n {s.label}\n </span>\n )}\n </div>\n );\n })}\n\n {target ? (\n <AbsoluteFill\n style={{\n alignItems: \"center\",\n justifyContent: \"center\",\n flexDirection: \"column\",\n }}\n >\n <div\n style={{\n fontFamily: display,\n fontWeight: 300,\n fontSize: 176 * u,\n lineHeight: 0.9,\n letterSpacing: \"-0.035em\",\n color: p.fg,\n fontVariantNumeric: \"tabular-nums\",\n whiteSpace: \"nowrap\",\n opacity: land,\n filter:\n land < 0.99 ? `blur(${(1 - land) * 8 * u}px)` : undefined,\n transform: `translateY(${(1 - land) * 22 * u}px) scale(${1.05 - 0.05 * land})`,\n marginTop: 10 * u,\n }}\n >\n {Math.round(target.pct * count)}\n <span\n style={{\n fontSize: 92 * u,\n fontStyle: \"italic\",\n letterSpacing: \"-0.02em\",\n marginLeft: 4 * u,\n color: p.muted,\n }}\n >\n %\n </span>\n </div>\n <div\n style={{\n marginTop: 14 * u,\n display: \"flex\",\n alignItems: \"center\",\n gap: 10 * u,\n opacity: labIn,\n transform: `translateY(${(1 - labIn) * 8 * u}px)`,\n }}\n >\n {isBrand(target.label) ? (\n <RemocnLogo fontSize={28 * u} color={p.fg} />\n ) : (\n <>\n <span\n style={{\n width: 10 * u,\n height: 10 * u,\n borderRadius: \"50%\",\n background: `linear-gradient(135deg, ${accent}, ${p.halo[0]}, ${p.halo[1]})`,\n }}\n />\n <span\n style={{\n fontFamily: sans,\n fontWeight: 400,\n fontSize: 22 * u,\n letterSpacing: \"-0.01em\",\n color: p.muted,\n whiteSpace: \"nowrap\",\n }}\n >\n {target.label}\n </span>\n </>\n )}\n </div>\n </AbsoluteFill>\n ) : null}\n </AbsoluteFill>\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 highlight: {\n type: \"number\",\n default: 0,\n min: 0,\n max: 10,\n step: 1,\n description: \"Highlight\",\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\",\"highlight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n theme: \"dark\",\n accent: \"#3B5BFD\",\n highlight: 0,\n speed: 1,\n};\n\ntype ShareDonutElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShareDonutBase>;\n\nconst ShareDonutInner = forwardRef<\n HTMLDivElement,\n ShareDonutElementProps & { 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 ?? \"<ShareDonut>\"}\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 <ShareDonutBase\n {...(componentProps as unknown as ComponentProps<typeof ShareDonutBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShareDonut = Interactive.withSchema({\n Component: ShareDonutInner,\n componentName: \"<ShareDonut>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 96,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 96
}