Math Curve Background
boldkit/math-curve-backgroundFreeComponent
Ambient animated mathematical curve background layer with neubrutalism aesthetics — wraps content with a slow-moving curve animation
Live preview
live · rendered by the registry
Rendered by boldkit on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://boldkit.dev/r/math-curve-background.jsonSource
1import * as React from 'react'2import { cn } from '@/lib/utils'3import { ErrorBoundary } from '@/components/ErrorBoundary'4import {5 buildPath,6 getPoint,7 getAngle,8 getDetailScale,9 getCurvePulseDuration,10 type BackgroundCurveKey,11} from '@/lib/math-curves'1213const SPEED_DURATION: Record<string, number> = {14 slow: 9000,15 normal: 5500,16 fast: 3000,17}1819export interface MathCurveBackgroundProps extends React.HTMLAttributes<HTMLDivElement> {20 curve?: BackgroundCurveKey21 speed?: 'slow' | 'normal' | 'fast'22 opacity?: number23 trackColor?: string24 headColor?: string25 strokeWidth?: number26 children?: React.ReactNode27}2829const MathCurveBackground = React.forwardRef<HTMLDivElement, MathCurveBackgroundProps>(30 (31 {32 className,33 curve = 'rose',34 speed = 'slow',35 opacity = 0.15,36 trackColor,37 headColor,38 strokeWidth = 2,39 children,40 ...props41 },42 ref43 ) => {44 const pathRef = React.useRef<SVGPathElement>(null)45 const rectRef = React.useRef<SVGRectElement>(null)46 const rafRef = React.useRef<number>(0)47 const startTimeRef = React.useRef<number>(performance.now())4849 const durationMs = SPEED_DURATION[speed] ?? SPEED_DURATION.slow50 const HEAD_SIZE = 85152 const initialTrackPath = React.useMemo(() => buildPath(curve, 1.0), [curve])5354 React.useEffect(() => {55 startTimeRef.current = performance.now()5657 const tick = () => {58 const now = performance.now()59 const elapsed = (now - startTimeRef.current) % durationMs60 const progress = elapsed / durationMs61 const detailScale = getDetailScale(now, getCurvePulseDuration(curve))6263 const { x, y } = getPoint(curve, progress, detailScale)64 const angle = getAngle(curve, progress, detailScale)6566 if (pathRef.current) {67 pathRef.current.setAttribute('d', buildPath(curve, detailScale))68 }6970 if (rectRef.current) {71 const cx = x72 const cy = y73 rectRef.current.setAttribute('x', String(cx - HEAD_SIZE / 2))74 rectRef.current.setAttribute('y', String(cy - HEAD_SIZE / 2))75 rectRef.current.setAttribute('transform', `rotate(${angle} ${cx} ${cy})`)76 }7778 rafRef.current = requestAnimationFrame(tick)79 }8081 rafRef.current = requestAnimationFrame(tick)8283 return () => {84 cancelAnimationFrame(rafRef.current)85 }86 }, [curve, speed, durationMs, strokeWidth])8788// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from boldkit
All 94 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | boldkit | Components | Free | 2 deps | |
| Alertalert | boldkit | Components | Free | 2 deps | |
| Alert Dialogalert-dialog | boldkit | Components | Free | 1 dep | |
| ASCII Shapesascii-shapes | boldkit | Components | Free | no deps | |
| Aspect Ratioaspect-ratio | boldkit | Components | Free | 1 dep | |
| Avataravatar | boldkit | Components | Free | 1 dep | |
| Badgebadge | boldkit | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | boldkit | Components | Free | 2 deps |
