Skip to content

Instantly share code, notes, and snippets.

@jsfeng
Created May 20, 2013 20:25
Show Gist options
  • Save jsfeng/5615214 to your computer and use it in GitHub Desktop.
Save jsfeng/5615214 to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<html>
<head>
<title> Canvas Test</title>
</head>
<body>
<canvas id="canvas">
<script>
canvas.height = window.screen.height;
canvas.width = window.screen.width;
var columns = []
var character =0;
for (i = 0; i < 256; columns[i++] = 1);
function step() {
canvas.getContext('2d').fillStyle = 'rgba(0,0,0,0.05)';
canvas.getContext('2d').fillRect(0, 0, canvas.width, canvas.height);
canvas.getContext('2d').fillStyle = '#0F0';
columns.map(function (value, index) {
canvas.getContext('2d').fillText(character, //text
index * 10, //x
value //y
);
if(character==0)
character=1;
else
character=0;
columns[index] = value > 758 + Math.random() * 1e4 ? 0 : value + 10
})
}
setInterval(step, 33)
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment