返回
心录历程
首页
JavaScript烟花特效(一)
2014-05-01 03:11:01 -0400
此代码
仅
供
参
考
代码说明
添加说明文字
html代码
JavaScript代码
var firework = function(){ this.size = 40; this.speed = 0.1; this.rise(); } firework.prototype = { color:function(){ var c = ['0','3','6','9','c','f']; var t = [c[Math.floor(Math.random()*100)%6],'0','f']; t.sort(function(){return Math.random()>0.5?-1:1;}); return '#'+t.join(''); }, aheight:function(){ var h = document.documentElement.clientHeight; return Math.abs(Math.floor(Math.random()*h-200))+201; }, firecracker:function(){ var b = document.createElement('div'); var w = document.body.clientWidth; b.style.color = this.color(); b.style.position = 'absolute'; b.style.bottom = 0; b.style.left = Math.floor(Math.random()*w)+1+'px'; document.body.appendChild(b); return b; }, rise:function(){ var o = this.firecracker(); var n = this.aheight(); var speed = this.speed; var e = this.expl; var s = this.size; var k = n; var m = function(){ o.style.bottom = parseFloat(o.style.bottom)+k*speed+'px'; k-=k*speed; if(k<2){ clearInterval(clear); e(o,n,s,speed); } } o.innerHTML = '*'; if(parseInt(o.style.bottom)
代码演示
【本站仅供参考,版权归原作者所有】
«Newer
Older»
Comment:
Name:
Back to home
Subscribe
|
Register
|
Login
|
N