royvanempel

JS

Jun 4th, 2019
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var c = document.getElementById('c');
  2. var cxt = c.getContext("2d");
  3.  
  4.  
  5.  
  6.  
  7. c.width = window.innerWidth;
  8. c.height = window.innerHeight;
  9.  
  10.  
  11.  
  12. var chinese = "田由甲申甴电甶男甸甹町画甼甽甾甿畀畁畂畃畄畅畆畇畈畉畊畋界畍畎畏畐畑";
  13. chinese = chinese.split("");
  14.  
  15. var font_size =10;
  16. var columns = c.width/font_size;
  17.  
  18. var drops = [];
  19.  
  20. for(var x=0;x<columns;x++){
  21.   drops[x]=1;
  22. }
  23.  
  24. function draw(){
  25.   cxt.fillStyle="rgba(0,0,0,0.05)";
  26.   cxt.fillRect(0,0,c.width,c.height);
  27.  
  28.   cxt.fillStyle = "#005200";
  29.   cxt.font = font_size+'px arial';
  30.  
  31.  
  32.   for(var i=0;i<drops.length;i++){
  33.     var text = chinese[Math.floor(Math.random()*chinese.length)];
  34.     cxt.fillText(text,i*font_size,drops[i]*font_size);
  35.  
  36.     if(drops[i]*font_size>c.height && Math.random() >0.975)
  37.       drops[i]=0;
  38.  
  39.     //increment y coordinate
  40.     drops[i]++;
  41.  
  42.     }
  43.  
  44. }
  45. setInterval(draw,33);
Add Comment
Please, Sign In to add comment