snow06s1
<div> <canvas width="500" height="500" id="snow_06" style="background-color:rgba(255, 255, 255, 1.0);"> </canvas> </div>
<script>
var canvas = document.getElementById('snow_06');
var context = canvas.getContext('2d');
const PARTICLE = 1000;
const rate = 1.005;
const center_x = canvas.width / 2;
const center_y = canvas.height / 2;
var x = new Array(PARTICLE);
var y = new Array(PARTICLE);
var size = new Array(PARTICLE);
for(let ti = 0 ; ti < PARTICLE ; ti++){<br /> x[ti] = Math.random() * canvas.width;
y[ti] = Math.random() * canvas.height;
size[ti] = (Math.random() + 0.001) * 60 ;
var tmp;
}
function draw(){
context.globalCompositeOperation = "source-over";
context.fillStyle = "rgb(15,15,31)";
context.globalAlpha = 1.0;
context.fillRect(0, 0, canvas.width, canvas.height);
for( var i=0 ; i<PARTICLE ; i++ ){<br /> context.beginPath();
context.globalCompositeOperation = "lighter";
tmp = size[i] - 20.0;
tmp=Math.abs(tmp);
context.fillStyle = "white";
context.globalAlpha = 1.0 / Math.pow(tmp+1.0, 1.7);
context.arc(x[i], y[i], tmp + 1.0, 0, Math.PI*2, false);
context.fill();
x[i] += (x[i] - center_x) * size[i] * 0.0001;
y[i] += (y[i] - center_y) * size[i] * 0.0001;
size[i] *= rate;
if(x[i]<0 || x[i]>canvas.width || y[i]<0 || y[i]>canvas.height){
x[i] = Math.random() * canvas.width;
y[i] = Math.random() * canvas.height;
size[i] = 0.5;
}
}
}
setInterval(draw,16);
</script>
Ende;