(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();
})();
JavaScript отключён. Чтобы полноценно использовать наш сайт, включите JavaScript в своём браузере.
Вы используете устаревший браузер. Этот и другие сайты могут отображаться в нём некорректно.
Вам необходимо обновить браузер или попробовать использовать
другой .
Пользователи, оставившие реакции к сообщению №2004
Сообщения
2.869
Реакции
5.256
Репутация
1.144
Баллы
231
46
Сообщения
2.469
Реакции
1.531
Репутация
266
Баллы
231
Полтава
Сообщения
13.310
Реакции
7.494
Репутация
799
Баллы
131
Загрузка…