2022-12-29 01:53:33 +00:00
|
|
|
// Cool snow that was TOTALLY NOT stolen from someone else :-)
|
2022-12-13 16:59:47 +00:00
|
|
|
|
|
|
|
// Amount of Snowflakes
|
2022-12-29 01:53:33 +00:00
|
|
|
var snowMax = 64;
|
2022-12-13 16:59:47 +00:00
|
|
|
|
|
|
|
// Snowflake Colours
|
|
|
|
var snowColor = ["#fff"];
|
|
|
|
|
|
|
|
// Snow Entity
|
|
|
|
var snowEntity = "*";
|
|
|
|
|
|
|
|
// Falling Velocity
|
|
|
|
var snowSpeed = 0.75;
|
|
|
|
|
|
|
|
// Minimum Flake Size
|
2022-12-29 01:53:33 +00:00
|
|
|
var snowMinSize = 16;
|
2022-12-13 16:59:47 +00:00
|
|
|
|
|
|
|
// Maximum Flake Size
|
2022-12-29 01:53:33 +00:00
|
|
|
var snowMaxSize = 32;
|
2022-12-13 16:59:47 +00:00
|
|
|
|
|
|
|
// Refresh Rate (in milliseconds)
|
|
|
|
var snowRefresh = 75;
|
|
|
|
|
|
|
|
// Additional Styles
|
|
|
|
var snowStyles = "z-index: 0; cursor: default; user-select: none;";
|
|
|
|
|
|
|
|
/*
|
|
|
|
// End of Configuration
|
|
|
|
// ----------------------------------------
|
|
|
|
// Do not modify the code below this line
|
|
|
|
*/
|
|
|
|
|
|
|
|
var snow = [],
|
|
|
|
pos = [],
|
|
|
|
coords = [],
|
|
|
|
lefr = [],
|
|
|
|
marginBottom,
|
|
|
|
marginRight;
|
|
|
|
|
|
|
|
function randomise(range) {
|
|
|
|
rand = Math.floor(range * Math.random());
|
|
|
|
return rand;
|
|
|
|
}
|
|
|
|
|
|
|
|
function initSnow() {
|
|
|
|
var snowSize = snowMaxSize - snowMinSize;
|
|
|
|
marginBottom = document.body.scrollHeight - 5;
|
|
|
|
marginRight = document.body.clientWidth - 15;
|
|
|
|
|
|
|
|
for (i = 0; i <= snowMax; i++) {
|
|
|
|
coords[i] = 0;
|
|
|
|
lefr[i] = Math.random() * 15;
|
|
|
|
pos[i] = 0.03 + Math.random() / 10;
|
|
|
|
snow[i] = document.getElementById("flake" + i);
|
|
|
|
snow[i].style.fontFamily = "inherit";
|
|
|
|
snow[i].size = randomise(snowSize) + snowMinSize;
|
|
|
|
snow[i].style.fontSize = snow[i].size + "px";
|
|
|
|
snow[i].style.color = snowColor[randomise(snowColor.length)];
|
|
|
|
snow[i].style.zIndex = -1;
|
|
|
|
snow[i].sink = snowSpeed * snow[i].size / 5;
|
|
|
|
snow[i].posX = randomise(marginRight - snow[i].size);
|
|
|
|
snow[i].posY = randomise(2 * marginBottom - marginBottom - 2 * snow[i].size);
|
|
|
|
snow[i].style.left = snow[i].posX + "px";
|
|
|
|
snow[i].style.top = snow[i].posY + "px";
|
|
|
|
}
|
|
|
|
|
|
|
|
moveSnow();
|
|
|
|
}
|
|
|
|
|
|
|
|
function resize() {
|
|
|
|
marginBottom = document.body.scrollHeight - 5;
|
|
|
|
marginRight = document.body.clientWidth - 15;
|
|
|
|
}
|
|
|
|
|
|
|
|
function moveSnow() {
|
|
|
|
for (i = 0; i <= snowMax; i++) {
|
|
|
|
coords[i] += pos[i];
|
|
|
|
snow[i].posY += snow[i].sink;
|
|
|
|
snow[i].style.left = snow[i].posX + lefr[i] * Math.sin(coords[i]) + "px";
|
|
|
|
snow[i].style.top = snow[i].posY + "px";
|
|
|
|
|
|
|
|
if (snow[i].posY >= marginBottom - 2 * snow[i].size || parseInt(snow[i].style.left) > (marginRight - 3 * lefr[i])) {
|
|
|
|
snow[i].posX = randomise(marginRight - snow[i].size);
|
|
|
|
snow[i].posY = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setTimeout("moveSnow()", snowRefresh);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i <= snowMax; i++) {
|
|
|
|
document.write("<span id='flake" + i + "' style='" + snowStyles + "position:absolute;top:-" + snowMaxSize + "'>" + snowEntity + "</span>");
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener('resize', resize);
|
|
|
|
window.addEventListener('load', initSnow);
|