// NextXus Federation — Cognitive Circuitry License // Animation: The Data Rain // License: Token Bundle (https://keywebster.gumroad.com/l/olhsf) // Own the marrow. (function () { "use strict"; var canvas = document.getElementById("canvas-zeta"); var ctx = canvas.getContext("2d"); var stage = canvas.parentElement; var reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches; var NCOLS = 52, GAP = 14, FLASH_CHARS = ["0", "1", "\u03B5", "\u0394", "\u03A9"]; var cols = [], running = false, rafId = null; function makeCol(x, anyY) { return { x: x, y: anyY ? Math.random() * canvas.height : -Math.random() * canvas.height * 0.5, speed: 1.5 + Math.random() * 2.5, len: 5 + ((Math.random() * 4) | 0), gold: Math.random() < 0.15, flash: 0, ch: "0" }; } function resize() { canvas.width = stage.clientWidth; canvas.height = stage.clientHeight; } function seed() { cols = []; var spacing = canvas.width / NCOLS; for (var i = 0; i < NCOLS; i++) { cols.push(makeCol(spacing * i + spacing / 2, true)); } } function step() { var h = canvas.height; for (var i = 0; i < cols.length; i++) { var c = cols[i]; c.y += c.speed; if (c.flash > 0.04) c.flash *= 0.9; else c.flash = 0; if (c.flash === 0 && Math.random() < 0.012) { c.flash = 1; c.ch = FLASH_CHARS[(Math.random() * FLASH_CHARS.length) | 0]; } if (c.y - c.len * GAP > h) { cols[i] = makeCol(c.x, false); } } } function draw() { var w = canvas.width, h = canvas.height, i, t; ctx.fillStyle = "#0a0a0f"; ctx.fillRect(0, 0, w, h); ctx.font = "14px monospace"; ctx.textAlign = "center"; for (i = 0; i < cols.length; i++) { var c = cols[i]; for (t = 0; t < c.len; t++) { var ty = c.y - t * GAP; if (ty < -GAP || ty > h + GAP) continue; var a = (1 - t / c.len) * (t === 0 ? 1 : 0.65); if (t === 0) { ctx.fillStyle = c.gold ? "rgba(255,233,138," + a.toFixed(3) + ")" : "rgba(174,244,255," + a.toFixed(3) + ")"; } else { ctx.fillStyle = c.gold ? "rgba(255,215,0," + a.toFixed(3) + ")" : "rgba(6,182,212," + a.toFixed(3) + ")"; } if (t === 0 && c.flash > 0.04) { ctx.fillText(c.ch, c.x, ty); } else { ctx.fillRect(c.x - 1, ty - 8, 2, t === 0 ? 10 : 7); } } } } function warm() { for (var s = 0; s < 20; s++) step(); } 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(); warm(); draw(); }); resize(); seed(); warm(); 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(); } } })();