Files
cactoz.su/frontend/js/matrix-rain.js
T
cacto a1b123dd13 Редизайн под новую Matrix-стилистику + RU/EN переключатель языка
Новая шапка (sticky, blur, мигающий курсор), нумерованные секции резюме
с полным опытом работы и новым разделом «Образование», карточки
проектов в стиле drwxr-xr-x, более яркий дождь на фоне. Добавлен
i18n-модуль (frontend/js/i18n.js) с переключателем EN/RU: резюме и
проекты полностью переведены, в игре переведены статичные подписи
интерфейса лобби и боя (данные от сервера остаются на русском).
2026-08-09 21:42:57 +05:00

49 lines
1.6 KiB
JavaScript

const canvas = document.getElementById('matrix-rain');
if (canvas && !window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
const ctx = canvas.getContext('2d');
const chars = 'アカサタナハマヤラワ0123456789ABCDEFcacto$#@%&*'.split('');
const fontSize = 15;
const bg = getComputedStyle(document.documentElement).getPropertyValue('--color-bg').trim();
let columns = 0;
let drops = [];
function setup() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
columns = Math.floor(canvas.width / fontSize);
drops = new Array(columns).fill(0).map(() => Math.floor((Math.random() * canvas.height) / fontSize));
}
function draw() {
ctx.fillStyle = `${bg}cc`;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.font = `${fontSize}px monospace`;
for (let i = 0; i < columns; i++) {
const char = chars[Math.floor(Math.random() * chars.length)];
const x = i * fontSize;
const y = drops[i] * fontSize;
// «голова» капли — редкая, чуть ярче, со свечением
const isHead = Math.random() > 0.94;
ctx.shadowColor = 'rgba(100, 255, 160, 0.9)';
ctx.shadowBlur = isHead ? 10 : 0;
ctx.fillStyle = isHead ? '#d2ffe1' : Math.random() > 0.98 ? '#9fa3a0' : '#00ff41';
ctx.fillText(char, x, y);
if (y > canvas.height && Math.random() > 0.975) {
drops[i] = 0;
} else {
drops[i]++;
}
}
ctx.shadowBlur = 0;
}
setup();
window.addEventListener('resize', setup);
setInterval(draw, 50);
}