From 754422d0433ae0232501a57996fbe45a8bec79d5 Mon Sep 17 00:00:00 2001 From: IM23a-spirgif Date: Thu, 19 Jun 2025 22:28:54 +0200 Subject: [PATCH] Add animated matrix background effect to home page. --- public/home.html | 4 +++- public/matrix.js | 27 +++++++++++++++++++++++++++ public/styles_home.css | 11 +++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 public/matrix.js diff --git a/public/home.html b/public/home.html index 0d949d0..772940d 100644 --- a/public/home.html +++ b/public/home.html @@ -6,6 +6,7 @@ +
Balance: $0 @@ -15,7 +16,7 @@
@@ -28,4 +29,5 @@ + \ No newline at end of file diff --git a/public/matrix.js b/public/matrix.js new file mode 100644 index 0000000..f4ff274 --- /dev/null +++ b/public/matrix.js @@ -0,0 +1,27 @@ +const canvas = document.getElementById("matrix-canvas"); +const ctx = canvas.getContext("2d"); +canvas.width = window.innerWidth; +canvas.height = window.innerHeight; +const letters = "アァイィウヴエェオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split(""); +const fontSize = 16; +const columns = Math.floor(canvas.width / fontSize); +const drops = new Array(columns).fill(1); +function drawMatrix() { + ctx.fillStyle = "rgba(0, 0, 0, 0.2)"; + ctx.fillRect(0, 0, canvas.width, canvas.height); + ctx.fillStyle = "#39FF14"; + ctx.font = fontSize + "px monospace"; + for (let i = 0; i < drops.length; i++) { + const text = letters[Math.floor(Math.random() * letters.length)]; + ctx.fillText(text, i * fontSize, drops[i] * fontSize); + if (drops[i] * fontSize > canvas.height || Math.random() > 0.975) { + drops[i] = 0; + } + drops[i]++; + } +} +setInterval(drawMatrix, 50); +window.addEventListener("resize", () => { + canvas.width = window.innerWidth; + canvas.height = window.innerHeight; +}); \ No newline at end of file diff --git a/public/styles_home.css b/public/styles_home.css index 0673ad3..226bd5c 100644 --- a/public/styles_home.css +++ b/public/styles_home.css @@ -125,4 +125,15 @@ button.logout { .hidden { display: none; +} + +#matrix-canvas { + position: fixed; + top: 0; + left: 0; + z-index: -1; + width: 100vw; + height: 100vh; + background: transparent; + pointer-events: none; } \ No newline at end of file