|
54 | 54 | .ai-disclaimer p { |
55 | 55 | margin: 0; |
56 | 56 | } |
| 57 | + |
| 58 | +#particles { |
| 59 | + position: fixed; |
| 60 | + top: 0; |
| 61 | + left: 0; |
| 62 | + width: 100%; |
| 63 | + height: 100%; |
| 64 | + pointer-events: none; |
| 65 | + z-index: 0; |
| 66 | +} |
57 | 67 | </style> |
| 68 | + |
| 69 | +<script> |
| 70 | +document.addEventListener('DOMContentLoaded', function() { |
| 71 | + var canvas = document.createElement('canvas'); |
| 72 | + canvas.id = 'particles'; |
| 73 | + document.body.appendChild(canvas); |
| 74 | + var ctx = canvas.getContext('2d'); |
| 75 | + var particles = []; |
| 76 | + var count = 60; |
| 77 | + |
| 78 | + function resize() { |
| 79 | + canvas.width = window.innerWidth; |
| 80 | + canvas.height = window.innerHeight; |
| 81 | + } |
| 82 | + resize(); |
| 83 | + window.addEventListener('resize', resize); |
| 84 | + |
| 85 | + for (var i = 0; i < count; i++) { |
| 86 | + particles.push({ |
| 87 | + x: Math.random() * canvas.width, |
| 88 | + y: Math.random() * canvas.height, |
| 89 | + r: Math.random() * 1.5 + 0.5, |
| 90 | + dx: (Math.random() - 0.5) * 0.3, |
| 91 | + dy: (Math.random() - 0.5) * 0.3, |
| 92 | + o: Math.random() * 0.4 + 0.1 |
| 93 | + }); |
| 94 | + } |
| 95 | + |
| 96 | + function draw() { |
| 97 | + ctx.clearRect(0, 0, canvas.width, canvas.height); |
| 98 | + for (var i = 0; i < particles.length; i++) { |
| 99 | + var p = particles[i]; |
| 100 | + ctx.beginPath(); |
| 101 | + ctx.arc(p.x, p.y, p.r, 0, Math.PI * 2); |
| 102 | + ctx.fillStyle = 'rgba(255,255,255,' + p.o + ')'; |
| 103 | + ctx.fill(); |
| 104 | + p.x += p.dx; |
| 105 | + p.y += p.dy; |
| 106 | + if (p.x < 0) p.x = canvas.width; |
| 107 | + if (p.x > canvas.width) p.x = 0; |
| 108 | + if (p.y < 0) p.y = canvas.height; |
| 109 | + if (p.y > canvas.height) p.y = 0; |
| 110 | + } |
| 111 | + requestAnimationFrame(draw); |
| 112 | + } |
| 113 | + draw(); |
| 114 | +}); |
| 115 | +</script> |
0 commit comments