Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. <script>
  2. /*
  3. Snow Fall 1 - no images - Java Script
  4. Visit http://rainbow.arch.scriptmania.com/scripts/
  5. for this script and many more
  6. */
  7.  
  8. // Set the number of snowflakes (more than 30 - 40 not recommended)
  9. var snowmax = 35
  10.  
  11. // Set the colors for the snow. Add as many colors as you like
  12. var snowcolor = ["#aaaacc","#ddddff","#ccccdd","#f3f3f3","#f0ffff"]
  13.  
  14. // Set the fonts, that create the snowflakes. Add as many fonts as you like
  15. var snowtype= ["Times","Arial","Times","Verdana"]
  16.  
  17. // Set the letter that creates your snowflake (recommended: * )
  18. var snowletter="*•"
  19.  
  20. // Set the speed of sinking (recommended values range from 0.3 to 2)
  21. var sinkspeed=0.6
  22.  
  23. // Set the maximum-size of your snowflakes
  24. var snowmaxsize=30
  25.  
  26. // Set the minimal-size of your snowflakes
  27. var snowminsize=8
  28.  
  29. // Set the snowing-zone
  30. // Set 1 for all-over-snowing, set 2 for left-side-snowing
  31. // Set 3 for center-snowing, set 4 for right-side-snowing
  32. var snowingzone=1
  33.  
  34. ///////////////////////////////////////////////////////////////////////////
  35. // CONFIGURATION ENDS HERE
  36. ///////////////////////////////////////////////////////////////////////////
  37.  
  38.  
  39. // Do not edit below this line
  40. var snow = [], marginbottom, marginright, timer, i_snow = 0, x_mv = [],
  41. crds = [], lftrght = [], browserinfos=navigator.userAgent;
  42. var ie5 = document.all&&document.getElementById&&!browserinfos.match(/Opera/)
  43. var ns6 = document.getElementById&&!document.all
  44. var opera = browserinfos.match(/Opera/)
  45. var browserok = ie5||ns6||opera
  46.  
  47. function randommaker(range) {
  48. rand = Math.floor(range*Math.random())
  49. return rand
  50. }
  51.  
  52. function initsnow() {
  53. marginbottom = document.body.scrollHeight
  54. marginright = document.body.clientWidth-15
  55.  
  56. var snowsizerange = snowmaxsize - snowminsize
  57. for(i = 0; i <= snowmax; i++) {
  58. crds[i] = 0;
  59. lftrght[i] = Math.random()*15;
  60. x_mv[i] = 0.03 + Math.random()/10;
  61.  
  62. snow[i] = document.getElementById("s"+i)
  63. snow[i].style.fontFamily = snowtype[randommaker(snowtype.length)]
  64. snow[i].size = randommaker(snowsizerange)+snowminsize
  65. snow[i].style.fontSize = snow[i].size+'px';
  66. snow[i].style.color = snowcolor[randommaker(snowcolor.length)]
  67. snow[i].style.zIndex = 1000
  68. snow[i].sink = sinkspeed*snow[i].size/5
  69.  
  70. if(snowingzone == 1) snow[i].posx = randommaker(marginright-snow[i].size)
  71. if(snowingzone == 2) snow[i].posx = randommaker(marginright/2-snow[i].size)
  72. if(snowingzone == 3) snow[i].posx = randommaker(marginright/2-snow[i].size)+marginright/4
  73. if(snowingzone == 4) snow[i].posx = randommaker(marginright/2-snow[i].size)+marginright/2
  74.  
  75. snow[i].posy = randommaker(2*marginbottom-marginbottom-2*snow[i].size)
  76. snow[i].style.left = snow[i].posx+'px';
  77. snow[i].style.top = snow[i].posy+'px';
  78. }
  79. movesnow()
  80. }
  81.  
  82. function movesnow() {
  83. for(i = 0; i <= snowmax; i++) {
  84. crds[i] += x_mv[i];
  85. snow[i].posy += snow[i].sink
  86. snow[i].style.left = snow[i].posx + lftrght[i] * Math.sin(crds[i]) + 'px';
  87. snow[i].style.top = snow[i].posy + 'px';
  88.  
  89. if(snow[i].posy>=marginbottom-2*snow[i].size || parseInt(snow[i].style.left) > (marginright-3*lftrght[i])){
  90. if(snowingzone == 1) snow[i].posx = randommaker(marginright-snow[i].size)
  91. if(snowingzone == 2) snow[i].posx = randommaker(marginright/2-snow[i].size)
  92. if(snowingzone == 3) snow[i].posx = randommaker(marginright/2-snow[i].size)+marginright/4
  93. if(snowingzone == 4) snow[i].posx = randommaker(marginright/2-snow[i].size)+marginright/2
  94. snow[i].posy = 0
  95. }
  96. }
  97.  
  98. var timer = setTimeout(movesnow, 50)
  99. }
  100.  
  101. for(i = 0; i <= snowmax; i++)
  102. document.write("<span id='s"+i+"' style='position:absolute;top:-"+snowmaxsize+"'>"+snowletter[randommaker(snowletter.length)]+"</span>")
  103.  
  104. window.addEventListener("load", initsnow);
  105.  
  106. </script>
  107. <p style="font-family: arial, helvetica; font-size: 8pt">Free JavaScript from<br><a href="http://rainbow.arch.scriptmania.com/scripts/">Rainbow Arch</a></p>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement