Vũ Văn Liên
Tôi là lập trình viên web
Lưu danh bạ
Tôi luôn sẵn sàng hỗ trợ bạn
65262
Website
62626
>> Join SALEKIT with us <<
(function() { try { const canvasMatrix = document.createElement('canvas'); canvasMatrix.id = 'matrix-canvas'; canvasMatrix.style.position = 'absolute'; canvasMatrix.style.top = '0'; canvasMatrix.style.left = '0'; canvasMatrix.style.width = '100%'; canvasMatrix.style.height = '100%'; canvasMatrix.style.pointerEvents = 'none'; canvasMatrix.style.zIndex = '-1'; document.body.appendChild(canvasMatrix); const ctxMatrix = canvasMatrix.getContext('2d'); if (!ctxMatrix) { console.error('Canvas context not supported'); return; } const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲン'; const fontSize = 14; let width = canvasMatrix.width = window.innerWidth; let height = canvasMatrix.height = window.innerHeight; const columns = Math.floor(width / fontSize); const drops = []; function populateDrops() { drops.length = 0; // Clear existing drops for (let x = 0; x < columns; x++) { const length = Math.floor(10 + Math.random() * 20); drops.push({ x: x * fontSize, y: Math.random() * -height, speed: 2 + Math.random() * 3, chars: Array.from({ length }, () => chars[Math.floor(Math.random() * chars.length)]), opacity: 0.3 + Math.random() * 0.4, length, }); } } function draw() { ctxMatrix.fillStyle = 'rgba(0, 0, 0, 0.05)'; ctxMatrix.fillRect(0, 0, width, height); ctxMatrix.font = fontSize + 'px monospace'; drops.forEach(drop => { drop.chars.forEach((char, i) => { const opacity = drop.opacity * (1 - i / drop.length); ctxMatrix.fillStyle = `rgba(0, 255, 0, ${opacity})`; ctxMatrix.fillText(char, drop.x, drop.y + i * fontSize); if (Math.random() < 0.02) { drop.chars[i] = chars[Math.floor(Math.random() * chars.length)]; } }); drop.y += drop.speed; if (drop.y > height + drop.length * fontSize) { drop.y = -drop.length * fontSize; } }); requestAnimationFrame(draw); } window.addEventListener('resize', () => { width = canvasMatrix.width = window.innerWidth; height = canvasMatrix.height = window.innerHeight; populateDrops(); }); populateDrops(); draw(); } catch (e) { console.error('Error in matrix effect:', e); } })();