const { useEffect, useRef, useState, useMemo } = React; function mulberry32(a) { return function () { let t = (a += 0x6D2B79F5); t = Math.imul(t ^ (t >>> 15), t | 1); t ^= t + Math.imul(t ^ (t >>> 7), t | 61); return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; } // Animated spectrum function Spectrum({ stable = true, intensity = 1 }) { const [t, setT] = useState(0); useEffect(() => { let raf, last = performance.now(); const tick = (now) => { setT((p) => p + (now - last) * 0.001); last = now; raf = requestAnimationFrame(tick); }; raf = requestAnimationFrame(tick); return () => cancelAnimationFrame(raf); }, []); const W = 600, H = 150, N = 56; return ( {[0.25, 0.5, 0.75].map((p, i) => ( ))} {Array.from({length: N}).map((_, i) => { const x = (i / N) * W; const phase = t * (stable ? 1.4 : 2.6) + i * 0.32; const env = Math.exp(-Math.pow((i - N/2) / (N/2.6), 2)); const noise = stable ? 0.10 : 0.32; const h = (Math.sin(phase) * 0.4 + Math.sin(phase*2.3 + i*0.2) * 0.3 + 0.5) * env * intensity + (Math.random()-0.5) * noise; const bh = Math.max(2, Math.min(H-4, H * 0.85 * Math.max(0.05, h))); return ; })} ); } // Topology function TopologyGraph({ nodes = 412, seed = 1 }) { const W = 600, H = 280; const NN = Math.min(28, Math.max(8, Math.round(nodes / 18))); const points = useMemo(() => { const rng = mulberry32(seed * 9301 + 1); return Array.from({ length: NN }).map((_, i) => { const r = (i % 5 === 0) ? 0.18 : 0.32 + rng() * 0.36; const a = rng() * Math.PI * 2; return { x: W*0.5 + Math.cos(a) * W * r * 0.7, y: H*0.5 + Math.sin(a) * H * r, size: i % 6 === 0 ? 5.5 : (i % 3 === 0 ? 3.6 : 2.4), kind: i % 7 === 0 ? "anchor" : "node", }; }); }, [seed, NN]); const edges = useMemo(() => { const rng = mulberry32(seed * 13); const e = []; for (let i = 0; i < points.length; i++) { const k = 1 + Math.floor(rng() * 3); for (let j = 0; j < k; j++) { const tg = (i + 1 + Math.floor(rng() * (points.length - 1))) % points.length; if (tg !== i) e.push([i, tg]); } } return e; }, [points, seed]); const [t, setT] = useState(0); useEffect(() => { let raf; const tick = () => { setT(performance.now() * 0.001); raf = requestAnimationFrame(tick); }; raf = requestAnimationFrame(tick); return () => cancelAnimationFrame(raf); }, []); return ( {[60, 110, 150].map((r, i) => )} {edges.map(([a, b], i) => { const A = points[a], B = points[b]; const phase = (t * 0.6 + i * 0.13) % 1; return ( ); })} {points.map((p, i) => { const a = p.kind === "anchor"; return ( {a && } ); })} ); } // Synesthesia waves function SynesStream() { const [t, setT] = useState(0); useEffect(() => { let raf; const tick = () => { setT(performance.now() * 0.001); raf = requestAnimationFrame(tick); }; raf = requestAnimationFrame(tick); return () => cancelAnimationFrame(raf); }, []); const W = 600, H = 140; const lines = [ { y: H*0.25, amp: 12, freq: 1.6, c: "var(--energy)", op: 0.9 }, { y: H*0.50, amp: 18, freq: 0.8, c: "var(--energy)", op: 0.55 }, { y: H*0.75, amp: 8, freq: 2.4, c: "var(--gold)", op: 0.7 }, ]; return ( {lines.map((c, ci) => { const pts = []; for (let i = 0; i <= 100; i++) { const x = (i/100)*W; const y = c.y + Math.sin(t*c.freq + i*0.15)*c.amp + Math.sin(t*c.freq*1.7 + i*0.27)*c.amp*0.4; pts.push(`${i===0?"M":"L"}${x},${y}`); } return ( ); })} ); } // Knob function Knob({ value, onChange, label, zh, disabled }) { const ang = 30 + (value / 100) * 240; const drag = (e) => { if (disabled) return; e.preventDefault(); const sy = e.clientY, sv = value; const move = (ev) => onChange(Math.max(0, Math.min(100, Math.round(sv + (sy - ev.clientY) * 0.6)))); const up = () => { window.removeEventListener("mousemove", move); window.removeEventListener("mouseup", up); }; window.addEventListener("mousemove", move); window.addEventListener("mouseup", up); }; return (
{value}
{label}
{zh}
); } // Fingerprint SVG function FingerprintSVG({ seed = 1, color = "var(--gold)" }) { return ( {Array.from({length:9}).map((_, i) => { const r = 6 + i * 4; const off = Math.sin((i+seed) * 1.3) * 4; return ; })} ); } window.HG2Atoms = { Spectrum, TopologyGraph, SynesStream, Knob, FingerprintSVG };