黑客帝国
<body>
<canvas id="c"></canvas>
<script>
var canvas = document.getElementById("c");
var ctx = canvas.getContext("2d");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
var str = "abcdefghi";
var lie = window.innerWidth/20;
var posY = [];
for(var x = 0; x<lie; x++){
posY[x] = 0;
}
console.log(posY)
console.log(lie)
function loop(){
ctx.fillStyle = "rgba(0,0,0,0.05)";
ctx.fillRect(0,0,canvas.width,canvas.height);
for(var i = 0; i<lie ;i++){
ctx.font = "20px 微软雅黑";
ctx.fillStyle = "green";
ctx.fillText(str.charAt(Math.floor(Math.random()*str.length)),i*20,posY[i]*20);
posY[i]++;
if(posY[i]*20>window.innerHeight){
if(Math.random()>0.9){
posY[i] = 0;
}
}
}
}
setInterval(loop,20);
</script>
</body>
效果图