/* eslint-disable */ // Dust Text Reveal — Originkit "use client"; import { useEffect, useMemo, useRef, useState, useCallback } from "react"; import { motion, useInView } from "framer-motion"; interface MagicTextRevealProps { text?: string; color?: string; font?: { fontFamily?: string; fontSize?: string; textAlign?: string; fontWeight?: number; letterSpacing?: string; }; noise?: number; transition?: { type?: string; duration?: number; ease?: string | [number, number, number, number]; }; density?: number; resetOnMouseLeave?: boolean; tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "div" | "span"; playMode?: "hover" | "enter"; startAlign?: "top" | "center" | "bottom"; replay?: boolean; } // Density slider (1..10) → particle sampling multiplier (lower = denser). const DENSITY_MAP = [6, 5.4, 4.9, 4.3, 3.8, 3.2, 2.7, 2.1, 1.6, 1]; const NAMED_EASES: Record = { linear: [0, 0, 1, 1], easeIn: [0.42, 0, 1, 1], easeOut: [0, 0, 0.58, 1], easeInOut: [0.42, 0, 0.58, 1], }; function cubicBezierEase(x1: number, y1: number, x2: number, y2: number) { const cx = 3 * x1; const bx = 3 * (x2 - x1) - cx; const ax = 1 - cx - bx; const cy = 3 * y1; const by = 3 * (y2 - y1) - cy; const ay = 1 - cy - by; const sampleX = (t: number) => ((ax * t + bx) * t + cx) * t; const sampleY = (t: number) => ((ay * t + by) * t + cy) * t; const dX = (t: number) => (3 * ax * t + 2 * bx) * t + cx; return (p: number) => { let t = p; for (let i = 0; i < 8; i++) { const x = sampleX(t) - p; const dd = dX(t); if (Math.abs(x) < 1e-4 || Math.abs(dd) < 1e-6) break; t -= x / dd; } t = t < 0 ? 0 : t > 1 ? 1 : t; return sampleY(t); }; } function easeToFn(ease: any) { if (Array.isArray(ease) && ease.length === 4) return cubicBezierEase(ease[0], ease[1], ease[2], ease[3]); const b = (typeof ease === "string" && NAMED_EASES[ease]) || NAMED_EASES.easeInOut; return cubicBezierEase(b[0], b[1], b[2], b[3]); } // Hand-off points on the form timeline (p). The real text fades in from TEXT_IN // and is fully opaque by FADE_OUT; the particles only start leaving at FADE_OUT. const TEXT_IN = 0.7; const FADE_OUT = 0.85; const renderCanvas = ({ canvasRef, wrapperRef, globalDpr, props, wrapperSize, particlesRef, transformedDensity, color, }: any) => { if ( !wrapperRef.current || !canvasRef.current || !wrapperSize.width || !wrapperSize.height ) return; const canvas = canvasRef.current; const { width, height } = wrapperSize; canvas.width = width * globalDpr; canvas.height = height * globalDpr; canvas.style.width = `${width}px`; canvas.style.height = `${height}px`; const ctx = canvas.getContext("2d"); if (!ctx) return; const textX = canvas.width / 2; const textY = canvas.height / 2; const formattedFontFamily = formatFontFamilies(props.font.fontFamily); const fontSize = parseInt(props.font.fontSize?.replace("px", "") || "50"); const font = `${props.font.fontWeight ?? 400} ${fontSize * globalDpr}px ${formattedFontFamily}`; const particles = createParticles( ctx, canvas, props.text, textX, textY, font, color, "center", transformedDensity, props.font.letterSpacing || "0px" ); particlesRef.current = particles; renderParticles(ctx, particles, globalDpr); }; const createParticles = ( ctx: any, canvas: any, text: any, textX: any, textY: any, font: any, color: any, alignment: any, transformedDensity: any, letterSpacing: any ) => { const particles: any[] = []; ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = color; ctx.font = font; ctx.textAlign = alignment; ctx.letterSpacing = letterSpacing; ctx.textBaseline = "middle"; ctx.imageSmoothingEnabled = true; ctx.fillText(text, textX, textY); const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); const data = imageData.data; const currentDPR = canvas.width / parseInt(canvas.style.width); const baseSampleRate = Math.max(2, Math.round(currentDPR)); const sampleRate = Math.max( 1, Math.round(baseSampleRate * transformedDensity) ); let minX = canvas.width; let maxX = 0; let minY = canvas.height; let maxY = 0; for (let y = 0; y < canvas.height; y += sampleRate) { for (let x = 0; x < canvas.width; x += sampleRate) { const index = (y * canvas.width + x) * 4; const alpha = data[index + 3]; if (alpha > 0) { minX = Math.min(minX, x); maxX = Math.max(maxX, x); minY = Math.min(minY, y); maxY = Math.max(maxY, y); } } } const textWidth = maxX - minX; const textHeight = maxY - minY; const spreadRadius = Math.max(textWidth, textHeight) * 0.1; for (let y = 0; y < canvas.height; y += sampleRate) { for (let x = 0; x < canvas.width; x += sampleRate) { const index = (y * canvas.width + x) * 4; const alpha = data[index + 3]; if (alpha > 0) { const originalAlpha = alpha / 255; const angle = Math.random() * Math.PI * 2; const distance = Math.random() * spreadRadius; const initialX = x + Math.cos(angle) * distance; const initialY = y + Math.sin(angle) * distance; const particle = { x: initialX, y: initialY, originalX: x, originalY: y, color: `rgba(${data[index]}, ${data[index + 1]}, ${data[index + 2]}, ${originalAlpha})`, opacity: originalAlpha * 0.3, sparkleOp: originalAlpha * 0.3, originalAlpha, velocityX: 0, velocityY: 0, angle: Math.random() * Math.PI * 2, speed: 0, floatingOffsetX: 0, floatingOffsetY: 0, floatingSpeed: Math.random() * 2 + 1, floatingAngle: Math.random() * Math.PI * 2, targetOpacity: Math.random() * originalAlpha * 0.5, sparkleSpeed: Math.random() * 2 + 1, }; particles.push(particle); } } } ctx.clearRect(0, 0, canvas.width, canvas.height); return particles; }; const updateParticles = ( particles: any, deltaTime: any, p: any, showText: any, setShowText: any, noise: any, speed: any ) => { const FLOAT_RADIUS = noise; const FLOAT_SPEED = speed; const NOISE_SCALE = 0.6; const CHAOS_FACTOR = 1.3; const time = Date.now() * 0.001; const inv = 1 - p; particles.forEach((particle: any) => { particle.floatingAngle += deltaTime * particle.floatingSpeed * (1 + Math.random() * CHAOS_FACTOR); const uniqueOffset = particle.floatingSpeed * 2e3; const noiseX = (Math.sin(time * particle.floatingSpeed + particle.floatingAngle) * 1.2 + Math.sin((time + uniqueOffset) * 0.5) * 0.8 + (Math.random() - 0.5) * CHAOS_FACTOR) * NOISE_SCALE; const noiseY = (Math.cos( time * particle.floatingSpeed + particle.floatingAngle * 1.5 ) * 0.6 + Math.cos((time + uniqueOffset) * 0.5) * 0.4 + (Math.random() - 0.5) * CHAOS_FACTOR) * NOISE_SCALE; const floatX = particle.originalX + FLOAT_RADIUS * noiseX; const floatY = particle.originalY + FLOAT_RADIUS * noiseY; const targetX = floatX + (particle.originalX - floatX) * p; const targetY = floatY + (particle.originalY - floatY) * p; const dx = targetX - particle.x; const dy = targetY - particle.y; const follow = 6 + p * 10; const jitterX = (Math.random() - 0.5) * FLOAT_SPEED * inv; const jitterY = (Math.random() - 0.5) * FLOAT_SPEED * inv; particle.x += dx * follow * deltaTime + jitterX; particle.y += dy * follow * deltaTime + jitterY; if (p >= 0.999) { particle.x = particle.originalX; particle.y = particle.originalY; } const opacityDiff = particle.targetOpacity - particle.sparkleOp; particle.sparkleOp += opacityDiff * particle.sparkleSpeed * deltaTime * 3; if (Math.abs(opacityDiff) < 0.01) { particle.targetOpacity = Math.random() < 0.5 ? Math.random() * 0.1 * particle.originalAlpha : particle.originalAlpha * 3; particle.sparkleSpeed = Math.random() * 3 + 1; } const idleOp = Math.max( 0, Math.min(particle.originalAlpha, particle.sparkleOp) ); const formFade = p < FADE_OUT ? 1 : Math.max(0, 1 - (p - FADE_OUT) / (1 - FADE_OUT)); particle.opacity = (idleOp + (particle.originalAlpha - idleOp) * p) * formFade; }); const formed = p > TEXT_IN; if (formed && !showText) setShowText(true); if (!formed && showText) setShowText(false); }; const renderParticles = (ctx: any, particles: any, globalDpr: any) => { ctx.save(); ctx.scale(globalDpr, globalDpr); const particlesByColor = new Map(); particles.forEach((particle: any) => { if (particle.opacity <= 0) return; const color = particle.color.replace( /[\d.]+\)$/, `${particle.opacity})` ); if (!particlesByColor.has(color)) { particlesByColor.set(color, []); } particlesByColor .get(color)! .push({ x: particle.x / globalDpr, y: particle.y / globalDpr }); }); particlesByColor.forEach((positions, color) => { ctx.fillStyle = color; positions.forEach(({ x, y }: any) => { ctx.fillRect(x, y, 1, 1); }); }); ctx.restore(); }; const cleanup = ({ canvasRef, particlesRef }: any) => { const canvas = canvasRef.current; const ctx = canvas?.getContext("2d"); if (canvas && ctx) { ctx.clearRect(0, 0, canvas.width, canvas.height); } if (particlesRef.current) { particlesRef.current = []; } }; const useWrapperSize = () => { const wrapperRef = useRef(null); const [wrapperSize, setWrapperSize] = useState<{ width: number | null; height: number | null; }>({ width: null, height: null }); useEffect(() => { if (wrapperRef.current) { const rect = wrapperRef.current.getBoundingClientRect(); setWrapperSize({ width: rect.width, height: rect.height }); } }, [wrapperRef]); return { wrapperSize, setWrapperSize, wrapperRef }; }; const useResizeObserver = ({ wrapperRef, wrapperSize, setWrapperSize, props, canvasRef, globalDpr, particlesRef, transformedDensity, color, }: any) => { useEffect(() => { const container = wrapperRef.current; if (!container) return; const resizeObserver = new ResizeObserver((entries) => { for (const entry of entries) { const { width, height } = entry.contentRect; setWrapperSize({ width, height }); } renderCanvas({ canvasRef, wrapperRef, globalDpr, props, wrapperSize, particlesRef, transformedDensity, color, }); }); resizeObserver.observe(container); return () => { resizeObserver.disconnect(); }; }, [wrapperRef]); }; const parseFramerColor = (color: any): string => { const rgbMatch = color.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/); const rgbaMatch = color.match(/rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)/); if (rgbaMatch) { const [, r, g, b, a] = rgbaMatch; return `rgba(${r}, ${g}, ${b}, ${a})`; } else if (rgbMatch) { const [, r, g, b] = rgbMatch; return `rgba(${r}, ${g}, ${b}, 1)`; } console.warn("Could not parse color:", color); return "rgba(0, 0, 0, 1)"; }; const formatFontFamilies = (fontFamilyString: any = "sans-serif") => { return ( fontFamilyString + ", sans-serif" .split(",") .map((font: string) => font.trim().replace(/['"]/g, "")) .join(", ") ); }; function transformValue( input: number, inputRange: number[], outputRange: number[], clamp = false ): number { const [inputMin, inputMax] = inputRange; const [outputMin, outputMax] = outputRange; const progress = (input - inputMin) / (inputMax - inputMin); let result = outputMin + progress * (outputMax - outputMin); if (clamp) { if (outputMax > outputMin) { result = Math.min(Math.max(result, outputMin), outputMax); } else { result = Math.min(Math.max(result, outputMax), outputMin); } } return result; } const renderAnimatedTag = (props: any, color: any, showText: any) => { const Component: any = (motion as any)[props.tag]; const trDur = typeof props.transition?.duration === "number" ? props.transition.duration : 1; const inDur = trDur * (FADE_OUT - TEXT_IN); return ( {props.text} ); }; const waitForFont = async (fontFamily: any) => { if (typeof window === "undefined" || !("FontFace" in window)) return; try { const families = fontFamily .split(",") .map((f: string) => f.trim().replace(/['"]/g, "")); await Promise.race([ Promise.all( families.map((family: string) => (document as any).fonts?.load(`16px "${family}"`) ) ), new Promise((resolve) => setTimeout(resolve, 5e3)), ]); } catch (e) { console.warn("Font loading failed:", e); } }; function __OriginkitBase_MagicTextReveal({ text = "DUST TEXT REVEAL", color: colorProp = "rgba(255, 255, 255, 1)", font = { fontFamily: "Inter", fontSize: "50px", textAlign: "center", fontWeight: 400, }, noise = 100, transition = { type: "tween", duration: 1, ease: "easeInOut" }, density = 8, resetOnMouseLeave = true, tag = "h1", playMode = "enter", startAlign = "center", replay = true, }: MagicTextRevealProps) { const props = { text, color: colorProp, font, noise, transition, density, resetOnMouseLeave, tag, playMode, startAlign, replay, }; const canvasRef = useRef(null); const wrapperRef = useRef(null); const lastFontRef = useRef(null); const particlesRef = useRef([]); const animationFrameRef = useRef(null); const lastTimeRef = useRef(performance.now()); const formProgressRef = useRef(0); const [fontLoaded, setFontLoaded] = useState(false); const [isHovered, setIsHovered] = useState(false); const [entered, setEntered] = useState(false); const [showText, setShowText] = useState(false); const [hasBeenShown, setHasBeenShown] = useState(false); const active = props.playMode === "enter" ? entered : isHovered; const d = Math.max(1, Math.min(10, Math.round(props.density))); const transformedDensity = DENSITY_MAP[d - 1]; const trDuration = typeof props.transition?.duration === "number" ? props.transition.duration : 1; const derivedSpeed = Math.min( 3, Math.max(0.1, 0.5 / Math.max(0.1, trDuration)) ); const easeFn = useMemo( () => easeToFn(props.transition?.ease), [props.transition] ); const color = useMemo(() => parseFramerColor(props.color), [props.color]); const isInView = useInView(wrapperRef); const { wrapperSize, setWrapperSize } = useWrapperSize(); const globalDpr = useMemo(() => { if (typeof window !== "undefined") return window.devicePixelRatio * 1.5 || 1; return 1; }, []); const tranformedCanvasY = useMemo(() => { return transformValue( parseInt(props.font.fontSize?.replace("px", "") || "50"), [0, 100], [0, 5], true ); }, [props.font.fontSize]); const transformedY = tranformedCanvasY; useEffect(() => { if (!props.font.fontFamily) return; const loadFont = async () => { await waitForFont(props.font.fontFamily); setFontLoaded(true); }; loadFont(); }, [props.font.fontFamily]); useEffect(() => { if (!isInView) return; if (!fontLoaded) return; renderCanvas({ canvasRef, wrapperRef, globalDpr, props, wrapperSize, particlesRef, transformedDensity, color, }); // eslint-disable-next-line react-hooks/exhaustive-deps }, [fontLoaded, isInView, wrapperSize, color]); useEffect(() => { if (!isInView) return; const animate = (currentTime: number) => { const deltaTime = (currentTime - lastTimeRef.current) / 1e3; lastTimeRef.current = currentTime; const canvas = canvasRef.current; const ctx = canvas?.getContext("2d"); if (!canvas || !ctx || !particlesRef.current.length) { animationFrameRef.current = requestAnimationFrame(animate); return; } ctx.clearRect(0, 0, canvas.width, canvas.height); const target = active ? 1 : 0; const rate = deltaTime / Math.max(0.05, trDuration); const cur = formProgressRef.current; formProgressRef.current = cur < target ? Math.min(target, cur + rate) : Math.max(target, cur - rate); const p = easeFn(formProgressRef.current); updateParticles( particlesRef.current, deltaTime, p, showText, setShowText, props.noise, derivedSpeed ); renderParticles(ctx, particlesRef.current, globalDpr); animationFrameRef.current = requestAnimationFrame(animate); }; animationFrameRef.current = requestAnimationFrame(animate); return () => { if (animationFrameRef.current) { cancelAnimationFrame(animationFrameRef.current); } }; // eslint-disable-next-line react-hooks/exhaustive-deps }, [isInView, props.noise, derivedSpeed, trDuration, easeFn, globalDpr, active]); const handleMouseEnter = useCallback(() => { setIsHovered(true); setHasBeenShown(true); }, []); const handleMouseLeave = useCallback(() => { if (props.resetOnMouseLeave || !hasBeenShown) { setIsHovered(false); } }, [props.resetOnMouseLeave, hasBeenShown]); useEffect(() => { if (props.playMode !== "enter") return; const el = wrapperRef.current; if (!el) return; setEntered(false); let has = false; const threshold = props.startAlign === "top" ? 0 : props.startAlign === "center" ? 0.5 : 1; const io = new IntersectionObserver( ([entry]) => { if (entry.isIntersecting) { if (!has) { has = true; setEntered(true); if (!props.replay) io.disconnect(); } } else if (props.replay) { has = false; setEntered(false); } }, { threshold } ); io.observe(el); return () => io.disconnect(); }, [props.playMode, props.startAlign, props.replay]); useEffect(() => { if (props.playMode !== "enter" || active || isInView) return; formProgressRef.current = 0; setShowText(false); }, [active, props.playMode, isInView]); useEffect(() => { renderCanvas({ canvasRef, wrapperRef, globalDpr, props, wrapperSize, particlesRef, transformedDensity, color, }); const currentFont = props.font.fontFamily || "sans-serif"; return handleFontChange({ currentFont, lastFontRef, props, canvasRef, wrapperRef, globalDpr, wrapperSize, particlesRef, transformedDensity, color, }); // eslint-disable-next-line react-hooks/exhaustive-deps }, [props, wrapperSize]); useResizeObserver({ wrapperRef, wrapperSize, setWrapperSize, props, canvasRef, globalDpr, particlesRef, transformedDensity, color, }); return (
{renderAnimatedTag(props, color, showText)}
); } function handleFontChange({ currentFont, lastFontRef, props, canvasRef, wrapperRef, globalDpr, wrapperSize, particlesRef, transformedDensity, color, }: any) { if (currentFont !== lastFontRef.current) { lastFontRef.current = currentFont; } return () => { cleanup({ canvasRef, particlesRef }); }; } const __originkitPresetProps = { "density": 10, "playMode": "hover" }; export default function MagicTextReveal(props: Record) { return <__OriginkitBase_MagicTextReveal {...(__originkitPresetProps as Record)} {...props} />; }
/* eslint-disable */ // Dust Text Reveal — Originkit "use client"; import { useEffect, useMemo, useRef, useState, useCallback } from "react"; import { motion, useInView } from "framer-motion"; interface MagicTextRevealProps { text?: string; color?: string; font?: { fontFamily?: string; fontSize?: string; textAlign?: string; fontWeight?: number; letterSpacing?: string; }; noise?: number; transition?: { type?: string; duration?: number; ease?: string | [number, number, number, number]; }; density?: number; resetOnMouseLeave?: boolean; tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "div" | "span"; playMode?: "hover" | "enter"; startAlign?: "top" | "center" | "bottom"; replay?: boolean; } // Density slider (1..10) → particle sampling multiplier (lower = denser). const DENSITY_MAP = [6, 5.4, 4.9, 4.3, 3.8, 3.2, 2.7, 2.1, 1.6, 1]; const NAMED_EASES: Record = { linear: [0, 0, 1, 1], easeIn: [0.42, 0, 1, 1], easeOut: [0, 0, 0.58, 1], easeInOut: [0.42, 0, 0.58, 1], }; function cubicBezierEase(x1: number, y1: number, x2: number, y2: number) { const cx = 3 * x1; const bx = 3 * (x2 - x1) - cx; const ax = 1 - cx - bx; const cy = 3 * y1; const by = 3 * (y2 - y1) - cy; const ay = 1 - cy - by; const sampleX = (t: number) => ((ax * t + bx) * t + cx) * t; const sampleY = (t: number) => ((ay * t + by) * t + cy) * t; const dX = (t: number) => (3 * ax * t + 2 * bx) * t + cx; return (p: number) => { let t = p; for (let i = 0; i < 8; i++) { const x = sampleX(t) - p; const dd = dX(t); if (Math.abs(x) < 1e-4 || Math.abs(dd) < 1e-6) break; t -= x / dd; } t = t < 0 ? 0 : t > 1 ? 1 : t; return sampleY(t); }; } function easeToFn(ease: any) { if (Array.isArray(ease) && ease.length === 4) return cubicBezierEase(ease[0], ease[1], ease[2], ease[3]); const b = (typeof ease === "string" && NAMED_EASES[ease]) || NAMED_EASES.easeInOut; return cubicBezierEase(b[0], b[1], b[2], b[3]); } // Hand-off points on the form timeline (p). The real text fades in from TEXT_IN // and is fully opaque by FADE_OUT; the particles only start leaving at FADE_OUT. const TEXT_IN = 0.7; const FADE_OUT = 0.85; const renderCanvas = ({ canvasRef, wrapperRef, globalDpr, props, wrapperSize, particlesRef, transformedDensity, color, }: any) => { if ( !wrapperRef.current || !canvasRef.current || !wrapperSize.width || !wrapperSize.height ) return; const canvas = canvasRef.current; const { width, height } = wrapperSize; canvas.width = width * globalDpr; canvas.height = height * globalDpr; canvas.style.width = `${width}px`; canvas.style.height = `${height}px`; const ctx = canvas.getContext("2d"); if (!ctx) return; const textX = canvas.width / 2; const textY = canvas.height / 2; const formattedFontFamily = formatFontFamilies(props.font.fontFamily); const fontSize = parseInt(props.font.fontSize?.replace("px", "") || "50"); const font = `${props.font.fontWeight ?? 400} ${fontSize * globalDpr}px ${formattedFontFamily}`; const particles = createParticles( ctx, canvas, props.text, textX, textY, font, color, "center", transformedDensity, props.font.letterSpacing || "0px" ); particlesRef.current = particles; renderParticles(ctx, particles, globalDpr); }; const createParticles = ( ctx: any, canvas: any, text: any, textX: any, textY: any, font: any, color: any, alignment: any, transformedDensity: any, letterSpacing: any ) => { const particles: any[] = []; ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = color; ctx.font = font; ctx.textAlign = alignment; ctx.letterSpacing = letterSpacing; ctx.textBaseline = "middle"; ctx.imageSmoothingEnabled = true; ctx.fillText(text, textX, textY); const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); const data = imageData.data; const currentDPR = canvas.width / parseInt(canvas.style.width); const baseSampleRate = Math.max(2, Math.round(currentDPR)); const sampleRate = Math.max( 1, Math.round(baseSampleRate * transformedDensity) ); let minX = canvas.width; let maxX = 0; let minY = canvas.height; let maxY = 0; for (let y = 0; y < canvas.height; y += sampleRate) { for (let x = 0; x < canvas.width; x += sampleRate) { const index = (y * canvas.width + x) * 4; const alpha = data[index + 3]; if (alpha > 0) { minX = Math.min(minX, x); maxX = Math.max(maxX, x); minY = Math.min(minY, y); maxY = Math.max(maxY, y); } } } const textWidth = maxX - minX; const textHeight = maxY - minY; const spreadRadius = Math.max(textWidth, textHeight) * 0.1; for (let y = 0; y < canvas.height; y += sampleRate) { for (let x = 0; x < canvas.width; x += sampleRate) { const index = (y * canvas.width + x) * 4; const alpha = data[index + 3]; if (alpha > 0) { const originalAlpha = alpha / 255; const angle = Math.random() * Math.PI * 2; const distance = Math.random() * spreadRadius; const initialX = x + Math.cos(angle) * distance; const initialY = y + Math.sin(angle) * distance; const particle = { x: initialX, y: initialY, originalX: x, originalY: y, color: `rgba(${data[index]}, ${data[index + 1]}, ${data[index + 2]}, ${originalAlpha})`, opacity: originalAlpha * 0.3, sparkleOp: originalAlpha * 0.3, originalAlpha, velocityX: 0, velocityY: 0, angle: Math.random() * Math.PI * 2, speed: 0, floatingOffsetX: 0, floatingOffsetY: 0, floatingSpeed: Math.random() * 2 + 1, floatingAngle: Math.random() * Math.PI * 2, targetOpacity: Math.random() * originalAlpha * 0.5, sparkleSpeed: Math.random() * 2 + 1, }; particles.push(particle); } } } ctx.clearRect(0, 0, canvas.width, canvas.height); return particles; }; const updateParticles = ( particles: any, deltaTime: any, p: any, showText: any, setShowText: any, noise: any, speed: any ) => { const FLOAT_RADIUS = noise; const FLOAT_SPEED = speed; const NOISE_SCALE = 0.6; const CHAOS_FACTOR = 1.3; const time = Date.now() * 0.001; const inv = 1 - p; particles.forEach((particle: any) => { particle.floatingAngle += deltaTime * particle.floatingSpeed * (1 + Math.random() * CHAOS_FACTOR); const uniqueOffset = particle.floatingSpeed * 2e3; const noiseX = (Math.sin(time * particle.floatingSpeed + particle.floatingAngle) * 1.2 + Math.sin((time + uniqueOffset) * 0.5) * 0.8 + (Math.random() - 0.5) * CHAOS_FACTOR) * NOISE_SCALE; const noiseY = (Math.cos( time * particle.floatingSpeed + particle.floatingAngle * 1.5 ) * 0.6 + Math.cos((time + uniqueOffset) * 0.5) * 0.4 + (Math.random() - 0.5) * CHAOS_FACTOR) * NOISE_SCALE; const floatX = particle.originalX + FLOAT_RADIUS * noiseX; const floatY = particle.originalY + FLOAT_RADIUS * noiseY; const targetX = floatX + (particle.originalX - floatX) * p; const targetY = floatY + (particle.originalY - floatY) * p; const dx = targetX - particle.x; const dy = targetY - particle.y; const follow = 6 + p * 10; const jitterX = (Math.random() - 0.5) * FLOAT_SPEED * inv; const jitterY = (Math.random() - 0.5) * FLOAT_SPEED * inv; particle.x += dx * follow * deltaTime + jitterX; particle.y += dy * follow * deltaTime + jitterY; if (p >= 0.999) { particle.x = particle.originalX; particle.y = particle.originalY; } const opacityDiff = particle.targetOpacity - particle.sparkleOp; particle.sparkleOp += opacityDiff * particle.sparkleSpeed * deltaTime * 3; if (Math.abs(opacityDiff) < 0.01) { particle.targetOpacity = Math.random() < 0.5 ? Math.random() * 0.1 * particle.originalAlpha : particle.originalAlpha * 3; particle.sparkleSpeed = Math.random() * 3 + 1; } const idleOp = Math.max( 0, Math.min(particle.originalAlpha, particle.sparkleOp) ); const formFade = p < FADE_OUT ? 1 : Math.max(0, 1 - (p - FADE_OUT) / (1 - FADE_OUT)); particle.opacity = (idleOp + (particle.originalAlpha - idleOp) * p) * formFade; }); const formed = p > TEXT_IN; if (formed && !showText) setShowText(true); if (!formed && showText) setShowText(false); }; const renderParticles = (ctx: any, particles: any, globalDpr: any) => { ctx.save(); ctx.scale(globalDpr, globalDpr); const particlesByColor = new Map(); particles.forEach((particle: any) => { if (particle.opacity <= 0) return; const color = particle.color.replace( /[\d.]+\)$/, `${particle.opacity})` ); if (!particlesByColor.has(color)) { particlesByColor.set(color, []); } particlesByColor .get(color)! .push({ x: particle.x / globalDpr, y: particle.y / globalDpr }); }); particlesByColor.forEach((positions, color) => { ctx.fillStyle = color; positions.forEach(({ x, y }: any) => { ctx.fillRect(x, y, 1, 1); }); }); ctx.restore(); }; const cleanup = ({ canvasRef, particlesRef }: any) => { const canvas = canvasRef.current; const ctx = canvas?.getContext("2d"); if (canvas && ctx) { ctx.clearRect(0, 0, canvas.width, canvas.height); } if (particlesRef.current) { particlesRef.current = []; } }; const useWrapperSize = () => { const wrapperRef = useRef(null); const [wrapperSize, setWrapperSize] = useState<{ width: number | null; height: number | null; }>({ width: null, height: null }); useEffect(() => { if (wrapperRef.current) { const rect = wrapperRef.current.getBoundingClientRect(); setWrapperSize({ width: rect.width, height: rect.height }); } }, [wrapperRef]); return { wrapperSize, setWrapperSize, wrapperRef }; }; const useResizeObserver = ({ wrapperRef, wrapperSize, setWrapperSize, props, canvasRef, globalDpr, particlesRef, transformedDensity, color, }: any) => { useEffect(() => { const container = wrapperRef.current; if (!container) return; const resizeObserver = new ResizeObserver((entries) => { for (const entry of entries) { const { width, height } = entry.contentRect; setWrapperSize({ width, height }); } renderCanvas({ canvasRef, wrapperRef, globalDpr, props, wrapperSize, particlesRef, transformedDensity, color, }); }); resizeObserver.observe(container); return () => { resizeObserver.disconnect(); }; }, [wrapperRef]); }; const parseFramerColor = (color: any): string => { const rgbMatch = color.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/); const rgbaMatch = color.match(/rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)/); if (rgbaMatch) { const [, r, g, b, a] = rgbaMatch; return `rgba(${r}, ${g}, ${b}, ${a})`; } else if (rgbMatch) { const [, r, g, b] = rgbMatch; return `rgba(${r}, ${g}, ${b}, 1)`; } console.warn("Could not parse color:", color); return "rgba(0, 0, 0, 1)"; }; const formatFontFamilies = (fontFamilyString: any = "sans-serif") => { return ( fontFamilyString + ", sans-serif" .split(",") .map((font: string) => font.trim().replace(/['"]/g, "")) .join(", ") ); }; function transformValue( input: number, inputRange: number[], outputRange: number[], clamp = false ): number { const [inputMin, inputMax] = inputRange; const [outputMin, outputMax] = outputRange; const progress = (input - inputMin) / (inputMax - inputMin); let result = outputMin + progress * (outputMax - outputMin); if (clamp) { if (outputMax > outputMin) { result = Math.min(Math.max(result, outputMin), outputMax); } else { result = Math.min(Math.max(result, outputMax), outputMin); } } return result; } const renderAnimatedTag = (props: any, color: any, showText: any) => { const Component: any = (motion as any)[props.tag]; const trDur = typeof props.transition?.duration === "number" ? props.transition.duration : 1; const inDur = trDur * (FADE_OUT - TEXT_IN); return ( {props.text} ); }; const waitForFont = async (fontFamily: any) => { if (typeof window === "undefined" || !("FontFace" in window)) return; try { const families = fontFamily .split(",") .map((f: string) => f.trim().replace(/['"]/g, "")); await Promise.race([ Promise.all( families.map((family: string) => (document as any).fonts?.load(`16px "${family}"`) ) ), new Promise((resolve) => setTimeout(resolve, 5e3)), ]); } catch (e) { console.warn("Font loading failed:", e); } }; function __OriginkitBase_MagicTextReveal({ text = "DUST TEXT REVEAL", color: colorProp = "rgba(255, 255, 255, 1)", font = { fontFamily: "Inter", fontSize: "50px", textAlign: "center", fontWeight: 400, }, noise = 100, transition = { type: "tween", duration: 1, ease: "easeInOut" }, density = 8, resetOnMouseLeave = true, tag = "h1", playMode = "enter", startAlign = "center", replay = true, }: MagicTextRevealProps) { const props = { text, color: colorProp, font, noise, transition, density, resetOnMouseLeave, tag, playMode, startAlign, replay, }; const canvasRef = useRef(null); const wrapperRef = useRef(null); const lastFontRef = useRef(null); const particlesRef = useRef([]); const animationFrameRef = useRef(null); const lastTimeRef = useRef(performance.now()); const formProgressRef = useRef(0); const [fontLoaded, setFontLoaded] = useState(false); const [isHovered, setIsHovered] = useState(false); const [entered, setEntered] = useState(false); const [showText, setShowText] = useState(false); const [hasBeenShown, setHasBeenShown] = useState(false); const active = props.playMode === "enter" ? entered : isHovered; const d = Math.max(1, Math.min(10, Math.round(props.density))); const transformedDensity = DENSITY_MAP[d - 1]; const trDuration = typeof props.transition?.duration === "number" ? props.transition.duration : 1; const derivedSpeed = Math.min( 3, Math.max(0.1, 0.5 / Math.max(0.1, trDuration)) ); const easeFn = useMemo( () => easeToFn(props.transition?.ease), [props.transition] ); const color = useMemo(() => parseFramerColor(props.color), [props.color]); const isInView = useInView(wrapperRef); const { wrapperSize, setWrapperSize } = useWrapperSize(); const globalDpr = useMemo(() => { if (typeof window !== "undefined") return window.devicePixelRatio * 1.5 || 1; return 1; }, []); const tranformedCanvasY = useMemo(() => { return transformValue( parseInt(props.font.fontSize?.replace("px", "") || "50"), [0, 100], [0, 5], true ); }, [props.font.fontSize]); const transformedY = tranformedCanvasY; useEffect(() => { if (!props.font.fontFamily) return; const loadFont = async () => { await waitForFont(props.font.fontFamily); setFontLoaded(true); }; loadFont(); }, [props.font.fontFamily]); useEffect(() => { if (!isInView) return; if (!fontLoaded) return; renderCanvas({ canvasRef, wrapperRef, globalDpr, props, wrapperSize, particlesRef, transformedDensity, color, }); // eslint-disable-next-line react-hooks/exhaustive-deps }, [fontLoaded, isInView, wrapperSize, color]); useEffect(() => { if (!isInView) return; const animate = (currentTime: number) => { const deltaTime = (currentTime - lastTimeRef.current) / 1e3; lastTimeRef.current = currentTime; const canvas = canvasRef.current; const ctx = canvas?.getContext("2d"); if (!canvas || !ctx || !particlesRef.current.length) { animationFrameRef.current = requestAnimationFrame(animate); return; } ctx.clearRect(0, 0, canvas.width, canvas.height); const target = active ? 1 : 0; const rate = deltaTime / Math.max(0.05, trDuration); const cur = formProgressRef.current; formProgressRef.current = cur < target ? Math.min(target, cur + rate) : Math.max(target, cur - rate); const p = easeFn(formProgressRef.current); updateParticles( particlesRef.current, deltaTime, p, showText, setShowText, props.noise, derivedSpeed ); renderParticles(ctx, particlesRef.current, globalDpr); animationFrameRef.current = requestAnimationFrame(animate); }; animationFrameRef.current = requestAnimationFrame(animate); return () => { if (animationFrameRef.current) { cancelAnimationFrame(animationFrameRef.current); } }; // eslint-disable-next-line react-hooks/exhaustive-deps }, [isInView, props.noise, derivedSpeed, trDuration, easeFn, globalDpr, active]); const handleMouseEnter = useCallback(() => { setIsHovered(true); setHasBeenShown(true); }, []); const handleMouseLeave = useCallback(() => { if (props.resetOnMouseLeave || !hasBeenShown) { setIsHovered(false); } }, [props.resetOnMouseLeave, hasBeenShown]); useEffect(() => { if (props.playMode !== "enter") return; const el = wrapperRef.current; if (!el) return; setEntered(false); let has = false; const threshold = props.startAlign === "top" ? 0 : props.startAlign === "center" ? 0.5 : 1; const io = new IntersectionObserver( ([entry]) => { if (entry.isIntersecting) { if (!has) { has = true; setEntered(true); if (!props.replay) io.disconnect(); } } else if (props.replay) { has = false; setEntered(false); } }, { threshold } ); io.observe(el); return () => io.disconnect(); }, [props.playMode, props.startAlign, props.replay]); useEffect(() => { if (props.playMode !== "enter" || active || isInView) return; formProgressRef.current = 0; setShowText(false); }, [active, props.playMode, isInView]); useEffect(() => { renderCanvas({ canvasRef, wrapperRef, globalDpr, props, wrapperSize, particlesRef, transformedDensity, color, }); const currentFont = props.font.fontFamily || "sans-serif"; return handleFontChange({ currentFont, lastFontRef, props, canvasRef, wrapperRef, globalDpr, wrapperSize, particlesRef, transformedDensity, color, }); // eslint-disable-next-line react-hooks/exhaustive-deps }, [props, wrapperSize]); useResizeObserver({ wrapperRef, wrapperSize, setWrapperSize, props, canvasRef, globalDpr, particlesRef, transformedDensity, color, }); return (
{renderAnimatedTag(props, color, showText)}
); } function handleFontChange({ currentFont, lastFontRef, props, canvasRef, wrapperRef, globalDpr, wrapperSize, particlesRef, transformedDensity, color, }: any) { if (currentFont !== lastFontRef.current) { lastFontRef.current = currentFont; } return () => { cleanup({ canvasRef, particlesRef }); }; } const __originkitPresetProps = { "density": 10, "playMode": "hover" }; export default function MagicTextReveal(props: Record) { return <__OriginkitBase_MagicTextReveal {...(__originkitPresetProps as Record)} {...props} />; }
/* eslint-disable */ // Falling Text — Originkit "use client"; import * as React from "react"; import { useEffect, useCallback, useMemo } from "react"; import { motion, useAnimate, stagger as motionStagger, type Transition, } from "framer-motion"; const TAGS = ["h1", "h2", "h3", "h4", "h5", "h6", "p", "div", "span"] as const; type Font = { fontFamily?: string; variant?: string; fontWeight?: number; fontSize?: number; lineHeight?: number; letterSpacing?: string; textAlign?: React.CSSProperties["textAlign"]; }; type Props = { text?: string; font?: Font; color?: string; tag?: (typeof TAGS)[number]; startY?: number; startOpacity?: number; stagger?: number; transition?: Transition; split?: "none" | "words" | "char"; }; function __OriginkitBase_GravityFall({ text = "Gravity Fall", font = { fontFamily: "Inter", variant: "Bold", fontWeight: 400, fontSize: 120, lineHeight: 1.2, letterSpacing: "0em", textAlign: "left", }, color = "#FFFFFF", tag = "h3", startY = -1000, startOpacity = 0, stagger = 0.04, transition = { type: "spring", stiffness: 400, damping: 15, mass: 1 }, split = "char", }: Props) { const [scope, animate] = useAnimate(); const normalizedOpacity = startOpacity / 100; const getTargetSelector = useCallback(() => { if (split === "none") return scope.current; if (split === "words") return ".word"; return ".char"; }, [split, scope]); const resetToHidden = useCallback(() => { if (!scope.current) return; const target = getTargetSelector(); if (!target) return; animate( target, { y: startY, opacity: normalizedOpacity, }, { duration: 0 } ); }, [animate, scope, startY, normalizedOpacity, getTargetSelector]); const runAppear = useCallback(() => { if (!scope.current) return; const target = getTargetSelector(); if (!target) return; const animationConfig = { ...transition, delay: split !== "none" ? motionStagger(stagger) : 0, }; animate( target, { y: 0, opacity: 1, }, animationConfig as any ); }, [animate, transition, stagger, split, getTargetSelector]); useEffect(() => { resetToHidden(); const t = setTimeout(runAppear, 50); return () => clearTimeout(t); }, [ resetToHidden, runAppear, text, split, startY, stagger, JSON.stringify(transition), ]); const safeTag = (TAGS as readonly string[]).includes(tag) ? tag : "div"; const Tag = (motion as any)[safeTag]; const words = useMemo(() => text.split(/(\s+)/), [text]); const itemStyle: React.CSSProperties = { display: "inline-block", transformOrigin: "bottom center", verticalAlign: "bottom", willChange: "transform, opacity", }; return ( {split === "none" && text} {split === "words" && words.map((word, wi) => { if (word === "") return null; if (/^\s+$/.test(word)) { return ( ); } return ( {word} ); })} {split === "char" && words.map((word, wi) => { if (word === "") return null; if (/^\s+$/.test(word)) { return ( ); } return ( ); })} ); } const __originkitPresetProps = { "font": { "variant": "Bold", "fontSize": 120, "textAlign": "center", "fontFamily": "Inter", "fontWeight": 700, "lineHeight": 1.2, "letterSpacing": "0em" }, "tag": "h2" }; export default function GravityFall(props: Record) { return <__OriginkitBase_GravityFall {...(__originkitPresetProps as Record)} {...props} />; }
/* eslint-disable */ // Inkbleed — Originkit "use client" import { useEffect, useId, useLayoutEffect, useMemo, useRef } from "react" // Spot blur — AE-style parameters. // MAIN_RADIUS = inner radius of the spot. In INVERT mode this is // the inner edge of the blurred core. // SECONDARY_RADIUS = outer radius — the fade ends here. // INVERT = true → blur INSIDE the spot, sharp outside. // BLUR_AMOUNT = spot's gaussian blur stdDeviation. // FRINGE = chromatic-aberration shift in px. const MAIN_RADIUS = 0 const SECONDARY_RADIUS = 35 const INVERT = true const BLUR_AMOUNT = 10 const FRINGE = 5 // Choker offsets — symmetric so the two chokers balance each other and // give the liquid feel inside the spot lens. const LEFT_CHOKER_OFFSET = -10 const RIGHT_CHOKER_OFFSET = 10 // Goo pipeline — fuses sharp + blur + both chokers + neighbour chars // into one continuous ink shape. Higher THRESHOLD multiplier yields a // sharper alpha transition → goo blob is fully opaque inside, hard edge // outside, no semi-transparent fringe leaking the bg through the spot. const GOO_BLUR = 6 const THRESHOLD = 40 const CUTOFF = -15 // Cursor smoothing. const FOLLOW = 0.3 const INTENSITY_FOLLOW = 0.25 const SETTLE_EPSILON = 0.4 /** * @framerSupportedLayoutWidth fixed * @framerSupportedLayoutHeight fixed * @framerIntrinsicWidth 600 * @framerIntrinsicHeight 200 */ function __OriginkitBase_InkBleed(props: any) { props = { ...COMPONENT_DEFAULTS, ...props } const { text, color, font, intensity, tag } = props const Tag = (tag ?? "div") as any // Intensity 0..100 → multiplier 0..6. 0 = no effect, 100 = very wide // spot (twice the previous max). Held in a ref so the running rAF // loop reads fresh values without being re-created on slider ticks. const intensityFactor = Math.max(0, Math.min(100, intensity ?? 50)) / 16.67 const intensityRef = useRef(intensityFactor) intensityRef.current = intensityFactor const rawId = useId() const safeId = rawId.replace(/[:]/g, "") const filterGooId = `ink-goo-${safeId}` const filterFringeId = `ink-fringe-${safeId}` const chars = useMemo(() => Array.from((text as string) ?? ""), [text]) const containerRef = useRef(null) const wrapRefs = useRef<(HTMLSpanElement | null)[]>([]) const leftRefs = useRef<(HTMLSpanElement | null)[]>([]) const rightRefs = useRef<(HTMLSpanElement | null)[]>([]) const metrics = useRef< { cx: number cy: number w: number h: number left: number top: number }[] >([]) const measure = () => { metrics.current = wrapRefs.current.map((el) => { if (!el) return { cx: 0, cy: 0, w: 0, h: 0, left: 0, top: 0 } const r = el.getBoundingClientRect() return { cx: r.left + r.width / 2, cy: r.top + r.height / 2, w: r.width, h: r.height, left: r.left, top: r.top, } }) } useLayoutEffect(() => { measure() const ro = new ResizeObserver(measure) if (containerRef.current) ro.observe(containerRef.current) window.addEventListener("scroll", measure, { passive: true }) window.addEventListener("resize", measure) return () => { ro.disconnect() window.removeEventListener("scroll", measure) window.removeEventListener("resize", measure) } }, [chars.length]) const target = useRef({ x: -9999, y: -9999, on: 0 }) const smooth = useRef({ x: -9999, y: -9999, on: 0 }) const rafRef = useRef(null) const render = () => { const { x: cx, y: cy, on } = smooth.current const container = containerRef.current if (container) { // --spot-on scales every mask circle's radius. Multiplied by // the intensity factor so the slider drives spot SIZE: at 0 // the radius collapses to 0 (no effect); at 100 the radius // can grow up to ~3× the reference SECONDARY_RADIUS. container.style.setProperty( "--spot-on", (on * intensityRef.current).toFixed(3) ) } const ms = metrics.current for (let i = 0; i < ms.length; i++) { const wrapEl = wrapRefs.current[i] const leftEl = leftRefs.current[i] const rightEl = rightRefs.current[i] const m = ms[i] if (!m || m.w === 0) continue // CHAR-LOCAL cursor coords. Y tracks the actual cursor → true // small spot at the cursor (no full-height pinning). const mxBase = cx - m.left const myActual = cy - m.top if (wrapEl) { wrapEl.style.setProperty("--mx", `${mxBase.toFixed(1)}px`) wrapEl.style.setProperty("--my", `${myActual.toFixed(1)}px`) } // Chokers are offset within the wrapper → their local cursor X // shifts by the negative of their CSS `left`. if (leftEl) { leftEl.style.setProperty( "--mx", `${(mxBase - LEFT_CHOKER_OFFSET).toFixed(1)}px` ) leftEl.style.setProperty("--my", `${myActual.toFixed(1)}px`) } if (rightEl) { rightEl.style.setProperty( "--mx", `${(mxBase - RIGHT_CHOKER_OFFSET).toFixed(1)}px` ) rightEl.style.setProperty("--my", `${myActual.toFixed(1)}px`) } } } const stopLoop = () => { if (rafRef.current !== null) { cancelAnimationFrame(rafRef.current) rafRef.current = null } } const tick = () => { const t = target.current const s = smooth.current s.x += (t.x - s.x) * FOLLOW s.y += (t.y - s.y) * FOLLOW s.on += (t.on - s.on) * INTENSITY_FOLLOW render() const settled = Math.abs(t.x - s.x) < SETTLE_EPSILON && Math.abs(t.y - s.y) < SETTLE_EPSILON && Math.abs(t.on - s.on) < 0.005 if (settled && t.on === 0) { s.on = 0 render() rafRef.current = null return } rafRef.current = requestAnimationFrame(tick) } const startLoop = () => { if (rafRef.current !== null) return rafRef.current = requestAnimationFrame(tick) } useEffect(() => () => stopLoop(), []) const handleMove = (e: React.MouseEvent) => { if (target.current.on === 0) { smooth.current.x = e.clientX smooth.current.y = e.clientY } target.current.x = e.clientX target.current.y = e.clientY target.current.on = 1 startLoop() } const handleLeave = () => { target.current.on = 0 startLoop() } const typeface = font ?? {} const fontStyle = Object.fromEntries( Object.entries(typeface).filter(([k]) => k !== "textAlign") ) // Mask radius scales with --spot-on. When --spot-on = 0 the mask // circle has radius 0 → sharp shows everywhere (no hole) and spot // layers (blur + chokers) are entirely outside their circle so they // collapse to transparent. Smooth fade-in/out for the whole spot. const innerPct = (MAIN_RADIUS / SECONDARY_RADIUS) * 100 const sharpMask = INVERT ? `radial-gradient(circle calc(${SECONDARY_RADIUS}px * var(--spot-on, 0)) at var(--mx, -9999px) var(--my, -9999px), transparent 0%, transparent ${innerPct}%, rgba(0,0,0,1) 100%)` : `radial-gradient(circle calc(${SECONDARY_RADIUS}px * var(--spot-on, 0)) at var(--mx, -9999px) var(--my, -9999px), rgba(0,0,0,1) 0%, rgba(0,0,0,1) ${innerPct}%, transparent 100%)` const spotMask = INVERT ? `radial-gradient(circle calc(${SECONDARY_RADIUS}px * var(--spot-on, 0)) at var(--mx, -9999px) var(--my, -9999px), rgba(0,0,0,1) 0%, rgba(0,0,0,1) ${innerPct}%, transparent 100%)` : `radial-gradient(circle calc(${SECONDARY_RADIUS}px * var(--spot-on, 0)) at var(--mx, -9999px) var(--my, -9999px), transparent 0%, transparent ${innerPct}%, rgba(0,0,0,1) 100%)` const baseLayer: React.CSSProperties = { display: "inline-block", whiteSpace: "pre", } const absLayer: React.CSSProperties = { ...baseLayer, position: "absolute", top: 0, left: 0, pointerEvents: "none", } return ( {/* Goo: blur → threshold → composite atop. Fuses all layers (sharp, blur, chokers, neighbours) into one continuous ink shape. */} {/* Diffraction fringe — splits R/G/B channels by ±FRINGE px horizontally and recombines via screen blend. Applied to the blur layer only. */}
{chars.map((ch, i) => ( { wrapRefs.current[i] = el }} style={{ position: "relative", display: "inline-block", whiteSpace: "pre", cursor: "default", overflow: "visible", }} > {/* Sharp base — in-flow, sizes the wrapper. Hidden INSIDE the spot circle so the blur shows through. */} {ch === " " ? " " : ch} {/* Blur layer — visible INSIDE the spot circle. Plain gaussian blur, no chromatic fringe → the goo threshold renders it as a solid blob in the text color (full opacity, nothing showing through). */} {ch === " " ? " " : ch} {/* Left choker (-10). Spot-masked just like the blur layer → only the patch of the choker INSIDE the cursor circle renders. */} { leftRefs.current[i] = el }} aria-hidden style={{ ...absLayer, left: LEFT_CHOKER_OFFSET, maskImage: spotMask, WebkitMaskImage: spotMask, willChange: "mask-image", }} > {ch === " " ? " " : ch} {/* Right choker (+10). Same spot mask. */} { rightRefs.current[i] = el }} aria-hidden style={{ ...absLayer, left: RIGHT_CHOKER_OFFSET, maskImage: spotMask, WebkitMaskImage: spotMask, willChange: "mask-image", }} > {ch === " " ? " " : ch} ))}
) } const COMPONENT_DEFAULTS = { text: "ink bleed", intensity: 50, color: "#ffffff", font: { fontFamily: "Inter", variant: "Bold", fontSize: 180, lineHeight: "1em", } as any, tag: "div", } const __originkitPresetProps = { "text": "InkBleed", "intensity": 25, "color": "#e1e1e1", "font": { "variant": "Bold", "fontSize": "120px", "textAlign": "left", "fontFamily": "Inter", "fontWeight": 700, "lineHeight": "1em", "letterSpacing": "0em" } }; export default function InkBleed(props: Record) { return <__OriginkitBase_InkBleed {...(__originkitPresetProps as Record)} {...props} />; }
/* eslint-disable */ // Inkbleed — Originkit "use client" import { useEffect, useId, useLayoutEffect, useMemo, useRef } from "react" // Spot blur — AE-style parameters. // MAIN_RADIUS = inner radius of the spot. In INVERT mode this is // the inner edge of the blurred core. // SECONDARY_RADIUS = outer radius — the fade ends here. // INVERT = true → blur INSIDE the spot, sharp outside. // BLUR_AMOUNT = spot's gaussian blur stdDeviation. // FRINGE = chromatic-aberration shift in px. const MAIN_RADIUS = 0 const SECONDARY_RADIUS = 35 const INVERT = true const BLUR_AMOUNT = 10 const FRINGE = 5 // Choker offsets — symmetric so the two chokers balance each other and // give the liquid feel inside the spot lens. const LEFT_CHOKER_OFFSET = -10 const RIGHT_CHOKER_OFFSET = 10 // Goo pipeline — fuses sharp + blur + both chokers + neighbour chars // into one continuous ink shape. Higher THRESHOLD multiplier yields a // sharper alpha transition → goo blob is fully opaque inside, hard edge // outside, no semi-transparent fringe leaking the bg through the spot. const GOO_BLUR = 6 const THRESHOLD = 40 const CUTOFF = -15 // Cursor smoothing. const FOLLOW = 0.3 const INTENSITY_FOLLOW = 0.25 const SETTLE_EPSILON = 0.4 /** * @framerSupportedLayoutWidth fixed * @framerSupportedLayoutHeight fixed * @framerIntrinsicWidth 600 * @framerIntrinsicHeight 200 */ function __OriginkitBase_InkBleed(props: any) { props = { ...COMPONENT_DEFAULTS, ...props } const { text, color, font, intensity, tag } = props const Tag = (tag ?? "div") as any // Intensity 0..100 → multiplier 0..6. 0 = no effect, 100 = very wide // spot (twice the previous max). Held in a ref so the running rAF // loop reads fresh values without being re-created on slider ticks. const intensityFactor = Math.max(0, Math.min(100, intensity ?? 50)) / 16.67 const intensityRef = useRef(intensityFactor) intensityRef.current = intensityFactor const rawId = useId() const safeId = rawId.replace(/[:]/g, "") const filterGooId = `ink-goo-${safeId}` const filterFringeId = `ink-fringe-${safeId}` const chars = useMemo(() => Array.from((text as string) ?? ""), [text]) const containerRef = useRef(null) const wrapRefs = useRef<(HTMLSpanElement | null)[]>([]) const leftRefs = useRef<(HTMLSpanElement | null)[]>([]) const rightRefs = useRef<(HTMLSpanElement | null)[]>([]) const metrics = useRef< { cx: number cy: number w: number h: number left: number top: number }[] >([]) const measure = () => { metrics.current = wrapRefs.current.map((el) => { if (!el) return { cx: 0, cy: 0, w: 0, h: 0, left: 0, top: 0 } const r = el.getBoundingClientRect() return { cx: r.left + r.width / 2, cy: r.top + r.height / 2, w: r.width, h: r.height, left: r.left, top: r.top, } }) } useLayoutEffect(() => { measure() const ro = new ResizeObserver(measure) if (containerRef.current) ro.observe(containerRef.current) window.addEventListener("scroll", measure, { passive: true }) window.addEventListener("resize", measure) return () => { ro.disconnect() window.removeEventListener("scroll", measure) window.removeEventListener("resize", measure) } }, [chars.length]) const target = useRef({ x: -9999, y: -9999, on: 0 }) const smooth = useRef({ x: -9999, y: -9999, on: 0 }) const rafRef = useRef(null) const render = () => { const { x: cx, y: cy, on } = smooth.current const container = containerRef.current if (container) { // --spot-on scales every mask circle's radius. Multiplied by // the intensity factor so the slider drives spot SIZE: at 0 // the radius collapses to 0 (no effect); at 100 the radius // can grow up to ~3× the reference SECONDARY_RADIUS. container.style.setProperty( "--spot-on", (on * intensityRef.current).toFixed(3) ) } const ms = metrics.current for (let i = 0; i < ms.length; i++) { const wrapEl = wrapRefs.current[i] const leftEl = leftRefs.current[i] const rightEl = rightRefs.current[i] const m = ms[i] if (!m || m.w === 0) continue // CHAR-LOCAL cursor coords. Y tracks the actual cursor → true // small spot at the cursor (no full-height pinning). const mxBase = cx - m.left const myActual = cy - m.top if (wrapEl) { wrapEl.style.setProperty("--mx", `${mxBase.toFixed(1)}px`) wrapEl.style.setProperty("--my", `${myActual.toFixed(1)}px`) } // Chokers are offset within the wrapper → their local cursor X // shifts by the negative of their CSS `left`. if (leftEl) { leftEl.style.setProperty( "--mx", `${(mxBase - LEFT_CHOKER_OFFSET).toFixed(1)}px` ) leftEl.style.setProperty("--my", `${myActual.toFixed(1)}px`) } if (rightEl) { rightEl.style.setProperty( "--mx", `${(mxBase - RIGHT_CHOKER_OFFSET).toFixed(1)}px` ) rightEl.style.setProperty("--my", `${myActual.toFixed(1)}px`) } } } const stopLoop = () => { if (rafRef.current !== null) { cancelAnimationFrame(rafRef.current) rafRef.current = null } } const tick = () => { const t = target.current const s = smooth.current s.x += (t.x - s.x) * FOLLOW s.y += (t.y - s.y) * FOLLOW s.on += (t.on - s.on) * INTENSITY_FOLLOW render() const settled = Math.abs(t.x - s.x) < SETTLE_EPSILON && Math.abs(t.y - s.y) < SETTLE_EPSILON && Math.abs(t.on - s.on) < 0.005 if (settled && t.on === 0) { s.on = 0 render() rafRef.current = null return } rafRef.current = requestAnimationFrame(tick) } const startLoop = () => { if (rafRef.current !== null) return rafRef.current = requestAnimationFrame(tick) } useEffect(() => () => stopLoop(), []) const handleMove = (e: React.MouseEvent) => { if (target.current.on === 0) { smooth.current.x = e.clientX smooth.current.y = e.clientY } target.current.x = e.clientX target.current.y = e.clientY target.current.on = 1 startLoop() } const handleLeave = () => { target.current.on = 0 startLoop() } const typeface = font ?? {} const fontStyle = Object.fromEntries( Object.entries(typeface).filter(([k]) => k !== "textAlign") ) // Mask radius scales with --spot-on. When --spot-on = 0 the mask // circle has radius 0 → sharp shows everywhere (no hole) and spot // layers (blur + chokers) are entirely outside their circle so they // collapse to transparent. Smooth fade-in/out for the whole spot. const innerPct = (MAIN_RADIUS / SECONDARY_RADIUS) * 100 const sharpMask = INVERT ? `radial-gradient(circle calc(${SECONDARY_RADIUS}px * var(--spot-on, 0)) at var(--mx, -9999px) var(--my, -9999px), transparent 0%, transparent ${innerPct}%, rgba(0,0,0,1) 100%)` : `radial-gradient(circle calc(${SECONDARY_RADIUS}px * var(--spot-on, 0)) at var(--mx, -9999px) var(--my, -9999px), rgba(0,0,0,1) 0%, rgba(0,0,0,1) ${innerPct}%, transparent 100%)` const spotMask = INVERT ? `radial-gradient(circle calc(${SECONDARY_RADIUS}px * var(--spot-on, 0)) at var(--mx, -9999px) var(--my, -9999px), rgba(0,0,0,1) 0%, rgba(0,0,0,1) ${innerPct}%, transparent 100%)` : `radial-gradient(circle calc(${SECONDARY_RADIUS}px * var(--spot-on, 0)) at var(--mx, -9999px) var(--my, -9999px), transparent 0%, transparent ${innerPct}%, rgba(0,0,0,1) 100%)` const baseLayer: React.CSSProperties = { display: "inline-block", whiteSpace: "pre", } const absLayer: React.CSSProperties = { ...baseLayer, position: "absolute", top: 0, left: 0, pointerEvents: "none", } return ( {/* Goo: blur → threshold → composite atop. Fuses all layers (sharp, blur, chokers, neighbours) into one continuous ink shape. */} {/* Diffraction fringe — splits R/G/B channels by ±FRINGE px horizontally and recombines via screen blend. Applied to the blur layer only. */}
{chars.map((ch, i) => ( { wrapRefs.current[i] = el }} style={{ position: "relative", display: "inline-block", whiteSpace: "pre", cursor: "default", overflow: "visible", }} > {/* Sharp base — in-flow, sizes the wrapper. Hidden INSIDE the spot circle so the blur shows through. */} {ch === " " ? " " : ch} {/* Blur layer — visible INSIDE the spot circle. Plain gaussian blur, no chromatic fringe → the goo threshold renders it as a solid blob in the text color (full opacity, nothing showing through). */} {ch === " " ? " " : ch} {/* Left choker (-10). Spot-masked just like the blur layer → only the patch of the choker INSIDE the cursor circle renders. */} { leftRefs.current[i] = el }} aria-hidden style={{ ...absLayer, left: LEFT_CHOKER_OFFSET, maskImage: spotMask, WebkitMaskImage: spotMask, willChange: "mask-image", }} > {ch === " " ? " " : ch} {/* Right choker (+10). Same spot mask. */} { rightRefs.current[i] = el }} aria-hidden style={{ ...absLayer, left: RIGHT_CHOKER_OFFSET, maskImage: spotMask, WebkitMaskImage: spotMask, willChange: "mask-image", }} > {ch === " " ? " " : ch} ))}
) } const COMPONENT_DEFAULTS = { text: "ink bleed", intensity: 50, color: "#ffffff", font: { fontFamily: "Inter", variant: "Bold", fontSize: 180, lineHeight: "1em", } as any, tag: "div", } const __originkitPresetProps = { "text": "InkBleed", "intensity": 25, "color": "#e1e1e1", "font": { "variant": "Bold", "fontSize": "120px", "textAlign": "left", "fontFamily": "Inter", "fontWeight": 700, "lineHeight": "1em", "letterSpacing": "0em" } }; export default function InkBleed(props: Record) { return <__OriginkitBase_InkBleed {...(__originkitPresetProps as Record)} {...props} />; }
/* eslint-disable */ // Inkbleed — Originkit "use client" import { useEffect, useId, useLayoutEffect, useMemo, useRef } from "react" // Spot blur — AE-style parameters. // MAIN_RADIUS = inner radius of the spot. In INVERT mode this is // the inner edge of the blurred core. // SECONDARY_RADIUS = outer radius — the fade ends here. // INVERT = true → blur INSIDE the spot, sharp outside. // BLUR_AMOUNT = spot's gaussian blur stdDeviation. // FRINGE = chromatic-aberration shift in px. const MAIN_RADIUS = 0 const SECONDARY_RADIUS = 35 const INVERT = true const BLUR_AMOUNT = 10 const FRINGE = 5 // Choker offsets — symmetric so the two chokers balance each other and // give the liquid feel inside the spot lens. const LEFT_CHOKER_OFFSET = -10 const RIGHT_CHOKER_OFFSET = 10 // Goo pipeline — fuses sharp + blur + both chokers + neighbour chars // into one continuous ink shape. Higher THRESHOLD multiplier yields a // sharper alpha transition → goo blob is fully opaque inside, hard edge // outside, no semi-transparent fringe leaking the bg through the spot. const GOO_BLUR = 6 const THRESHOLD = 40 const CUTOFF = -15 // Cursor smoothing. const FOLLOW = 0.3 const INTENSITY_FOLLOW = 0.25 const SETTLE_EPSILON = 0.4 /** * @framerSupportedLayoutWidth fixed * @framerSupportedLayoutHeight fixed * @framerIntrinsicWidth 600 * @framerIntrinsicHeight 200 */ function __OriginkitBase_InkBleed(props: any) { props = { ...COMPONENT_DEFAULTS, ...props } const { text, color, font, intensity, tag } = props const Tag = (tag ?? "div") as any // Intensity 0..100 → multiplier 0..6. 0 = no effect, 100 = very wide // spot (twice the previous max). Held in a ref so the running rAF // loop reads fresh values without being re-created on slider ticks. const intensityFactor = Math.max(0, Math.min(100, intensity ?? 50)) / 16.67 const intensityRef = useRef(intensityFactor) intensityRef.current = intensityFactor const rawId = useId() const safeId = rawId.replace(/[:]/g, "") const filterGooId = `ink-goo-${safeId}` const filterFringeId = `ink-fringe-${safeId}` const chars = useMemo(() => Array.from((text as string) ?? ""), [text]) const containerRef = useRef(null) const wrapRefs = useRef<(HTMLSpanElement | null)[]>([]) const leftRefs = useRef<(HTMLSpanElement | null)[]>([]) const rightRefs = useRef<(HTMLSpanElement | null)[]>([]) const metrics = useRef< { cx: number cy: number w: number h: number left: number top: number }[] >([]) const measure = () => { metrics.current = wrapRefs.current.map((el) => { if (!el) return { cx: 0, cy: 0, w: 0, h: 0, left: 0, top: 0 } const r = el.getBoundingClientRect() return { cx: r.left + r.width / 2, cy: r.top + r.height / 2, w: r.width, h: r.height, left: r.left, top: r.top, } }) } useLayoutEffect(() => { measure() const ro = new ResizeObserver(measure) if (containerRef.current) ro.observe(containerRef.current) window.addEventListener("scroll", measure, { passive: true }) window.addEventListener("resize", measure) return () => { ro.disconnect() window.removeEventListener("scroll", measure) window.removeEventListener("resize", measure) } }, [chars.length]) const target = useRef({ x: -9999, y: -9999, on: 0 }) const smooth = useRef({ x: -9999, y: -9999, on: 0 }) const rafRef = useRef(null) const render = () => { const { x: cx, y: cy, on } = smooth.current const container = containerRef.current if (container) { // --spot-on scales every mask circle's radius. Multiplied by // the intensity factor so the slider drives spot SIZE: at 0 // the radius collapses to 0 (no effect); at 100 the radius // can grow up to ~3× the reference SECONDARY_RADIUS. container.style.setProperty( "--spot-on", (on * intensityRef.current).toFixed(3) ) } const ms = metrics.current for (let i = 0; i < ms.length; i++) { const wrapEl = wrapRefs.current[i] const leftEl = leftRefs.current[i] const rightEl = rightRefs.current[i] const m = ms[i] if (!m || m.w === 0) continue // CHAR-LOCAL cursor coords. Y tracks the actual cursor → true // small spot at the cursor (no full-height pinning). const mxBase = cx - m.left const myActual = cy - m.top if (wrapEl) { wrapEl.style.setProperty("--mx", `${mxBase.toFixed(1)}px`) wrapEl.style.setProperty("--my", `${myActual.toFixed(1)}px`) } // Chokers are offset within the wrapper → their local cursor X // shifts by the negative of their CSS `left`. if (leftEl) { leftEl.style.setProperty( "--mx", `${(mxBase - LEFT_CHOKER_OFFSET).toFixed(1)}px` ) leftEl.style.setProperty("--my", `${myActual.toFixed(1)}px`) } if (rightEl) { rightEl.style.setProperty( "--mx", `${(mxBase - RIGHT_CHOKER_OFFSET).toFixed(1)}px` ) rightEl.style.setProperty("--my", `${myActual.toFixed(1)}px`) } } } const stopLoop = () => { if (rafRef.current !== null) { cancelAnimationFrame(rafRef.current) rafRef.current = null } } const tick = () => { const t = target.current const s = smooth.current s.x += (t.x - s.x) * FOLLOW s.y += (t.y - s.y) * FOLLOW s.on += (t.on - s.on) * INTENSITY_FOLLOW render() const settled = Math.abs(t.x - s.x) < SETTLE_EPSILON && Math.abs(t.y - s.y) < SETTLE_EPSILON && Math.abs(t.on - s.on) < 0.005 if (settled && t.on === 0) { s.on = 0 render() rafRef.current = null return } rafRef.current = requestAnimationFrame(tick) } const startLoop = () => { if (rafRef.current !== null) return rafRef.current = requestAnimationFrame(tick) } useEffect(() => () => stopLoop(), []) const handleMove = (e: React.MouseEvent) => { if (target.current.on === 0) { smooth.current.x = e.clientX smooth.current.y = e.clientY } target.current.x = e.clientX target.current.y = e.clientY target.current.on = 1 startLoop() } const handleLeave = () => { target.current.on = 0 startLoop() } const typeface = font ?? {} const fontStyle = Object.fromEntries( Object.entries(typeface).filter(([k]) => k !== "textAlign") ) // Mask radius scales with --spot-on. When --spot-on = 0 the mask // circle has radius 0 → sharp shows everywhere (no hole) and spot // layers (blur + chokers) are entirely outside their circle so they // collapse to transparent. Smooth fade-in/out for the whole spot. const innerPct = (MAIN_RADIUS / SECONDARY_RADIUS) * 100 const sharpMask = INVERT ? `radial-gradient(circle calc(${SECONDARY_RADIUS}px * var(--spot-on, 0)) at var(--mx, -9999px) var(--my, -9999px), transparent 0%, transparent ${innerPct}%, rgba(0,0,0,1) 100%)` : `radial-gradient(circle calc(${SECONDARY_RADIUS}px * var(--spot-on, 0)) at var(--mx, -9999px) var(--my, -9999px), rgba(0,0,0,1) 0%, rgba(0,0,0,1) ${innerPct}%, transparent 100%)` const spotMask = INVERT ? `radial-gradient(circle calc(${SECONDARY_RADIUS}px * var(--spot-on, 0)) at var(--mx, -9999px) var(--my, -9999px), rgba(0,0,0,1) 0%, rgba(0,0,0,1) ${innerPct}%, transparent 100%)` : `radial-gradient(circle calc(${SECONDARY_RADIUS}px * var(--spot-on, 0)) at var(--mx, -9999px) var(--my, -9999px), transparent 0%, transparent ${innerPct}%, rgba(0,0,0,1) 100%)` const baseLayer: React.CSSProperties = { display: "inline-block", whiteSpace: "pre", } const absLayer: React.CSSProperties = { ...baseLayer, position: "absolute", top: 0, left: 0, pointerEvents: "none", } return ( {/* Goo: blur → threshold → composite atop. Fuses all layers (sharp, blur, chokers, neighbours) into one continuous ink shape. */} {/* Diffraction fringe — splits R/G/B channels by ±FRINGE px horizontally and recombines via screen blend. Applied to the blur layer only. */}
{chars.map((ch, i) => ( { wrapRefs.current[i] = el }} style={{ position: "relative", display: "inline-block", whiteSpace: "pre", cursor: "default", overflow: "visible", }} > {/* Sharp base — in-flow, sizes the wrapper. Hidden INSIDE the spot circle so the blur shows through. */} {ch === " " ? " " : ch} {/* Blur layer — visible INSIDE the spot circle. Plain gaussian blur, no chromatic fringe → the goo threshold renders it as a solid blob in the text color (full opacity, nothing showing through). */} {ch === " " ? " " : ch} {/* Left choker (-10). Spot-masked just like the blur layer → only the patch of the choker INSIDE the cursor circle renders. */} { leftRefs.current[i] = el }} aria-hidden style={{ ...absLayer, left: LEFT_CHOKER_OFFSET, maskImage: spotMask, WebkitMaskImage: spotMask, willChange: "mask-image", }} > {ch === " " ? " " : ch} {/* Right choker (+10). Same spot mask. */} { rightRefs.current[i] = el }} aria-hidden style={{ ...absLayer, left: RIGHT_CHOKER_OFFSET, maskImage: spotMask, WebkitMaskImage: spotMask, willChange: "mask-image", }} > {ch === " " ? " " : ch} ))}
) } const COMPONENT_DEFAULTS = { text: "ink bleed", intensity: 50, color: "#ffffff", font: { fontFamily: "Inter", variant: "Bold", fontSize: 180, lineHeight: "1em", } as any, tag: "div", } const __originkitPresetProps = { "text": "InkBleed", "intensity": 25, "color": "#e1e1e1", "font": { "variant": "Bold", "fontSize": "120px", "textAlign": "left", "fontFamily": "Inter", "fontWeight": 700, "lineHeight": "1em", "letterSpacing": "0em" } }; export default function InkBleed(props: Record) { return <__OriginkitBase_InkBleed {...(__originkitPresetProps as Record)} {...props} />; }