Code
<style>
/* Canvas */
canvas {
position: fixed;
top: 0;
left: 0;
pointer-events: none;
}
</style>
</head>
<body>
<canvas id="snow"></canvas>
<script>
/* ❄️ მხოლოდ თოვლი */
const canvas = document.getElementById("snow");
const ctx = canvas.getContext("2d");
function resize() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
resize();
window.addEventListener("resize", resize);
let snowflakes = [];
for (let i = 0; i < 400; i++) {
snowflakes.push({
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
r: Math.random() * 3 + 1,
speed: Math.random() * 7 + 4,
drift: Math.random() * 2 - 1
});
}
function animateSnow() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "rgba(255,255,255,0.95)";
ctx.beginPath();
for (let f of snowflakes) {
ctx.moveTo(f.x, f.y);
ctx.arc(f.x, f.y, f.r, 0, Math.PI * 2);
}
ctx.fill();
for (let f of snowflakes) {
f.y += f.speed;
f.x += f.drift;
if (f.y > canvas.height) {
f.y = -5;
f.x = Math.random() * canvas.width;
}
if (f.x > canvas.width) f.x = 0;
if (f.x < 0) f.x = canvas.width;
}
requestAnimationFrame(animateSnow);
}
animateSnow();
</script>