Fairy Dust Cursor v1
A fairy dust animation that falls from the cursor trail.
by padhg
HTML
<body>
<div>Move your mouse in this box.</div>
</body>
CSS
html, body {
height: 100%;
}
JavaScript
/******************************
* Tinkerbell Magic Sparkle *
* (c)2005-13 mf2fm web-design *
* http://www.mf2fm.com/rv *
******************************/
var colour = "random", // or "#000000"
sparkles = 50,
x = 400,
ox = 400,
y = 300,
oy = 300,
swide = 800,
shigh = 600,
sleft = 0,
sdown = 0,
tiny = [],
star = [],
starv = [],
starx = [],
stary = [],
tinyx = [],
tinyy = [],
tinyv = [];
function sparkle() {
var c;
if (Math.abs(x - ox) > 1 || Math.abs(y - oy) > 1) {
ox = x;
oy = y;
for (c = 0; c < sparkles; c++) if (!starv[c]) {
star[c].style.left = (starx[c] = x) + "px";
star[c].style.top = (stary[c] = y + 1) + "px";
star[c].style.clip = "rect(0px, 5px, 5px, 0px)";
star[c].childNodes[0].style.backgroundColor = star[c].childNodes[1].style.backgroundColor = (colour == "random") ? newColour() : colour;
star[c].style.visibility = "visible";
starv[c] = 50;
break;
}
}
for (c = 0; c < sparkles; c++) {
if (starv[c]) update_star(c);
if (tinyv[c]) update_tiny(c);
}
setTimeout(sparkle, 40);
}
function update_star(i) {
if (--starv[i] == 25) star[i].style.clip = "rect(1px, 4px, 4px, 1px)";
if (starv[i]) {
stary[i] += 1 + Math.random() * 3;
starx[i] += (i % 5 - 2) / 5;
if (stary[i] < shigh + sdown) {
star[i].style.top = stary[i] + "px";
star[i].style.left = starx[i] + "px";
} else {
star[i].style.visibility = "hidden";
starv[i] = 0;
return;
}
} else {
tinyv[i] = 50;
tiny[i].style.top = (tinyy[i] = stary[i]) + "px";
tiny[i].style.left = (tinyx[i] = starx[i]) + "px";
tiny[i].style.width = "2px";
tiny[i].style.height = "2px";
tiny[i].style.backgroundColor =...