The_snowfall

adds falling snowflakes to the page

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/513921/1470984/The_snowfall.js

  1. // Add this script before </body> tag,
  2. // its must be pasted in the last pair of tags <script></script>
  3.  
  4. // CREDITS:
  5. // Snowmaker
  6. // By Peter Gehrig
  7. // Copyright (c) 2003 Peter Gehrig. All rights reserved.
  8. // Permission given to use the script provided that this notice remains as is.
  9. // Additional scripts can be found at http://www.24fun.com
  10. // info@24fun.com
  11. // 11/27/2003
  12.  
  13. // IMPORTANT:
  14. // If you add this script to a script-library or script-archive
  15. // you have to add a highly visible link to
  16. // http://www.24fun.com on the webpage
  17. // where this script will be featured
  18.  
  19. ///////////////////////////////////////////////////////////////////////////
  20. // CONFIGURATION STARTS HERE
  21. ///////////////////////////////////////////////////////////////////////////
  22.  
  23. // Set the number of snowflakes (more than 30 - 40 not recommended)
  24. var snowmax=35;
  25.  
  26. // Set the colors for the snow. Add as many colors as you like
  27. var snowcolor=new Array("#aaaacc","#ddddFF","#ccccDD");
  28.  
  29. // Set the fonts, that create the snowflakes. Add as many fonts as you like
  30. var snowtype=new Array("Arial Black","Arial Narrow","Times","Comic Sans MS");
  31.  
  32. // Set the letter that creates your snowflake (recommended:*)
  33. var snowletter="*";
  34.  
  35. // Set the speed of sinking (recommended values range from 0.3 to 2)
  36. var sinkspeed=0.6;
  37.  
  38. // Set the maximal-size of your snowflaxes
  39. var snowmaxsize=22;
  40.  
  41. // Set the minimal-size of your snowflaxes
  42. var snowminsize=13;
  43.  
  44. // Set the snowing-zone
  45. // Set 1 for all-over-snowing, set 2 for left-side-snowing
  46. // Set 3 for center-snowing, set 4 for right-side-snowing
  47. var snowingzone=1;
  48.  
  49. ///////////////////////////////////////////////////////////////////////////
  50. // CONFIGURATION ENDS HERE
  51. ///////////////////////////////////////////////////////////////////////////
  52.  
  53.  
  54. // Do not edit below this line
  55. var snow=new Array();
  56. var marginbottom;
  57. var marginright;
  58. var timer;
  59. var i_snow=0;
  60. var x_mv=new Array();
  61. var crds=new Array();
  62. var lftrght=new Array();
  63. var browserinfos=navigator.userAgent;
  64. var ie5=document.all&&document.getElementById&&!browserinfos.match(/Opera/);
  65. var ns6=document.getElementById&&!document.all;
  66. var opera=browserinfos.match(/Opera/);
  67. var browserok=ie5||ns6||opera;
  68.  
  69. function randommaker(range) {
  70. rand=Math.floor(range*Math.random());
  71. return rand;
  72. }
  73.  
  74. function initsnow() {
  75. if (ie5 || opera) {
  76. marginbottom = document.body.clientHeight;
  77. marginright = document.body.clientWidth;
  78. }
  79. else if (ns6) {
  80. marginbottom = window.innerHeight;
  81. marginright = window.innerWidth;
  82. }
  83. var snowsizerange=snowmaxsize-snowminsize;
  84. for (i=0;i<=snowmax;i++) {
  85. crds[i] = 0;
  86. lftrght[i] = Math.random()*15;
  87. x_mv[i] = 0.03 + Math.random()/10;
  88. snow[i]=document.getElementById("s"+i);
  89. snow[i].style.fontFamily=snowtype[randommaker(snowtype.length)];
  90. snow[i].size=randommaker(snowsizerange)+snowminsize;
  91. snow[i].style.fontSize=snow[i].size;
  92. snow[i].style.color=snowcolor[randommaker(snowcolor.length)];
  93. snow[i].sink=sinkspeed*snow[i].size/5;
  94. if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size);}
  95. if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size);}
  96. if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4;}
  97. if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2;}
  98. snow[i].posy=randommaker(2*marginbottom-marginbottom-2*snow[i].size);
  99. snow[i].style.left=snow[i].posx;
  100. snow[i].style.top=snow[i].posy;
  101. }
  102. movesnow();
  103. }
  104.  
  105. function movesnow() {
  106. for (i=0;i<=snowmax;i++) {
  107. crds[i] += x_mv[i];
  108. snow[i].posy+=snow[i].sink;
  109. snow[i].style.left=snow[i].posx+lftrght[i]*Math.sin(crds[i]);
  110. snow[i].style.top=snow[i].posy;
  111. if (snow[i].posy>=marginbottom-2*snow[i].size || parseInt(snow[i].style.left)>(marginright-3*lftrght[i])){
  112. if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size);}
  113. if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size);}
  114. if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4;}
  115. if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2;}
  116. snow[i].posy=0;
  117. }
  118. }
  119. var timer=setTimeout("movesnow()",50);
  120. }
  121.  
  122. for (i=0;i<=snowmax;i++) {
  123. document.write("<span id='s"+i+"' style='position:absolute;top:-"+snowmaxsize+"'>"+snowletter+"</span>");
  124. }
  125. if (browserok) {
  126. window.onload=initsnow;
  127. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址