(function() { const canvas = document.createElement('canvas'); canvas.id = 'fireworks'; document.body.appendChild(canvas); const ctx = canvas.getContext('2d'); let w = canvas.width = window.innerWidth; let h = canvas.height = window.innerHeight; window.addEventListener('resize', () => { w = canvas.width = window.innerWidth; h = canvas.height = window.innerHeight; }); canvas.style.position = 'fixed'; canvas.style.top = 0; canvas.style.left = 0; canvas.style.pointerEvents = 'none'; canvas.style.zIndex = 9999; const particles = []; function Particle(x, y) { this.x = x; this.y = y; this.vx = (Math.random() - 0.5) * 4; this.vy = (Math.random() - 0.5) * 4; this.life = 60; this.color = Math.random() > 0.5 ? '#0057b7' : '#ffd700'; } function loop() { ctx.clearRect(0, 0, w, h); if (Math.random() < 0.05) { const x = Math.random() * w; const y = Math.random() * h / 2; for (let i = 0; i < 30; i++) { particles.push(new Particle(x, y)); } } for (let i = particles.length - 1; i >= 0; i--) { const p = particles[i]; p.x += p.vx; p.y += p.vy; p.life--; ctx.beginPath(); ctx.arc(p.x, p.y, 2, 0, Math.PI * 2); ctx.fillStyle = p.color; ctx.fill(); if (p.life <= 0) particles.splice(i, 1); } requestAnimationFrame(loop); } loop(); })();

Пользователи, оставившие реакции к сообщению №2

Все (1) Мне нравится Мне нравится (1)

Назад
Сверху Снизу