閒來沒事兒做,找了段黑客帝國中的數字矩陣代碼。與大家分享一下……
這不是我寫的哦……
代碼:
<body> | |
<canvas id="q"></canvas> | |
<script type="text/javascript"> | |
var s = window.screen; | |
var width = q.width = s.width; | |
var height = q.height = s.height; | |
var letters = Array(256).join(1).split(""); | |
var draw = function () { | |
q.getContext('2d').fillStyle='rgba(0,0,0,.05)'; | |
q.getContext('2d').fillRect(0,0,width,height); | |
q.getContext('2d').fillStyle='#0F0'; | |
letters.map(function(y_pos, index){ | |
text = String.fromCharCode(48+Math.round(Math.random())); | |
x_pos = index * 10; | |
q.getContext('2d').font='bold 12px san-serif'; | |
q.getContext('2d').fillText(text, x_pos, y_pos); | |
letters[index] = (y_pos > 758 + Math.random() * 1e4) ? 0 : y_pos + 10; | |
}); | |
}; | |
setInterval(draw, 35); | |
</script> | |
</body> |