Advertisement
reijeo

fireworks mf2fm

Jul 16th, 2022
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.05 KB | None | 0 0
  1. <script type="text/javascript">
  2. // <![CDATA[
  3. var bits=80; // how many bits
  4. var speed=33; // how fast - smaller is faster
  5. var bangs=5; // how many can be launched simultaneously (note that using too many can slow the script down)
  6. var colours=new Array("#03f", "#f03", "#0e0", "#93f", "#0cf", "#f93", "#f0c");
  7. // blue red green purple cyan orange pink
  8.  
  9. /****************************
  10. * Fireworks Effect *
  11. *(c)2004-14 mf2fm web-design*
  12. * http://www.mf2fm.com/rv *
  13. * DON'T EDIT BELOW THIS BOX *
  14. ****************************/
  15. var bangheight=new Array();
  16. var intensity=new Array();
  17. var colour=new Array();
  18. var Xpos=new Array();
  19. var Ypos=new Array();
  20. var dX=new Array();
  21. var dY=new Array();
  22. var stars=new Array();
  23. var decay=new Array();
  24. var swide=800;
  25. var shigh=600;
  26. var boddie;
  27.  
  28. if (typeof('addRVLoadEvent')!='function') function addRVLoadEvent(funky) {
  29. var oldonload=window.onload;
  30. if (typeof(oldonload)!='function') window.onload=funky;
  31. else window.onload=function() {
  32. if (oldonload) oldonload();
  33. funky();
  34. }
  35. }
  36.  
  37. addRVLoadEvent(light_blue_touchpaper);
  38.  
  39. function light_blue_touchpaper() { if (document.getElementById) {
  40. var i;
  41. boddie=document.createElement("div");
  42. boddie.style.position="fixed";
  43. boddie.style.top="0px";
  44. boddie.style.left="0px";
  45. boddie.style.overflow="visible";
  46. boddie.style.width="1px";
  47. boddie.style.height="1px";
  48. boddie.style.backgroundColor="transparent";
  49. document.body.appendChild(boddie);
  50. set_width();
  51. for (i=0; i<bangs; i++) {
  52. write_fire(i);
  53. launch(i);
  54. setInterval('stepthrough('+i+')', speed);
  55. }
  56. }}
  57.  
  58. function write_fire(N) {
  59. var i, rlef, rdow;
  60. stars[N+'r']=createDiv('|', 12);
  61. boddie.appendChild(stars[N+'r']);
  62. for (i=bits*N; i<bits+bits*N; i++) {
  63. stars[i]=createDiv('*', 13);
  64. boddie.appendChild(stars[i]);
  65. }
  66. }
  67.  
  68. function createDiv(char, size) {
  69. var div=document.createElement("div");
  70. div.style.font=size+"px monospace";
  71. div.style.position="absolute";
  72. div.style.backgroundColor="transparent";
  73. div.appendChild(document.createTextNode(char));
  74. return (div);
  75. }
  76.  
  77. function launch(N) {
  78. colour[N]=Math.floor(Math.random()*colours.length);
  79. Xpos[N+"r"]=swide*0.5;
  80. Ypos[N+"r"]=shigh-5;
  81. bangheight[N]=Math.round((0.5+Math.random())*shigh*0.4);
  82. dX[N+"r"]=(Math.random()-0.5)*swide/bangheight[N];
  83. if (dX[N+"r"]>1.25) stars[N+"r"].firstChild.nodeValue="/";
  84. else if (dX[N+"r"]<-1.25) stars[N+"r"].firstChild.nodeValue="\\";
  85. else stars[N+"r"].firstChild.nodeValue="|";
  86. stars[N+"r"].style.color=colours[colour[N]];
  87. }
  88.  
  89. function bang(N) {
  90. var i, Z, A=0;
  91. for (i=bits*N; i<bits+bits*N; i++) {
  92. Z=stars[i].style;
  93. Z.left=Xpos[i]+"px";
  94. Z.top=Ypos[i]+"px";
  95. if (decay[i]) decay[i]--;
  96. else A++;
  97. if (decay[i]==15) Z.fontSize="7px";
  98. else if (decay[i]==7) Z.fontSize="2px";
  99. else if (decay[i]==1) Z.visibility="hidden";
  100. if (decay[i]>1 && Math.random()<.1) {
  101. Z.visibility="hidden";
  102. setTimeout('stars['+i+'].style.visibility="visible"', speed-1);
  103. }
  104. Xpos[i]+=dX[i];
  105. Ypos[i]+=(dY[i]+=1.25/intensity[N]);
  106.  
  107. }
  108. if (A!=bits) setTimeout("bang("+N+")", speed);
  109. }
  110.  
  111. function stepthrough(N) {
  112. var i, M, Z;
  113. var oldx=Xpos[N+"r"];
  114. var oldy=Ypos[N+"r"];
  115. Xpos[N+"r"]+=dX[N+"r"];
  116. Ypos[N+"r"]-=4;
  117. if (Ypos[N+"r"]<bangheight[N]) {
  118. M=Math.floor(Math.random()*3*colours.length);
  119. intensity[N]=5+Math.random()*4;
  120. for (i=N*bits; i<bits+bits*N; i++) {
  121. Xpos[i]=Xpos[N+"r"];
  122. Ypos[i]=Ypos[N+"r"];
  123. dY[i]=(Math.random()-0.5)*intensity[N];
  124. dX[i]=(Math.random()-0.5)*(intensity[N]-Math.abs(dY[i]))*1.25;
  125. decay[i]=16+Math.floor(Math.random()*16);
  126. Z=stars[i];
  127. if (M<colours.length) Z.style.color=colours[i%2?colour[N]:M];
  128. else if (M<2*colours.length) Z.style.color=colours[colour[N]];
  129. else Z.style.color=colours[i%colours.length];
  130. Z.style.fontSize="13px";
  131. Z.style.visibility="visible";
  132. }
  133. bang(N);
  134. launch(N);
  135. }
  136. stars[N+"r"].style.left=oldx+"px";
  137. stars[N+"r"].style.top=oldy+"px";
  138. }
  139.  
  140. window.onresize=set_width;
  141. function set_width() {
  142. var sw_min=999999;
  143. var sh_min=999999;
  144. if (document.documentElement && document.documentElement.clientWidth) {
  145. if (document.documentElement.clientWidth>0) sw_min=document.documentElement.clientWidth;
  146. if (document.documentElement.clientHeight>0) sh_min=document.documentElement.clientHeight;
  147. }
  148. if (typeof(self.innerWidth)!="undefined" && self.innerWidth) {
  149. if (self.innerWidth>0 && self.innerWidth<sw_min) sw_min=self.innerWidth;
  150. if (self.innerHeight>0 && self.innerHeight<sh_min) sh_min=self.innerHeight;
  151. }
  152. if (document.body.clientWidth) {
  153. if (document.body.clientWidth>0 && document.body.clientWidth<sw_min) sw_min=document.body.clientWidth;
  154. if (document.body.clientHeight>0 && document.body.clientHeight<sh_min) sh_min=document.body.clientHeight;
  155. }
  156. if (sw_min==999999 || sh_min==999999) {
  157. sw_min=800;
  158. sh_min=600;
  159. }
  160. swide=sw_min;
  161. shigh=sh_min;
  162. }
  163. // ]]>
  164. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement