// NextXus Federation — Cognitive Circuitry License // Animation: Persistent Neural Mesh // License: Token Bundle (https://keywebster.gumroad.com/l/olhsf) // Own the marrow. (function () { "use strict"; var canvas = document.getElementById("canvas-alpha"); var ctx = canvas.getContext("2d"); var stage = canvas.parentElement; var reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches; var THRESHOLD = 130, COUNT = 50; var nodes = [], running = false, rafId = null; function resize() { canvas.width = stage.clientWidth; canvas.height = stage.clientHeight; } function seed() { nodes = []; for (var i = 0; i < COUNT; i++) { nodes.push({ x: Math.random() * canvas.width, y: Math.random() * canvas.height, vx: (Math.random() - 0.5) * 0.5, vy: (Math.random() - 0.5) * 0.5, r: 1.5 + Math.random() }); } } function draw() { var w = canvas.width, h = canvas.height, i, j, a, b, dx, dy, d; ctx.fillStyle = "#0a0a0f"; ctx.fillRect(0, 0, w, h); for (i = 0; i < nodes.length; i++) { for (j = i + 1; j < nodes.length; j++) { a = nodes[i]; b = nodes[j]; dx = a.x - b.x; dy = a.y - b.y; d = Math.sqrt(dx * dx + dy * dy); if (d < THRESHOLD) { ctx.strokeStyle = "rgba(212,175,55," + ((1 - d / THRESHOLD) * 0.55).toFixed(3) + ")"; ctx.lineWidth = 0.7; ctx.beginPath(); ctx.moveTo(a.x, a.y); ctx.lineTo(b.x, b.y); ctx.stroke(); } } } ctx.fillStyle = "#d4af37"; for (i = 0; i < nodes.length; i++) { ctx.beginPath(); ctx.arc(nodes[i].x, nodes[i].y, nodes[i].r, 0, Math.PI * 2); ctx.fill(); } } function step() { var w = canvas.width, h = canvas.height; for (var i = 0; i < nodes.length; i++) { var n = nodes[i]; n.x += n.vx; n.y += n.vy; if (n.x < 0) n.x = w; else if (n.x > w) n.x = 0; if (n.y < 0) n.y = h; else if (n.y > h) n.y = 0; } } function loop() { if (!running) return; step(); draw(); rafId = requestAnimationFrame(loop); } function start() { if (running || reduced) return; running = true; rafId = requestAnimationFrame(loop); } function stop() { running = false; if (rafId) cancelAnimationFrame(rafId); } window.addEventListener("resize", function () { resize(); seed(); draw(); }); resize(); seed(); draw(); if (!reduced) { if ("IntersectionObserver" in window) { new IntersectionObserver(function (entries) { entries.forEach(function (e) { if (e.isIntersecting) start(); else stop(); }); }).observe(canvas); } else { start(); } } })();