日期:2014-05-16  浏览次数:20318 次

分享几种超漂亮的JS烟花

今天看到蓝色理想有几个哥们都发了自己写的烟花效果,弄的心里痒痒,自己也想写一个出来玩,结果把IE写死好几次,还是放弃了,这里转几个别人写的效果上来分享!

转自:http://www.ok22.org/art_detail.aspx?id=176(可直接运行)

Html代码复制代码运行
  1. <script?type="text/javascript">??
  2. ????var?fireworks?=?function(){ ??
  3. ?????this.size?=?20; ??
  4. ?????this.rise(); ??
  5. ????} ??
  6. ????fireworks.prototype?=?{ ??
  7. ?????color:function(){ ??
  8. ??????var?c?=?['0','3','6','9','c','f']; ??
  9. ??????var?t?=?[c[Math.floor(Math.random()*100)%6],'0','f']; ??
  10. ??????t.sort(function(){return?Math.random()>0.5?-1:1;}); ??
  11. ??????return?'#'+t.join(''); ??
  12. ?????}, ??
  13. ?????aheight:function(){ ??
  14. ??????var?h?=?document.documentElement.clientHeight-250; ??
  15. ??????return?Math.abs(Math.floor(Math.random()*h-200))+201; ??
  16. ?????}, ??
  17. ?????firecracker:function(){ ??
  18. ??????var?b?=?document.createElement('div'); ??
  19. ??????var?w?=?document.documentElement.clientWidth; ??
  20. ??????b.style.position?=?'absolute'; ??
  21. ??????b.style.color?=?this.color(); ??
  22. ??????b.style.bottom?=?0; ??
  23. ??????b.style.left?=?Math.floor(Math.random()*w)+1+'px'; ??
  24. ??????document.body.appendChild(b); ??
  25. ??????return?b; ??
  26. ?????}, ??
  27. ?????rise:function(){ ??
  28. ??????var?o?=?this.firecracker(); ??
  29. ??????var?n?=?this.aheight(); ??
  30. ??????var?c?=?this.color; ??
  31. ??????var?e?=?this.expl; ??
  32. ??????var?s?=?this.size; ??
  33. ??????var?k?=?n; ??
  34. ??????var?