daily pastebin goal
50%
SHARE
TWEET

Snow Effect for HTML

Berandal666 Mar 29th, 2017 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.  
  3. // Berandal | OWL SQUAD
  4. var snowmax=35
  5. var snowcolor=new Array("#F3F3F3","#F0FFFF")
  6. var snowtype=new Array("Comic Sans MS")
  7. var snowletter="*"
  8. var sinkspeed=0.6
  9. var snowmaxsize=22
  10. var snowminsize=8
  11. var snowingzone=1
  12.  
  13. // Dibawah ini gausah diedit !! //
  14. var snow=new Array()
  15. var marginbottom
  16. var marginright
  17. var timer
  18. var i_snow=0
  19. var x_mv=new Array();
  20. var crds=new Array();
  21. var lftrght=new Array();
  22. var browserinfos=navigator.userAgent
  23. var ie5=document.all&&document.getElementById&&!browserinfos.match(/Opera/)
  24. var ns6=document.getElementById&&!document.all
  25. var opera=browserinfos.match(/Opera/)  
  26. var browserok=ie5||ns6||opera
  27.  
  28. function randommaker(range) {      
  29.     rand=Math.floor(range*Math.random())
  30.     return rand
  31. }
  32.  
  33. function initsnow() {
  34.     if (ie5 || opera) {
  35.         marginbottom = document.body.clientHeight
  36.         marginright = document.body.clientWidth
  37.     }
  38.     else if (ns6) {
  39.         marginbottom = window.innerHeight
  40.         marginright = window.innerWidth
  41.     }
  42.     var snowsizerange=snowmaxsize-snowminsize
  43.     for (i=0;i<=snowmax;i++) {
  44.         crds[i] = 0;                      
  45.         lftrght[i] = Math.random()*15;        
  46.         x_mv[i] = 0.03 + Math.random()/10;
  47.         snow[i]=document.getElementById("s"+i)
  48.         snow[i].style.fontFamily=snowtype[randommaker(snowtype.length)]
  49.         snow[i].size=randommaker(snowsizerange)+snowminsize
  50.         snow[i].style.fontSize=snow[i].size
  51.         snow[i].style.color=snowcolor[randommaker(snowcolor.length)]
  52.         snow[i].sink=sinkspeed*snow[i].size/5
  53.         if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size)}
  54.         if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size)}
  55.         if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4}
  56.         if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2}
  57.         snow[i].posy=randommaker(2*marginbottom-marginbottom-2*snow[i].size)
  58.         snow[i].style.left=snow[i].posx
  59.         snow[i].style.top=snow[i].posy
  60.     }
  61.     movesnow()
  62. }
  63.  
  64. function movesnow() {
  65.     for (i=0;i<=snowmax;i++) {
  66.         crds[i] += x_mv[i];
  67.         snow[i].posy+=snow[i].sink
  68.         snow[i].style.left=snow[i].posx+lftrght[i]*Math.sin(crds[i]);
  69.         snow[i].style.top=snow[i].posy
  70.        
  71.         if (snow[i].posy>=marginbottom-2*snow[i].size || parseInt(snow[i].style.left)>(marginright-3*lftrght[i])){
  72.             if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size)}
  73.             if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size)}
  74.             if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4}
  75.             if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2}
  76.             snow[i].posy=0
  77.         }
  78.     }
  79.     var timer=setTimeout("movesnow()",1)
  80. }
  81.  
  82. for (i=0;i<=snowmax;i++) {
  83.     document.write("<span id='s"+i+"' style='position:absolute;top:-"+snowmaxsize+"'>"+snowletter+"</span>")
  84. }
  85. if (browserok) {
  86.     window.onload=initsnow
  87. }
  88. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top