Quadrant Plot
Competitors scatter on a quadrant plot and the Kuchi marker lands in the best corner.
Source
components/kuchi/quadrant-plot.tsx
1"use client";23import { loadFont as loadGeist } from "@remotion/google-fonts/Geist";4import { loadFont as loadGeistMono } from "@remotion/google-fonts/GeistMono";5import { loadFont as loadManrope } from "@remotion/google-fonts/Manrope";6import type React from "react";7import { useId } from "react";8import {9 AbsoluteFill,10 Easing,11 interpolate,12 interpolateColors,13 spring,14 useCurrentFrame,15 useVideoConfig,16} from "remotion";1718const { fontFamily: sans } = loadGeist("normal", {19 weights: ["400", "500"],20 subsets: ["latin"],21});22const { fontFamily: mono } = loadGeistMono("normal", {23 weights: ["400", "500"],24 subsets: ["latin"],25});26const { fontFamily: manrope } = loadManrope("normal", {27 weights: ["600"],28 subsets: ["latin"],29});3031export interface QuadrantPoint {32 label: string;33 x: number;34 y: number;35}3637export interface QuadrantPlotProps {38 xLabels?: [string, string];39 yLabels?: [string, string];40 points?: QuadrantPoint[];41 brand?: QuadrantPoint;42 accent?: string;43 /** Color of the brand label and the lit axis ends; overrides the theme. */44 ink?: string;45 /** Background fill; "transparent" drops it. */46 background?: string;47 /** Typeface for the point and brand labels. Load it yourself; Geist by default. */48 fontFamily?: string;49 /** Frames between competitor dots dropping in. */50 stagger?: number;51 /** Replaces the acme mark when the brand label is "acme". */52 logo?: React.ReactNode;53 /** Film grain over the scene. */54 grain?: boolean;55 /** Size of the plot, around the frame's center. */56 scale?: number;57 /** Frames to hold the first frame before anything moves. */58 delay?: number;59 theme?: "dark" | "light";60 speed?: number;61}6263const DEFAULT_POINTS: QuadrantPoint[] = [64 { label: "Kitebase", x: 0.71, y: 0.3 },65 { label: "Lumen", x: 0.27, y: 0.71 },66 { label: "Fernway", x: 0.2, y: 0.24 },67 { label: "Quarry", x: 0.6, y: 0.4 },68 { label: "Orbitly", x: 0.38, y: 0.58 },69 { label: "Halcyon", x: 0.13, y: 0.42 },70];7172const DEFAULT_BRAND: QuadrantPoint = { label: "acme", x: 0.74, y: 0.8 };7374const EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);75const EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);76const EASE_ARRIVE = Easing.bezier(0.2, 0.9, 0.25, 1);77const CLAMP = {78 extrapolateLeft: "clamp",79 extrapolateRight: "clamp",80} as const;8182const THEMES = {83 dark: {84 bg: "#0A0A0B",85 fg: "#F3F2EF",86 muted: "#8B8A90",87 axis: "rgba(255,255,255,0.26)",88 mark: "rgba(255,255,255,0.32)",89 grid: "rgba(255,255,255,0.075)",90 dot: "#9C9BA1",91 grain: 0.06,92 hero: "#F5F6FF",93 heroLabel: "#F5F6FF",94 guide: "rgba(245,246,255,0.55)",95 // gradients.sh "mesh": bg #0a0d24, [#ecdcf2, #8796ee, #2e45b7, #0e1645]96 meshBg: "#0a0d24",97 blobs: [98 ["#2e45b7", 18, 6, 0.95],99 ["#ecdcf2", -2, 112, 0.8],100 ["#8796ee", 30, 84, 0.85],101 ["#2e45b7", 72, 46, 1],102 ["#0e1645", 102, 104, 1],103 ["#8796ee", 104, -6, 0.45],104 ],105 },106 light: {107 bg: "#F5F4F0",108 fg: "#121214",109 muted: "#6E6C67",110 axis: "rgba(18,18,20,0.26)",111 mark: "rgba(18,18,20,0.32)",112 grid: "rgba(18,18,20,0.08)",113 dot: "#8E8C86",114 grain: 0.045,115 hero: "#121214",116 heroLabel: "#121214",117 guide: "rgba(18,18,20,0.45)",118 meshBg: "#EEF0FB",119 blobs: [120 ["#8796ee", 0, 104, 0.95],121 ["#ecdcf2", 36, 70, 1],122 ["#2e45b7", 8, 40, 0.45],123 ["#8796ee", 100, 0, 0.55],124 ["#ecdcf2", 96, 96, 0.9],125 ["#2e45b7", 104, 104, 0.35],126 ],127 },128} as const;129130const AXIS = [-8, 22] as const;131const DROP = 26;132const DROP_STAGGER = 4;133const ARRIVE = 62;134const ARRIVE_LEN = 30;135const LANDED = ARRIVE + ARRIVE_LEN - 8;136137function Grain({ opacity }: { opacity: number }) {138 const id = `g${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;139 return (140 <svg141 width="100%"142 height="100%"143 style={{ position: "absolute", inset: 0, opacity }}144 aria-hidden145 >146 <filter id={id}>147 <feTurbulence148 type="fractalNoise"149 baseFrequency="0.9"150 numOctaves={2}151 seed={23}152 stitchTiles="stitch"153 />154 <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" />155 </filter>156 <rect width="100%" height="100%" filter={`url(#${id})`} />157 </svg>158 );159}160161162/** The acme.dev logo: R mark (0.76em, on the baseline) + "Acme" in Manrope 600. */163function KuchiLogo({ fontSize, color }: { fontSize: number; color: string }) {164 return (165 <div166 style={{167 display: "flex",168 alignItems: "baseline",169 color,170 fontFamily: manrope,171 fontWeight: 600,172 fontSize,173 letterSpacing: "-0.025em",174 lineHeight: 1,175 whiteSpace: "nowrap",176 }}177 >178 <span>Acme</span>179 </div>180 );181}182183const clamp01 = (v: number) => Math.min(1, Math.max(0, v));184185/** The foreground at `scale`, around the frame's center; nothing extra at 1. */186function ScaleLayer({187 scale,188 children,189}: {190 scale: number;191 children: React.ReactNode;192}) {193 if (scale === 1) return children;194 return (195 <AbsoluteFill style={{ transform: `scale(${scale})` }}>196 {children}197 </AbsoluteFill>198 );199}200201export function QuadrantPlot({202 xLabels = ["Slow", "Fast"],203 yLabels = ["Hard", "Easy"],204 points = DEFAULT_POINTS,205 brand = DEFAULT_BRAND,206 accent = "#3B5BFD",207 ink,208 background,209 fontFamily = sans,210 stagger = DROP_STAGGER,211 logo,212 grain = true,213 scale = 1,214 delay = 0,215 theme = "dark",216 speed = 1,217}: QuadrantPlotProps) {218 const t = Math.max(0, useCurrentFrame() - delay) * speed;219 const { width, height, fps } = useVideoConfig();220 const u = Math.min(width / 1280, height / 720);221 const p = THEMES[theme];222 const fg = ink ?? p.fg;223 const heroLabel = ink ?? p.heroLabel;224 const stage =225 background === "transparent" ? "transparent" : (background ?? p.bg);226227 const cx = width / 2;228 const cy = height / 2;229 const hw = width * 0.3;230 const hh = height * 0.3;231 const toX = (x: number) => cx + (clamp01(x) - 0.5) * 2 * hw;232 const toY = (y: number) => cy - (clamp01(y) - 0.5) * 2 * hh;233 const sw = Math.max(1, u);234235 const axisK = interpolate(t, AXIS, [0, 1], { ...CLAMP, easing: EASE_IO });236 const markK = interpolate(t, [12, 30], [0, 1], {237 ...CLAMP,238 easing: EASE_OUT,239 });240 const labelK = (delay: number) =>241 interpolate(t, [14 + delay, 32 + delay], [0, 1], {242 ...CLAMP,243 easing: EASE_OUT,244 });245246 const arrive = interpolate(t, [ARRIVE, ARRIVE + ARRIVE_LEN], [0, 1], {247 ...CLAMP,248 easing: EASE_ARRIVE,249 });250 const bx = toX(brand.x);251 const by = toY(brand.y);252 const sx = cx - hw * 0.12;253 const sy = cy + hh * 0.18;254 const qx = bx + hw * 0.05;255 const qy = sy - hh * 0.05;256 const along = (k: number): [number, number] => {257 const a = (1 - k) * (1 - k);258 const b = 2 * (1 - k) * k;259 const c = k * k;260 return [a * sx + b * qx + c * bx, a * sy + b * qy + c * by];261 };262 const arriveAt = (time: number) =>263 interpolate(time, [ARRIVE, ARRIVE + ARRIVE_LEN], [0, 1], {264 ...CLAMP,265 easing: EASE_ARRIVE,266 });267 const [dx, dy] = along(arrive);268 const brandO = interpolate(t, [ARRIVE, ARRIVE + 5], [0, 1], CLAMP);269 const brandS = interpolate(t, [ARRIVE, ARRIVE + 10], [0.6, 1], {270 ...CLAMP,271 easing: EASE_OUT,272 });273 const ghosts = [1.5, 3, 4.5].map((lag, i) => {274 const [gx, gy] = along(arriveAt(t - lag));275 const dist = Math.hypot(gx - dx, gy - dy);276 return {277 gx,278 gy,279 o: Math.min(1, dist / (18 * u)) * [0.3, 0.16, 0.08][i] * brandO,280 };281 });282283 const ring = interpolate(t, [LANDED, LANDED + 26], [0, 1], {284 ...CLAMP,285 easing: EASE_OUT,286 });287 const dim = interpolate(t, [LANDED - 4, LANDED + 14], [0, 1], {288 ...CLAMP,289 easing: EASE_IO,290 });291 const wash = interpolate(t, [LANDED - 2, LANDED + 20], [0, 1], {292 ...CLAMP,293 easing: EASE_IO,294 });295 const guide = interpolate(t, [LANDED + 4, LANDED + 22], [0, 1], {296 ...CLAMP,297 easing: EASE_IO,298 });299 const brandLab = interpolate(t, [LANDED - 2, LANDED + 16], [0, 1], {300 ...CLAMP,301 easing: EASE_OUT,302 });303304 const push = interpolate(t, [0, 140], [0, 1], { ...CLAMP, easing: EASE_IO });305 const zoom = 0.975 + 0.04 * push;306 const drift = interpolate(t, [ARRIVE - 10, 140], [0, 1], {307 ...CLAMP,308 easing: EASE_IO,309 });310 const camX = -(bx - cx) * 0.035 * drift;311 const camY = -(by - cy) * 0.035 * drift;312313 const corner = 16 * u * markK;314 const corners: Array<[number, number, number, number]> = [315 [cx - hw, cy - hh, 1, 1],316 [cx + hw, cy - hh, -1, 1],317 [cx - hw, cy + hh, 1, -1],318 [cx + hw, cy + hh, -1, -1],319 ];320321 const gap = 0.25;322 const gridDots: Array<[number, number]> = [];323 for (let gx = 0; gx <= 1.0001; gx += gap / 2) {324 for (let gy = 0; gy <= 1.0001; gy += gap / 2) {325 if (Math.abs(gx - 0.5) < 0.01 || Math.abs(gy - 0.5) < 0.01) continue;326 gridDots.push([toX(gx), toY(gy)]);327 }328 }329330 const endLabel = (331 text: string,332 x: number,333 y: number,334 align: "left" | "right" | "top" | "bottom",335 k: number,336 strong: boolean,337 ) => {338 const tx = align === "left" ? "-100%" : align === "right" ? "0%" : "-50%";339 const ty = align === "top" ? "-100%" : align === "bottom" ? "0%" : "-50%";340 const nudge = (1 - k) * 10 * u;341 const ox = align === "left" ? nudge : align === "right" ? -nudge : 0;342 const oy = align === "top" ? nudge : align === "bottom" ? -nudge : 0;343 return (344 <div345 key={text + align}346 style={{347 position: "absolute",348 left: x,349 top: y,350 transform: `translate(${tx}, ${ty}) translate(${ox}px, ${oy}px)`,351 fontFamily: mono,352 fontWeight: 400,353 fontSize: 14 * u,354 letterSpacing: "0.12em",355 textTransform: "uppercase",356 color: strong357 ? interpolateColors(wash, [0, 1], [p.muted, fg])358 : p.muted,359 opacity: k,360 whiteSpace: "nowrap",361 }}362 >363 {text}364 </div>365 );366 };367368 const pad = 20 * u;369 const reveal = 0.25 + 0.75 * wash;370 const sway = interpolate(t, [LANDED - 4, 140], [0, 1], CLAMP);371 const mesh = [372 ...p.blobs.map(373 ([c, x, y, a], i) =>374 `radial-gradient(85% 95% at ${x + Math.sin(i * 1.7 + sway * 1.4) * 4}% ${y + Math.cos(i * 2.3 + sway * 1.2) * 4}%, color-mix(in oklab, ${c} ${Math.round(a * 100)}%, transparent) 0%, transparent 68%)`,375 ),376 `linear-gradient(${p.meshBg}, ${p.meshBg})`,377 ].join(", ");378 const heroDot =379 theme === "light"380 ? accent381 : interpolateColors(wash, [0, 1], [accent, p.hero]);382383 return (384 <AbsoluteFill style={{ background: stage, overflow: "hidden" }}>385 <ScaleLayer scale={scale}>386 <AbsoluteFill387 style={{388 transform: `translate(${camX}px, ${camY}px) scale(${zoom})`,389 transformOrigin: "50% 50%",390 }}391 >392 <div393 style={{394 position: "absolute",395 left: cx,396 top: cy - hh,397 width: hw,398 height: hh,399 background: mesh,400 opacity: wash,401 clipPath: `inset(${(1 - reveal) * 100}% ${(1 - reveal) * 100}% 0 0)`,402 }}403 />404 <svg405 width={width}406 height={height}407 style={{ position: "absolute", inset: 0 }}408 aria-hidden409 >410 {gridDots.map(([gx, gy]) => (411 <circle412 key={`${gx.toFixed(1)}-${gy.toFixed(1)}`}413 cx={gx}414 cy={gy}415 r={1.3 * u}416 fill={p.grid}417 opacity={markK}418 />419 ))}420421 <line422 x1={cx - hw * axisK}423 y1={cy}424 x2={cx + hw * axisK}425 y2={cy}426 stroke={p.axis}427 strokeWidth={sw}428 />429 <line430 x1={cx}431 y1={cy - hh * axisK}432 x2={cx}433 y2={cy + hh * axisK}434 stroke={p.axis}435 strokeWidth={sw}436 />437438 {corners.map(([x, y, ix, iy]) => (439 <path440 key={`${x}-${y}`}441 d={`M${x + ix * corner} ${y} L${x} ${y} L${x} ${y + iy * corner}`}442 fill="none"443 stroke={p.mark}444 strokeWidth={sw}445 opacity={markK * (ix < 0 && iy > 0 ? 1 - wash : 1)}446 />447 ))}448449 {points.map((pt, i) => {450 const start = DROP + i * stagger;451 const s = spring({452 frame: t - start,453 fps,454 config: { damping: 14, stiffness: 170, mass: 0.7 },455 });456 const o = interpolate(t, [start, start + 6], [0, 1], CLAMP);457 const x = toX(pt.x);458 const y = toY(pt.y) - (1 - s) * 34 * u;459 return (460 <circle461 key={pt.label}462 cx={x}463 cy={y}464 r={7 * u}465 fill={p.dot}466 opacity={o * (1 - 0.62 * dim)}467 />468 );469 })}470471 <g opacity={guide * 0.9}>472 <line473 x1={bx}474 y1={by}475 x2={bx}476 y2={by + (cy - by) * guide}477 stroke={p.guide}478 strokeWidth={sw}479 strokeDasharray={`${3 * u} ${5 * u}`}480 />481 <line482 x1={bx}483 y1={by}484 x2={bx + (cx - bx) * guide}485 y2={by}486 stroke={p.guide}487 strokeWidth={sw}488 strokeDasharray={`${3 * u} ${5 * u}`}489 />490 </g>491492 {ghosts.map((g, i) => (493 <circle494 key={i}495 cx={g.gx}496 cy={g.gy}497 r={12 * u * brandS}498 fill={accent}499 opacity={t >= ARRIVE ? g.o : 0}500 />501 ))}502 <circle503 cx={dx}504 cy={dy}505 r={(12 + 36 * ring) * u}506 fill="none"507 stroke={heroDot}508 strokeWidth={1.5 * u}509 opacity={t >= LANDED ? (1 - ring) * 0.7 : 0}510 />511 <circle512 cx={dx}513 cy={dy}514 r={22 * u}515 fill="none"516 stroke={heroDot}517 strokeWidth={sw}518 opacity={brandLab * 0.45}519 />520 <circle521 cx={dx}522 cy={dy}523 r={12 * u * brandS}524 fill={heroDot}525 opacity={t >= ARRIVE ? brandO : 0}526 />527 </svg>528529 {points.map((pt, i) => {530 const start = DROP + i * stagger + 5;531 const k = interpolate(t, [start, start + 14], [0, 1], {532 ...CLAMP,533 easing: EASE_OUT,534 });535 return (536 <div537 key={pt.label}538 style={{539 position: "absolute",540 left: toX(pt.x) + 15 * u,541 top: toY(pt.y),542 transform: `translate(${(1 - k) * -6 * u}px, -50%)`,543 fontFamily,544 fontWeight: 400,545 fontSize: 17 * u,546 letterSpacing: "-0.005em",547 color: p.muted,548 opacity: k * (1 - 0.6 * dim),549 whiteSpace: "nowrap",550 }}551 >552 {pt.label}553 </div>554 );555 })}556557 <div558 style={{559 position: "absolute",560 left: bx + 36 * u,561 top: by,562 transform: `translate(${(1 - brandLab) * -10 * u}px, -50%)`,563 opacity: brandLab,564 }}565 >566 {brand.label.toLowerCase() === "acme" ? (567 (logo ?? <KuchiLogo fontSize={34 * u} color={heroLabel} />)568 ) : (569 <div570 style={{571 fontFamily,572 fontWeight: 500,573 fontSize: 32 * u,574 letterSpacing: "-0.025em",575 color: heroLabel,576 whiteSpace: "nowrap",577 }}578 >579 {brand.label}580 </div>581 )}582 </div>583584 {endLabel(xLabels[0], cx - hw - pad, cy, "left", labelK(0), false)}585 {endLabel(xLabels[1], cx + hw + pad, cy, "right", labelK(2), true)}586 {endLabel(yLabels[1], cx, cy - hh - pad, "top", labelK(4), true)}587 {endLabel(yLabels[0], cx, cy + hh + pad, "bottom", labelK(6), false)}588 </AbsoluteFill>589 </ScaleLayer>590591 <AbsoluteFill592 style={{593 background: `radial-gradient(ellipse 80% 80% at 50% 50%, transparent 62%, ${stage} 100%)`,594 opacity: 0.6,595 }}596 />597 {grain ? <Grain opacity={p.grain} /> : null}598 </AbsoluteFill>599 );600}









