const fontSize = 16; const columns = canvas.width / fontSize; const drops = new Array(Math.floor(columns)).fill(1); function draw() { // fade the canvas slightly ctx.fillStyle = "rgba(0, 0, 0, 0.05)"; ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = "#00ff00"; ctx.font = fontSize + "px monospace"; for (let i = 0; i < drops.length; i++) { const text = lettersArray[Math.floor(Math.random() * lettersArray.length)]; ctx.fillText(text, i * fontSize, drops[i] * fontSize); // randomly reset drop to top if (drops[i] * fontSize > canvas.height && Math.random() > 0.975) { drops[i] = 0; } drops[i]++; } } setInterval(draw, 33); // Update canvas size on resize window.addEventListener('resize', () => { canvas.width = window.innerWidth; canvas.height = window.innerHeight; });