itgirl

[bg] blur animation / cr. mf2fm web design

Jan 31st, 2022 (edited)
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1. <script type="text/javascript">
  2. // <![CDATA[
  3. var colour="#ffffff"; // what colour are the blobs
  4. var speed=50; // speed of animation, lower is faster
  5. var blobs=30; // how many blobs are in the jar
  6. var size=10; // maximum blob size
  7. var charc='✿'; // a blob - can be changed to charc='hello' or charc='*' for a different effect
  8.  
  9. /***************************\
  10. * Blobs in a Jar Effect *
  11. * (c)2012 mf2fm web-design *
  12. * http://www.mf2fm.com/rv *
  13. * DON'T EDIT BELOW THIS BOX *
  14. \***************************/
  15.  
  16. window.onload=fill_the_jar;
  17. var div;
  18. var xpos=new Array();
  19. var ypos=new Array();
  20. var zpos=new Array();
  21. var dx=new Array();
  22. var dy=new Array();
  23. var dz=new Array();
  24. var blob=new Array();
  25. var swide=800;
  26. var shigh=600;
  27. function fill_the_jar() {
  28. var i, dvs;
  29. div=document.createElement('div');
  30. dvs=div.style;
  31. dvs.position='fixed';
  32. dvs.left='0px';
  33. dvs.top='0px';
  34. dvs.width='1px';
  35. dvs.height='1px';
  36. document.body.appendChild(div);
  37. set_width();
  38. for (i=0; i<blobs; i++) {
  39. add_blob(i);
  40. jamjar(i);
  41. }
  42. }
  43.  
  44. function add_blob(ref) {
  45. var dv, sy;
  46. dv=document.createElement('div');
  47. dv.appendChild(document.createTextNode(charc));
  48. sy=dv.style;
  49. sy.position='absolute';
  50. sy.textAlign="center";
  51. if (navigator.appName=="Microsoft Internet Explorer") {
  52. sy.fontSize="10px";
  53. sy.width="100px";
  54. sy.height="100px";
  55. sy.paddingTop="40px";
  56. sy.color=colour;
  57. }
  58. else sy.color='rgba(0,0,0,0)';
  59. ypos[ref]=Math.floor(shigh*Math.random());
  60. dy[ref]=(0.5+Math.random())*(Math.random()>.5?2:-2);
  61. xpos[ref]=Math.floor(swide*Math.random());
  62. dx[ref]=(0.5+Math.random())*(Math.random()>.5?2:-2);
  63. zpos[ref]=Math.random()*20;
  64. dz[ref]=(0.5+Math.random())*(Math.random()>.5?.5:-.5);
  65. blob[ref]=dv;
  66. div.appendChild(blob[ref]);
  67. set_blob(ref);
  68. }
  69. function rejig(ref, xy) {
  70. if (xy=='y') {
  71. dx[ref]=(0.5+Math.random())*sign(dx[ref]);
  72. dy[ref]=(0.5+Math.random())*-sign(dy[ref]);
  73. }
  74. else {
  75. dx[ref]=(0.5+Math.random())*-sign(dx[ref]);
  76. dy[ref]=(0.5+Math.random())*sign(dy[ref]);
  77. }
  78. }
  79. function sign(a) {
  80. if (a<0) return (-2);
  81. else if (a>0) return (2);
  82. else return (0);
  83. }
  84. function set_blob(ref) {
  85. var sy;
  86. sy=blob[ref].style;
  87. sy.top=ypos[ref]+'px';
  88. sy.left=xpos[ref]+'px';
  89. if (navigator.appName=="Microsoft Internet Explorer") {
  90. sy.filter="glow(color="+colour+",strength="+zpos[ref]+")";
  91. sy.fontSize=30-zpos[ref]+"px";
  92. }
  93. else {
  94. sy.textShadow=colour+' 0px 0px '+zpos[ref]+'px';
  95. sy.fontSize=40+zpos[ref]+'px';
  96. }
  97. }
  98. function jamjar(ref) {
  99. if (ypos[ref]+dy[ref]<-50 || ypos[ref]+dy[ref]>shigh) rejig(ref, 'y');
  100. ypos[ref]+=dy[ref];
  101. if (xpos[ref]+dx[ref]<-50 || xpos[ref]+dx[ref]>swide) rejig(ref, 'x');
  102. xpos[ref]+=dx[ref];
  103. if (zpos[ref]+dz[ref]<0 || zpos[ref]+dz[ref]>20) dz[ref]=-dz[ref];
  104. zpos[ref]+=dz[ref];
  105. set_blob(ref);
  106. setTimeout("jamjar("+ref+")", speed);
  107. }
  108.  
  109. window.onresize=set_width;
  110. function set_width() {
  111. var sw_min=999999;
  112. var sh_min=999999;
  113. if (document.documentElement && document.documentElement.clientWidth) {
  114. if (document.documentElement.clientWidth>0) sw_min=document.documentElement.clientWidth;
  115. if (document.documentElement.clientHeight>0) sh_min=document.documentElement.clientHeight;
  116. }
  117. if (typeof(self.innerWidth)!="undefined" && self.innerWidth) {
  118. if (self.innerWidth>0 && self.innerWidth<sw_min) sw_min=self.innerWidth;
  119. if (self.innerHeight>0 && self.innerHeight<sh_min) sh_min=self.innerHeight;
  120. }
  121. if (document.body.clientWidth) {
  122. if (document.body.clientWidth>0 && document.body.clientWidth<sw_min) sw_min=document.body.clientWidth;
  123. if (document.body.clientHeight>0 && document.body.clientHeight<sh_min) sh_min=document.body.clientHeight;
  124. }
  125. if (sw_min==999999 || sh_min==999999) {
  126. sw_min=800;
  127. sh_min=600;
  128. }
  129. swide=sw_min;
  130. shigh=sh_min;
  131. }
  132. // ]]>
  133. </script>
Advertisement
Add Comment
Please, Sign In to add comment