当前位置:   article > 正文

黑客帝国代码雨_黑客代码复制粘贴

黑客代码复制粘贴

黑客帝国代码雨


  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>NumberRain</title>
  6. <style type="text/css">
  7. canvas{
  8. display: block;
  9. }
  10. </style>
  11. </head>
  12. <body>
  13. <canvas id="canvas"></canvas>
  14. <script>
  15. function $(id){
  16. return document.getElementById(id);
  17. }
  18. var mywindow=window.screen;
  19. var canvas=$("canvas");
  20. canvas.width=mywindow.width;
  21. canvas.height=mywindow.height;
  22. var str="0123456789abcdefghijklmnopqrstuvwxyz~!@#$%^&*()-+{}|:<>?,.";
  23. str=str.split("");
  24. var fontSize=16;
  25. var cols=canvas.width/fontSize;
  26. var drops=[];
  27. for(var i=0;i<cols;i++){
  28. drops[i]=1;
  29. }
  30. var ctx=canvas.getContext("2d");
  31. function draw(){
  32. ctx.fillStyle="rgba(0,0,0,0.05)";
  33. ctx.fillRect(0,0,canvas.width,canvas.height);
  34. ctx.fillStyle="green";
  35. ctx.font=fontSize+"px arial";
  36. for(var i=0;i<cols;i++){
  37. var text=str[ Math.floor( Math.random() * (str.length) ) ];
  38. ctx.fillText(text,i*fontSize,drops[i]*fontSize);
  39. if(drops[i]*fontSize > canvas.height || Math.random() > 0.95)
  40. drops[i] = 0;
  41. drops[i]++;
  42. }
  43. }
  44. setInterval(draw,33);
  45. </script>
  46. </body>
  47. </html>

结果如下所示:


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/723014
推荐阅读
相关标签