public
Last active

The Matrix Console in JS

  • Download Gist
index.html
HTML
1
<canvas id="q"></canvas>
matrix.css
CSS
1 2 3 4 5 6 7 8 9 10
* {
margin: 0;
padding: 0;
border: 0;
}
 
body {
background: #dff;
font: 30px sans-serif;
}
matrix.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
// forked from skopp's "forked: the-matrix" http://jsdo.it/skopp/vEBP
// forked from teetteet's "forked: the-matrix" http://jsdo.it/teetteet/fiiz
// forked from dongriab's "the-matrix" http://jsdo.it/dongriab/c56Z
 
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(3e4+Math.random()*33);
x_pos = index * 10;
q.getContext('2d').fillText(text, x_pos, y_pos);
letters[index] = (y_pos > 758 + Math.random() * 1e4) ? 0 : y_pos + 10;
});
};
setInterval(draw, 33);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.