// NextXus Federation — Cognitive Circuitry License // Animation: Starfall Node Connect // License: Token Bundle (https://keywebster.gumroad.com/l/olhsf) // Own the marrow. (function () { "use strict"; var canvas = document.getElementById("canvas-gamma"); var ctx = canvas.getContext("2d"); var stage = canvas.parentElement; var reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches; var COUNT = 90, LINK = 100; var stars = [], running = false, rafId = null; function makeStar(fromTop) { return { x: Math.random() * canvas.width, y: fromTop ? -10 : Math.random() * canvas.height, vy: 0.2 + Math.random() * 0.4, r: 0.8 + Math.random(), alpha: 0, target: 0.55 + Math.random() * 0.45, phase: Math.random() * Math.PI * 2, amp: 0.3 + Math.random() * 0.5, fading: false }; } function resize() { canvas.width = stage.clientWidth; canvas.height = stage.clientHeight; } function seed(fromTop) { stars = []; for (var i = 0; i < COUNT; i++) stars.push(makeStar(fromTop)); if (!fromTop) { for (var j = 0; j < stars.length; j++) stars[j].alpha = stars[j].target; } } 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); ctx.lineWidth = 0.5; for (i = 0; i < stars.length; i++) { for (j = i + 1; j < stars.length; j++) { a = stars[i]; b = stars[j]; dx = a.x - b.x; dy = a.y - b.y; d = Math.sqrt(dx * dx + dy * dy); if (d < LINK) { ctx.strokeStyle = "rgba(255,255,255," + ((1 - d / LINK) * 0.22 * Math.min(a.alpha, b.alpha)).toFixed(3) + ")"; ctx.beginPath(); ctx.moveTo(a.x, a.y); ctx.lineTo(b.x, b.y); ctx.stroke(); } } } for (i = 0; i < stars.length; i++) { a = stars[i]; ctx.fillStyle = "rgba(255,255,255," + a.alpha.toFixed(3) + ")"; ctx.beginPath(); ctx.arc(a.x, a.y, a.r, 0, Math.PI * 2); ctx.fill(); } } function step() { var h = canvas.height; for (var i = 0; i < stars.length; i++) { var s = stars[i]; s.phase += 0.02; s.x += Math.sin(s.phase) * s.amp * 0.3; s.y += s.vy; if (!s.fading && s.alpha < s.target) s.alpha = Math.min(s.target, s.alpha + 0.01); if (s.y > h - 40) s.fading = true; if (s.fading) { s.alpha -= 0.02; if (s.alpha <= 0) stars[i] = makeStar(true); } } } 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(false); draw(); }); resize(); seed(false); 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(); } } })();