登 录
}; var fireball = function(){ var asize = [3,4,5,6,7,8]; var av = [10,11,12,13,15];
this.getrm = function(x){ return Math.round(Math.random()*x); }; this.getpv = function(v,p){ return [v*Math.cos(Math.PI*p),v*Math.sin(Math.PI*p)]; }; this.getf = function(sky,sx,sy,vx,vy,scolor){ var ssize = asize[this.getrm(asize.length-1)]; var fx = document.createElement('div'); fx.innerHTML = '●'; fx.style.color = scolor; fx.style.fontSize = ssize+'px'; fx.style.left = sx+'px'; fx.style.top = sy+'px'; sky.appendChild(fx); fireworks.call(fx,sky); fx.minh = sy; fx.g = 1; fx.onmove = function(x,y){ if(fx.times>10){fx.uninstall();return;} var fy = document.createElement('div'); fy.innerHTML = '.'; fy.style.color = scolor; fy.style.fontSize = '8px'; sky.appendChild(fy); fireworks.call(fy,sky); fy.minh = sy; fy.g = 1; fy.onmove = function(){if(fy.times>8||parseInt(fy.style.fontSize)<1){fy.uninstall();return;}fy.style.fontSize = parseInt(fy.style.fontSize)-1+'px';} fy.movepos(x,y,0,0); }; fx.movepos(sx,sy,vx,vy); }; this.fire = function(sky,sx,sy,scolor){ var n = this.getrm(16)+16,i=0; while(n>0){ var p = Math.random()*2; var v = av[this.getrm(av.length-1)]; var pv = this.getpv(v,p); this.getf(sky,sx,sy,pv[0],pv[1],scolor); n--; } }; }; var firebox = function(sky,delay){ sky = sky||document.body; delay = delay||500; var acolor = ['red','#fff894','#ffe3e4','#ddefc9','#e6d3ff','#5A0E86','#AC456A','#3FAC00','#2B5AAC','yellow','white']; var asize = [7,8,9,10,11,12]; var avy = [40,42,43,48,49,50]; var avx = [-3,-2,-1,0,1,2,3] this.total = 10000; this.timer = null; this.getrm = function(x){ return Math.round(Math.random()*x); }; this.getf = function(){ var scolor = acolor[this.getrm(acolor.length-1)]; var ssize = asize[this.getrm(asize.length-1)]; var sx = this.getrm(800)+100,sy = 800; var vx = avx[this.getrm(avx.length-1)],vy = avy[this.getrm(avy.length-1)]; var fx = document.createElement('div'); fx.innerHTML = '●'; fx.style.color = scolor; fx.style.fontSize = ssize+'px'; fx.style.left = sx+'px'; fx.style.top = sy+'px'; sky.appendChild(fx); fireworks.call(fx,sky); fx.minh = sy; fx.onmove = function(x,y){ if(fx.maxh&&fx.maxh<y){fx.uninstall();return;} var h = fx.minh-y; if(h>300){ var fy = document.createElement('div'); fy.innerHTML = '.'; fy.style.color = scolor; fy.style.fontSize = '3px'; sky.appendChild(fy); fireworks.call(fy,sky); fy.minh = sy; fy.onmove = function(){if(fy.times>15){fy.uninstall();return;}fy.style.fontSize = parseInt(fy.style.fontSize)+1+'px';} fy.movepos((x+ssize/2),(y+ssize),0,0); } }; fx.fireball = new fireball(); fx.onend = function(x,y){fx.fireball.fire(sky,x,y,scolor);} fx.movepos(sx,sy,vx,vy); this.total--; }; this.fire = function(){ if(this.total<=0){ window.clearTimeout(this.timer); this.timer = null; } this.getf(); with({fb:this}){ this.timer = window.setTimeout(function(){fb.fire()},delay); } }; }; </script> </head> <body> <table style="width:100%;height:100%;"><tr><td style="text-align:center;vertical-align:middle;"><h1 style="color:red;">Happy New Year!</h1></td></tr></table> <script type="text/javascript"> var delay = (/msie/i.test(navigator.appVersion))?3500:1500; var fx = new firebox(document.body,delay); fx.fire(); </script> </body> </html>
抱歉!评论已关闭.