标签:
codeRain.html
1 <html> 2 <head> 3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 4 <title>The world is a matrix</title> 5 <style type="text/css"> 6 body 7 { 8 background-color:#000000; 9 overflow:hidden; 10 margin:0; 11 } 12 </style> 13 </head> 14 <body> 15 <canvas id="q"></canvas> 16 <script> 17 var s = window.screen; 18 var width = q.width = s.width; 19 var height = q.height = s.height; 20 var letters = Array(256).join(1).split(‘‘); 21 var draw = function () { 22 q.getContext(‘2d‘).fillStyle=‘rgba(0,0,0,0.05)‘; 23 q.getContext(‘2d‘).fillRect(0,0,width,height); 24 q.getContext(‘2d‘).fillStyle=‘#00FF00‘; 25 letters.map(function(y_pos, index){ 26 text = String.fromCharCode(34+Math.random()*33); 27 x_pos = index * 10; 28 q.getContext(‘2d‘).fillText(text, x_pos, y_pos); 29 letters[index] = (y_pos > 758 + Math.random() * 1e4) ? 0 : y_pos + 10; 30 q.getContext(‘2d‘).fillStyle=‘#00FF00‘; 31 }); 32 }; 33 setInterval(draw, 33); 34 </script> 35 </body> 36 </html>
标签:
原文地址:http://www.cnblogs.com/cangqiongbingchen/p/4570316.html