JS1K

#2: the original

Source description for demo by Rob O'Dwyer.

function d(size, interval) { var txt = document.createElement('div'); s0(txt, 'position:absolute;left:' + r(800) + 'px;top:' + r(400) + 'px;'); s(txt, 'font-size:'+size+'px; opacity: 1.0;'); s(txt, 'color:rgb(' + r(255) + ',' + r(255) + ',' + r(255) + ');'); document.body.appendChild(txt); txt.innerHTML = u(); var interval = setInterval(function() { m(txt); }, interval); } function s0(e, s) { e.style.cssText = s; } function s(e, s) { e.style.cssText += s; } function m(l) { o = parseFloat(l.style.opacity) - 0.01; l.style.opacity = o; if(o < 0.1) { s0(l, 'position:absolute;left:' + r(800) + 'px;top:' + r(400) + 'px;'); s(l, 'color:rgb(' + r(255) + ',' + r(255) + ',' + r(255) + ');'); s(l, 'font-size:'+(14+r(72))+'px; opacity:1.0;'); l.innerHTML = u(); } } function u() { num = Math.round(0x10FFFF * Math.random()); var uni = eval('"\\u' + num.toString(16) + '"'); return (uni.length>1)? u() : uni; } function r(h) { return Math.round(h * Math.random()); } var canvas = document.getElementById("c"); var context = canvas.getContext('2d'); document.body.style.cssText="background-color:black;color:white;"; function l(num) { if(num > 0) { try { d(14+r(72), 10); } catch(e) { } setTimeout(function() { l(num - 1) }, 100); } } l(50);