mirror of
https://github.com/byReqz/matrix-bg.git
synced 2025-08-03 14:22:41 +00:00
Add files via upload
This commit is contained in:
47
js/index.js
Normal file
47
js/index.js
Normal file
@@ -0,0 +1,47 @@
|
||||
window.addEventListener('load', eventWindowLoaded, false);
|
||||
|
||||
function eventWindowLoaded () {
|
||||
canvasApp();
|
||||
}
|
||||
function canvasSupport (e) {
|
||||
|
||||
return !!e.getContext;
|
||||
|
||||
}
|
||||
function canvasApp () {
|
||||
var canvas = document.getElementById('myCanvas');
|
||||
|
||||
if (!canvasSupport(myCanvas)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var ctx = canvas.getContext('2d');
|
||||
var w = canvas.width = window.innerWidth;
|
||||
var h = canvas.height = window.innerHeight;
|
||||
var yPositions = Array(300).join(0).split('');
|
||||
|
||||
function runMatrix() {
|
||||
if (typeof Game_Interval != 'undefined') clearInterval(Game_interval);
|
||||
Game_Interval = setInterval(drawScreen, 33);
|
||||
}
|
||||
|
||||
function drawScreen () {
|
||||
ctx.fillStyle = 'rgba(0,0,0,.05)';
|
||||
ctx.fillRect(0, 0, w, h);
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.font = '10px Nasalization';
|
||||
yPositions.map(function(y, index){
|
||||
text = String.fromCharCode(1e2 + Math.random() * 33);
|
||||
x = (index * 10) + 10;
|
||||
ctx.fillText(text, x, y);
|
||||
if (y > 100 + Math.random() * 1e4) {
|
||||
yPositions[index] = 0;
|
||||
} else {
|
||||
yPositions[index] = y + 10;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
runMatrix();
|
||||
|
||||
}
|
Reference in New Issue
Block a user