-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatrix.html
48 lines (48 loc) · 1.53 KB
/
matrix.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Matrix</title>
<link rel="icon" href="./img/favicon.png" type="image/x-icon" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<style>
* {margin: 0; padding: 0;}
body {background: #23252E;}
canvas {display: block;}
</style>
</head>
<body bgcolor="#277EE2">
<canvas></canvas>
<script type="text/javascript">
setTimeout(function() {
document.addEventListener('contextmenu', event => event.preventDefault());
var canvas = document.querySelector('canvas'),
ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
var letters = 'ABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZ';
letters = letters.split('');
var fontSize = 10,
columns = canvas.width / fontSize;
var drops = [];
for (var i = 0; i < columns; i++) {
drops[i] = 1;
}
function draw() {
ctx.fillStyle = 'rgba(35, 37, 46, .1)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
for (var i = 0; i < drops.length; i++) {
var text = letters[Math.floor(Math.random() * letters.length)];
ctx.fillStyle = '#277EE2';
ctx.fillText(text, i * fontSize, drops[i] * fontSize);
drops[i]++;
if (drops[i] * fontSize > canvas.height && Math.random() > .95) {
drops[i] = 0;
}
}
}
setInterval(draw, 33);
}, 3000);
</script>
</body>
</html>