let W,H,flakes=[];
function resize(){W=c.width=window.innerWidth;H=c.height=window.innerHeight;}
resize(); window.addEventListener('resize',()=>{resize();init();});
function mkFlake(){
const r=Math.random();
return {
x:Math.random()*W,
y:Math.random()*H,
r:r<0.5?Math.random()*1.2+0.4:Math.random()*2.2+1.2,
speed:Math.random()*0.35+0.1,
drift:Math.random()*0.18-0.09,
opacity:Math.random()*0.28+0.04,
wobble:Math.random()*Math.PI*2,
wobbleSpeed:Math.random()*0.008+0.002,
};
}
function init(){flakes=Array.from({length:120},mkFlake);}
init();
function draw(){
ctx.clearRect(0,0,W,H);
for(const f of flakes){
ctx.beginPath();
ctx.arc(f.x,f.y,f.r,0,Math.PI*2);
ctx.fillStyle=`rgba(255,255,255,${f.opacity})`;
ctx.fill();
}
requestAnimationFrame(draw);
}
function update(){
for(const f of flakes){
f.wobble+=f.wobbleSpeed;
f.x+=f.drift+Math.sin(f.wobble)*0.12;
f.y+=f.speed;
if(f.y>H+4){f.y=-4;f.x=Math.random()*W;}
if(f.x>W+4)f.x=-4;
if(f.x<-4)f.x=W+4;
}
setTimeout(update,16);
}
draw(); update();
})();
idk im kinda boring,
I'll think of something to put here eventually
