Caret Dolly
A prompt box types a request while the camera dollies along the caret.
Source
components/kuchi/caret-dolly.tsx
1"use client";23import { loadFont } from "@remotion/google-fonts/InstrumentSans";4import {5 type ReactNode,6 useEffect,7 useId,8 useMemo,9 useRef,10 useState,11} from "react";12import {13 AbsoluteFill,14 continueRender,15 delayRender,16 Easing,17 interpolate,18 spring,19 useCurrentFrame,20 useVideoConfig,21} from "remotion";22import type { GradientParams } from "@/lib/kuchi/gsh/gradient-engine";23import { GshGround, gshParams } from "@/lib/kuchi/gsh/gsh-ground";24import type { GshPresetId } from "@/lib/kuchi/gsh/presets";2526const face = loadFont("normal", {27 weights: ["400"],28 subsets: ["latin"],29});3031export interface CaretDollyProps {32 prompt?: string;33 focus?: string;34 chipLabel?: string;35 modelLabel?: string;36 accent?: string;37 ink?: string;38 background?: string;39 theme?: "dark" | "light";40 ground?: GshPresetId;41 groundParams?: Partial<GradientParams>;42 /** Typeface for the prompt and toolbar. Load it yourself; Instrument Sans by default. */43 fontFamily?: string;44 /** Multiplier on how close the camera gets to the focus phrase. */45 zoom?: number;46 /** Directional blur while the camera punches in and pulls out. */47 motionBlur?: boolean;48 /** Size of the box and cursor, around the frame's center. */49 scale?: number;50 /** Frames to hold the first frame before anything moves. */51 delay?: number;52 speed?: number;53}5455const LIGHT_GROUND: Partial<GradientParams> = {56 kind: "mist",57 background: "#efebe5",58 colors: ["#ffffff", "#f8f4ee", "#f0dccb", "#e2cbb9"],59 blur: 0.7,60 warp: 0.4,61 seed: 3,62 grain: 0.2,63};6465const THEMES = {66 dark: {67 ink: "#f6f1ec",68 muted: "rgba(246,241,236,0.56)",69 faint: "rgba(246,241,236,0.12)",70 accent: "#ff7d3f",71 ground: "hearth" as GshPresetId | undefined,72 groundParams: undefined as Partial<GradientParams> | undefined,73 groundOffset: 4,74 scrim: "5,3,3",75 scrimAlpha: 0.6,76 card: "#16120f",77 border: "rgba(255,236,222,0.09)",78 shadow: "0 40px 90px -24px rgba(0,0,0,0.7)",79 send: "rgba(246,241,236,0.12)",80 sendArmed: "#f6f1ec",81 sendGlyph: "#16120f",82 cursorFill: "#ffffff",83 cursorStroke: "#15141d",84 },85 light: {86 ink: "#1b1612",87 muted: "rgba(27,22,18,0.54)",88 faint: "rgba(27,22,18,0.1)",89 accent: "#e0561c",90 ground: undefined as GshPresetId | undefined,91 groundParams: LIGHT_GROUND as Partial<GradientParams> | undefined,92 groundOffset: 2,93 scrim: "239,235,229",94 scrimAlpha: 0.35,95 card: "#ffffff",96 border: "rgba(40,24,10,0.07)",97 shadow:98 "0 1px 3px rgba(40,24,10,0.06), 0 36px 80px -24px rgba(40,24,10,0.24)",99 send: "rgba(27,22,18,0.07)",100 sendArmed: "#1b1612",101 sendGlyph: "#ffffff",102 cursorFill: "#1b1612",103 cursorStroke: "#ffffff",104 },105};106107const BEAT = {108 typeA: 2,109 punch: 24,110 punchLen: 12,111 focusLen: 22,112 pull: 60,113 pullLen: 24,114 post: 72,115 postLen: 30,116 cursor: 82,117 press: 108,118};119120const TRACK = -0.012;121const FONT_PX = 200;122const CAMERA = Easing.bezier(0.87, 0, 0.13, 1);123const LIGHT_IN = Easing.bezier(0.32, 0.72, 0, 1);124const CHAR = Easing.bezier(0.65, 0, 0.35, 1);125const CLAMP = {126 extrapolateLeft: "clamp",127 extrapolateRight: "clamp",128} as const;129130type Measure = (s: string) => number;131132function buildMeasure(_version: number, fontFamily: string): Measure {133 const ctx = document.createElement("canvas").getContext("2d");134 const cache: Record<string, number> = {};135 return (s: string) => {136 if (cache[s] === undefined) {137 if (!ctx) return s.length * 0.52;138 ctx.font = `400 ${FONT_PX}px "${fontFamily}"`;139 cache[s] =140 ctx.measureText(s).width / FONT_PX + TRACK * Array.from(s).length;141 }142 return cache[s];143 };144}145146function useMeasure(fontFamily: string) {147 const [version, setVersion] = useState(0);148 const [handle] = useState(() => delayRender("caret-dolly: measuring"));149 const released = useRef(false);150 useEffect(() => {151 let live = true;152 const bump = () => {153 if (live) setVersion((v) => v + 1);154 };155 document.fonts.addEventListener("loadingdone", bump);156 Promise.all([157 face.waitUntilDone(),158 document.fonts.load(`400 100px "${fontFamily}"`),159 ])160 .catch(() => undefined)161 .then(() => {162 bump();163 if (!released.current) {164 released.current = true;165 continueRender(handle);166 }167 });168 return () => {169 live = false;170 document.fonts.removeEventListener("loadingdone", bump);171 };172 }, [handle, fontFamily]);173 return useMemo(174 () => buildMeasure(version, fontFamily),175 [version, fontFamily],176 );177}178179function Icon({180 size,181 color,182 children,183}: {184 size: number;185 color: string;186 children: ReactNode;187}) {188 return (189 <svg190 viewBox="0 0 24 24"191 width={size}192 height={size}193 fill="none"194 stroke={color}195 strokeWidth={1.6}196 strokeLinecap="round"197 strokeLinejoin="round"198 style={{ display: "block", flexShrink: 0 }}199 aria-hidden200 >201 {children}202 </svg>203 );204}205206interface Layout {207 T: number;208 LH: number;209 cardX: number;210 cardY: number;211 cardW: number;212 cardH: number;213 pad: number;214 u: number;215 lines: { start: number; end: number }[];216 charX: (i: number) => number;217 lineOf: (i: number) => number;218 lineY: (li: number) => number;219 sendX: number;220 sendY: number;221 sendD: number;222}223224/** The foreground at `scale`, around the frame's center; nothing extra at 1. */225function ScaleLayer({226 scale,227 children,228}: {229 scale: number;230 children: React.ReactNode;231}) {232 if (scale === 1) return children;233 return (234 <AbsoluteFill style={{ transform: `scale(${scale})` }}>235 {children}236 </AbsoluteFill>237 );238}239240export function CaretDolly({241 prompt = "Make a launch video for our new app with a bold title, product shots and a calm ending",242 focus = "launch video",243 chipLabel = "Video",244 modelLabel = "Acme 1",245 accent,246 ink,247 background,248 theme = "dark",249 ground,250 groundParams,251 fontFamily = face.fontFamily,252 zoom = 1,253 motionBlur = true,254 scale = 1,255 delay = 0,256 speed = 1,257}: CaretDollyProps) {258 const frame = Math.max(0, useCurrentFrame() - delay) * speed;259 const { width: W, height: H, fps, durationInFrames } = useVideoConfig();260 const c = THEMES[theme];261 const inkC = ink ?? c.ink;262 const hi = accent ?? c.accent;263 const preset = ground ?? (groundParams ? undefined : c.ground);264 const gParams = groundParams ?? (ground ? undefined : c.groundParams);265 const bg = background ?? gshParams(preset, gParams).background;266 const m = useMeasure(fontFamily);267 const portrait = H > W * 1.1;268 const filterId = `cd${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;269270 const found = prompt.indexOf(focus);271 const fs = found >= 0 && focus.length > 0 ? found : 0;272 const fe = found >= 0 && focus.length > 0 ? found + focus.length : 0;273 const focusLen = fe - fs;274 const postLen = prompt.length - fe;275 const rateA = Math.max(0.6, fs / 18);276 const rateF = Math.max(0.5, focusLen / BEAT.focusLen);277 const rateP = Math.max(2, postLen / BEAT.postLen);278 const punchEnd = BEAT.punch + BEAT.punchLen;279 const pullEnd = BEAT.pull + BEAT.pullLen;280 const postEnd = BEAT.post + postLen / rateP;281282 const typedA = (f: number) =>283 Math.max(0, Math.min(fs, (f - BEAT.typeA) * rateA));284 const typedF = (f: number) =>285 Math.max(0, Math.min(focusLen, (f - punchEnd) * rateF));286 const typedP = (f: number) =>287 Math.max(0, Math.min(postLen, (f - BEAT.post) * rateP));288289 const layout = ((): Layout | null => {290 if (!m) return null;291 const cardW = portrait ? W * 0.86 : Math.min(W * 0.66, H * 1.25);292 const T = portrait ? W * 0.05 : Math.max(H * 0.032, cardW * 0.031);293 const u = T / 22;294 const LH = T * 1.45;295 const pad = 22 * u;296 const room = cardW - pad * 2;297 const words = prompt.split(" ");298 const lines: { start: number; end: number }[] = [];299 let pos = 0;300 let cur = "";301 let curStart = 0;302 for (const w of words) {303 const next = cur.length > 0 ? `${cur} ${w}` : w;304 if (cur.length > 0 && m(next) * T > room) {305 lines.push({ start: curStart, end: curStart + cur.length });306 curStart = pos;307 cur = w;308 } else {309 cur = next;310 }311 pos += w.length + 1;312 }313 lines.push({ start: curStart, end: curStart + cur.length });314 const barH = 36 * u;315 const cardH = pad + lines.length * LH + 22 * u + barH + pad * 0.8;316 const cardX = (W - cardW) / 2;317 const cardY = H / 2 - cardH / 2;318 const lineOf = (i: number) => {319 for (let li = 0; li < lines.length; li++) {320 if (i <= lines[li].end) return li;321 }322 return lines.length - 1;323 };324 const charX = (i: number) => {325 const li = lineOf(i);326 return cardX + pad + m(prompt.slice(lines[li].start, i)) * T;327 };328 const lineY = (li: number) => cardY + pad + li * LH + LH / 2;329 const sendD = 34 * u;330 return {331 T,332 LH,333 cardX,334 cardY,335 cardW,336 cardH,337 pad,338 u,339 lines,340 charX,341 lineOf,342 lineY,343 sendX: cardX + cardW - pad * 0.8 - sendD / 2,344 sendY: cardY + cardH - pad * 0.8 - barH / 2,345 sendD,346 };347 })();348349 const cams = (() => {350 if (!layout) return [];351 const { T, charX, lineOf, lineY } = layout;352 const C = { x: W / 2, y: H / 2 };353 const A = portrait ? W * 0.11 : H * 0.1;354 const giant = (portrait ? W * 0.27 : Math.min(H * 0.36, W * 0.27)) * zoom;355 const sA = A / T;356 const sG = giant / T;357 const xAt = (ci: number) => {358 const lo = Math.floor(ci);359 const hiI = Math.min(prompt.length, lo + 1);360 const fr = ci - lo;361 if (lineOf(lo) !== lineOf(hiI)) return charX(lo);362 return charX(lo) + (charX(hiI) - charX(lo)) * CHAR(fr);363 };364 const goalA = (f: number) => {365 const ci = typedA(f);366 const li = lineOf(Math.floor(ci));367 return {368 x: (charX(layout.lines[li].start) + xAt(ci)) / 2,369 y: lineY(li),370 };371 };372 const goalG = (f: number) => {373 const ci = fs + typedF(f);374 const at = Math.floor(ci);375 let ws = at;376 while (ws > fs && prompt[ws - 1] !== " ") ws--;377 if (prompt[at] === " " && at > fs && ci - at < 0.5) {378 ws = at;379 while (ws > fs && prompt[ws - 1] !== " ") ws--;380 }381 const li = lineOf(at);382 return { x: (charX(ws) + xAt(ci)) / 2, y: lineY(li) };383 };384 const K = { x: charX(fs), y: lineY(lineOf(fs)) };385 const Fp = { x: charX(fe), y: lineY(lineOf(Math.max(fs, fe - 1))) };386 const out: { x: number; y: number; s: number }[] = [];387 let fx = goalA(0).x;388 let fy = goalA(0).y;389 let scrStart = { x: 0, y: 0 };390 let scrPull = { x: 0, y: 0 };391 const total = Math.max(durationInFrames, pullEnd + 1);392 for (let f = 0; f < total; f++) {393 if (f < BEAT.punch) {394 const g = goalA(f);395 fx += (g.x - fx) * 0.32;396 fy += (g.y - fy) * 0.32;397 out.push({ x: fx, y: fy, s: sA });398 scrStart = { x: C.x + (K.x - fx) * sA, y: C.y + (K.y - fy) * sA };399 } else if (f < punchEnd) {400 const p = CAMERA((f - BEAT.punch) / BEAT.punchLen);401 const s = Math.exp(Math.log(sA) + (Math.log(sG) - Math.log(sA)) * p);402 const sx = scrStart.x + (C.x - scrStart.x) * p;403 const sy = scrStart.y + (C.y - scrStart.y) * p;404 fx = K.x - (sx - C.x) / s;405 fy = K.y - (sy - C.y) / s;406 out.push({ x: fx, y: fy, s });407 } else if (f < BEAT.pull) {408 const g = goalG(f);409 fx += (g.x - fx) * 0.3;410 fy += (g.y - fy) * 0.3;411 out.push({ x: fx, y: fy, s: sG });412 scrPull = { x: C.x + (Fp.x - fx) * sG, y: C.y + (Fp.y - fy) * sG };413 } else if (f < pullEnd) {414 const p = CAMERA((f - BEAT.pull) / BEAT.pullLen);415 const s = Math.exp(Math.log(sG) * (1 - p));416 const sx = scrPull.x + (Fp.x - scrPull.x) * p;417 const sy = scrPull.y + (Fp.y - scrPull.y) * p;418 out.push({ x: Fp.x - (sx - C.x) / s, y: Fp.y - (sy - C.y) / s, s });419 } else {420 out.push({ x: C.x, y: C.y, s: 1 });421 }422 }423 return out;424 })();425426 let content: ReactNode = <div />;427 if (layout && cams.length > 0) {428 const L = layout;429 const f = frame;430 const cam = cams[Math.min(cams.length - 1, Math.floor(f))];431 const prev =432 cams[Math.max(0, Math.min(cams.length - 1, Math.floor(f) - 1))];433 const push =434 f >= pullEnd435 ? interpolate(f, [pullEnd, durationInFrames], [1, 1.03], CLAMP)436 : 1;437 const s = cam.s * push;438 const zoomV = Math.abs(Math.log(cam.s) - Math.log(prev.s));439 const panV = Math.abs(cam.x - prev.x) * cam.s;440 const zoomBlur = Math.min(7, zoomV * 26);441 const bx = Math.min(12, zoomBlur + panV * 0.05);442 const by = zoomBlur;443444 const preOp =445 f < BEAT.punch446 ? 1447 : f < BEAT.pull448 ? interpolate(f, [BEAT.punch, BEAT.punch + 5], [1, 0], CLAMP)449 : interpolate(f, [BEAT.pull + 8, pullEnd], [0, 1], {450 ...CLAMP,451 easing: LIGHT_IN,452 });453 const shown =454 f < punchEnd455 ? Math.floor(typedA(f))456 : fs + Math.floor(typedF(f)) + Math.floor(typedP(f));457 const caretIdx = Math.min(prompt.length, shown);458459 const segs: ReactNode[] = [];460 L.lines.forEach((ln, li) => {461 const ranges: [number, number, number][] = [462 [ln.start, Math.min(ln.end, fs), preOp],463 [Math.max(ln.start, fs), Math.min(ln.end, fe), 1],464 [Math.max(ln.start, fe), ln.end, 1],465 ];466 ranges.forEach(([a, b, op], ri) => {467 const to = Math.min(b, shown);468 if (to <= a || op <= 0.001) return;469 segs.push(470 <div471 key={`s${li}-${ri}`}472 style={{473 position: "absolute",474 left: L.charX(a),475 top: L.lineY(li) - L.T / 2,476 fontSize: L.T,477 lineHeight: 1,478 whiteSpace: "pre",479 fontFamily,480 fontWeight: 400,481 letterSpacing: `${TRACK}em`,482 color: inkC,483 opacity: op,484 }}485 >486 {prompt.slice(a, to)}487 </div>,488 );489 });490 });491492 const typing =493 (f >= BEAT.typeA && f < BEAT.typeA + fs / rateA + 2) ||494 (f >= punchEnd && f < punchEnd + focusLen / rateF + 2) ||495 (f >= BEAT.post && f < postEnd + 2);496 const blinkOn = typing || Math.floor(f / 14) % 2 === 0;497 const caretFade =498 f >= postEnd + 4499 ? interpolate(f, [BEAT.press - 6, BEAT.press], [1, 0], CLAMP)500 : 1;501 const caretH = L.T * 1.18;502 const caretW = Math.max(L.T * 0.05, 1.6 / s);503 const caretLine = L.lineOf(Math.max(0, caretIdx === 0 ? 0 : caretIdx));504 const caret = (505 <div506 style={{507 position: "absolute",508 left: L.charX(caretIdx) + L.T * 0.04,509 top: L.lineY(caretLine) - caretH / 2,510 width: caretW,511 height: caretH,512 borderRadius: caretW,513 background: inkC,514 opacity: (blinkOn ? 1 : 0) * caretFade,515 }}516 />517 );518519 const surfaceIn = interpolate(f, [BEAT.pull + 6, pullEnd], [0, 1], {520 ...CLAMP,521 easing: LIGHT_IN,522 });523 const u = L.u;524 const pop = (at: number) =>525 spring({526 frame: f - at,527 fps,528 config: { mass: 0.5, damping: 12, stiffness: 200 },529 });530 const toolIn = [0, 1, 2, 3, 4].map((i) => pop(pullEnd - 8 + i * 2));531 const armed = interpolate(f, [postEnd, postEnd + 4], [0, 1], CLAMP);532 const PRESS = { mass: 0.5, damping: 14, stiffness: 260 };533 const dip =534 spring({ frame: f - BEAT.press + 2, fps, config: PRESS }) -535 spring({ frame: f - BEAT.press - 3, fps, config: PRESS });536 const isPressed = f >= BEAT.press;537 const sendScale = 1 - 0.06 * dip;538 const sendBg = isPressed539 ? hi540 : `color-mix(in oklab, ${c.sendArmed} ${(armed * 100).toFixed(1)}%, ${c.send})`;541 const glyph = isPressed542 ? "#ffffff"543 : `color-mix(in oklab, ${c.sendGlyph} ${(armed * 100).toFixed(1)}%, ${c.muted})`;544 const stopIn = spring({545 frame: f - BEAT.press - 3,546 fps,547 config: { mass: 0.5, damping: 12, stiffness: 200 },548 });549 const arrowOut = interpolate(f - BEAT.press, [1, 5], [1, 0], CLAMP);550 const spin = interpolate(f - BEAT.press, [4, 12], [0, 1], {551 ...CLAMP,552 easing: LIGHT_IN,553 });554 const labelF = 15 * u;555 const ctrlD = 32 * u;556557 const card = (558 <div559 style={{560 position: "absolute",561 left: L.cardX,562 top: L.cardY,563 width: L.cardW,564 height: L.cardH,565 borderRadius: 22 * u,566 background: c.card,567 boxShadow: `inset 0 0 0 1px ${c.border}, ${c.shadow}`,568 opacity: surfaceIn,569 transform: `scale(${(0.97 + 0.03 * surfaceIn).toFixed(4)})`,570 }}571 >572 <div573 style={{574 position: "absolute",575 left: L.pad * 0.8,576 right: L.pad * 0.8,577 bottom: L.pad * 0.8,578 height: 36 * u,579 display: "flex",580 alignItems: "center",581 gap: 8 * u,582 fontFamily,583 fontWeight: 400,584 fontSize: labelF,585 color: c.muted,586 }}587 >588 <div589 style={{590 width: ctrlD,591 height: ctrlD,592 borderRadius: ctrlD,593 boxShadow: `inset 0 0 0 1px ${c.faint}`,594 display: "flex",595 alignItems: "center",596 justifyContent: "center",597 transform: `scale(${toolIn[0].toFixed(4)})`,598 }}599 >600 <Icon size={18 * u} color={c.muted}>601 <path d="M12 5v14M5 12h14" />602 </Icon>603 </div>604 <div605 style={{606 height: ctrlD,607 padding: `0 ${12 * u}px 0 ${10 * u}px`,608 borderRadius: ctrlD,609 boxShadow: `inset 0 0 0 1px ${c.faint}`,610 display: "flex",611 alignItems: "center",612 gap: 6 * u,613 whiteSpace: "pre",614 transform: `scale(${toolIn[1].toFixed(4)})`,615 transformOrigin: "0% 50%",616 }}617 >618 <Icon size={16 * u} color={c.muted}>619 <rect x="3.5" y="5" width="17" height="14" rx="2.5" />620 <path d="M3.5 9.5h17M8 5v4.5M12 5v4.5M16 5v4.5" />621 </Icon>622 {chipLabel}623 </div>624 <div style={{ flex: 1 }} />625 <div626 style={{627 display: "flex",628 alignItems: "center",629 gap: 4 * u,630 whiteSpace: "pre",631 opacity: Math.min(1, toolIn[2]),632 }}633 >634 {modelLabel}635 <Icon size={14 * u} color={c.muted}>636 <path d="M7 10l5 5 5-5" />637 </Icon>638 </div>639 <div640 style={{641 position: "relative",642 width: L.sendD,643 height: L.sendD,644 flexShrink: 0,645 transform: `scale(${(toolIn[4] * sendScale).toFixed(4)})`,646 }}647 >648 <div649 style={{650 position: "absolute",651 inset: 0,652 borderRadius: L.sendD,653 background: sendBg,654 display: "flex",655 alignItems: "center",656 justifyContent: "center",657 }}658 >659 <div660 style={{661 opacity: arrowOut,662 transform: `translateY(${(-6 * u * (1 - arrowOut)).toFixed(3)}px)`,663 }}664 >665 <Icon size={18 * u} color={glyph}>666 <path d="M12 19V5M6 11l6-6 6 6" />667 </Icon>668 </div>669 {isPressed ? (670 <div671 style={{672 position: "absolute",673 width: 11 * u,674 height: 11 * u,675 borderRadius: 2.5 * u,676 background: "#ffffff",677 transform: `scale(${stopIn.toFixed(4)})`,678 }}679 />680 ) : null}681 </div>682 {isPressed ? (683 <svg684 viewBox="0 0 40 40"685 width={L.sendD + 7 * u}686 height={L.sendD + 7 * u}687 style={{688 position: "absolute",689 left: -3.5 * u,690 top: -3.5 * u,691 opacity: spin,692 transform: `rotate(${((f - BEAT.press) * 9).toFixed(2)}deg)`,693 }}694 aria-hidden695 >696 <circle697 cx="20"698 cy="20"699 r="18.5"700 fill="none"701 stroke={hi}702 strokeWidth={1.4}703 strokeLinecap="round"704 strokeDasharray="30 200"705 />706 </svg>707 ) : null}708 </div>709 </div>710 </div>711 );712713 const world = (714 <div715 style={{716 position: "absolute",717 left: 0,718 top: 0,719 width: W,720 height: H,721 transformOrigin: "0 0",722 transform: `translate(${(W / 2).toFixed(2)}px, ${(H / 2).toFixed(2)}px) scale(${s.toFixed(5)}) translate(${(-cam.x).toFixed(3)}px, ${(-cam.y).toFixed(3)}px)`,723 }}724 >725 {card}726 {segs}727 {caret}728 </div>729 );730731 const curSize = portrait ? W * 0.05 : H * 0.05;732 const cursorP = spring({733 frame: f - BEAT.cursor,734 fps,735 config: { mass: 0.8, damping: 20, stiffness: 140 },736 });737 const cursorPy = spring({738 frame: f - BEAT.cursor - 3,739 fps,740 config: { mass: 0.8, damping: 20, stiffness: 140 },741 });742 const tx = W / 2 + (L.sendX + L.sendD * 0.12 - W / 2) * s;743 const ty = H / 2 + (L.sendY + L.sendD * 0.18 - H / 2) * s;744 const sx0 = W * (portrait ? 0.96 : 0.9);745 const sy0 = H * 1.06;746 const away = spring({747 frame: f - BEAT.press - 8,748 fps,749 config: { mass: 0.8, damping: 20, stiffness: 140 },750 });751 const curX = sx0 + (tx - sx0) * cursorP + curSize * 1.1 * away;752 const curY = sy0 + (ty - sy0) * cursorPy + curSize * 1.3 * away;753 const click = dip;754 const cursor =755 f >= BEAT.cursor ? (756 <svg757 viewBox="0 0 24 24"758 width={curSize}759 height={curSize}760 style={{761 position: "absolute",762 left: curX - curSize * 0.17,763 top: curY - curSize * 0.1,764 transform: `scale(${(1 - 0.12 * click).toFixed(4)})`,765 transformOrigin: "17% 10%",766 filter: "drop-shadow(0 2px 4px rgba(0,0,0,0.28))",767 }}768 aria-hidden769 >770 <path771 d="M4.5 2.5v16.2l4.4-4.1 2.9 6.6 2.7-1.2-2.9-6.5h6.1z"772 fill={c.cursorFill}773 stroke={c.cursorStroke}774 strokeWidth={1.3}775 strokeLinejoin="round"776 />777 </svg>778 ) : null;779780 content = (781 <>782 <svg width="0" height="0" style={{ position: "absolute" }} aria-hidden>783 <filter id={filterId} x="-10%" y="-10%" width="120%" height="120%">784 <feGaussianBlur785 stdDeviation={`${bx.toFixed(2)} ${by.toFixed(2)}`}786 />787 </filter>788 </svg>789 <AbsoluteFill790 style={{791 filter: motionBlur && bx > 0.2 ? `url(#${filterId})` : undefined,792 }}793 >794 {world}795 </AbsoluteFill>796 {cursor}797 </>798 );799 }800801 return (802 <AbsoluteFill style={{ background: bg, overflow: "hidden" }}>803 {background === undefined ? (804 <>805 <GshGround806 preset={preset}807 params={gParams}808 timeOffset={c.groundOffset}809 timeScale={0.6}810 />811 <AbsoluteFill812 style={{813 background: `radial-gradient(${portrait ? "90% 46%" : "64% 60%"} at 50% 50%, rgba(${c.scrim},${c.scrimAlpha}) 0%, rgba(${c.scrim},0) 100%)`,814 }}815 />816 </>817 ) : null}818 <ScaleLayer scale={scale}>{content}</ScaleLayer>819 </AbsoluteFill>820 );821}822823export default CaretDolly;









