|
24 | 24 | function createMatrixRain() { |
25 | 25 | const matrixContainer = document.getElementById('matrixRain'); |
26 | 26 | if (!matrixContainer) return; |
| 27 | + // Clear any existing content |
| 28 | + matrixContainer.innerHTML = ''; |
| 29 | + if (!matrixContainer) return; |
| 30 | + |
27 | 31 |
|
28 | 32 | const chars = '01アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲン'; |
29 | 33 |
|
30 | 34 | // Clear existing columns first |
31 | 35 | matrixContainer.innerHTML = ''; |
32 | 36 |
|
| 37 | + |
33 | 38 | for (let i = 0; i < 30; i++) { |
34 | 39 | const column = document.createElement('div'); |
35 | 40 | column.className = 'matrix-column'; |
|
39 | 44 | column.style.animation = `matrix-fall ${column.style.animationDuration} linear infinite`; |
40 | 45 | column.style.animationDelay = column.style.animationDelay; |
41 | 46 |
|
| 47 | + column.style.left = (i * 3.33) + '%'; |
| 48 | + column.style.animationDuration = (Math.random() * 5 + 3) + 's'; |
| 49 | + column.style.animationDelay = Math.random() * 5 + 's'; |
| 50 | + |
42 | 51 | let text = ''; |
43 | | - for (let j = 0; j < 15; j++) { |
44 | | - text += chars[Math.floor(Math.random() * chars.length)] + '<br>'; |
| 52 | + for (let j = 0; j < 25; j++) { |
| 53 | + text += chars[Math.floor(Math.random() * chars.length)] + '\n'; |
45 | 54 | } |
46 | | - column.innerHTML = text; |
| 55 | + column.textContent = text; |
47 | 56 | matrixContainer.appendChild(column); |
48 | 57 | } |
| 58 | + // Refresh columns periodically |
| 59 | + setInterval(() => { |
| 60 | + const columns = matrixContainer.querySelectorAll('.matrix-column'); |
| 61 | + columns.forEach(column => { |
| 62 | + if (Math.random() > 0.95) { |
| 63 | + let text = ''; |
| 64 | + for (let j = 0; j < 25; j++) { |
| 65 | + text += chars[Math.floor(Math.random() * chars.length)] + '\n'; |
| 66 | + } |
| 67 | + column.textContent = text; |
| 68 | + } |
| 69 | + }); |
| 70 | + }, 100); |
49 | 71 | } |
50 | 72 | // Floating Particles |
51 | 73 | function createParticles() { |
|
0 commit comments