-
Notifications
You must be signed in to change notification settings - Fork 0
/
matrix.html
54 lines (52 loc) · 1.73 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
49
50
51
52
53
54
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Matrix Rain - html/css/javascript</title>
</head>
<style>
*{
margin: 0%;
padding: 0%;
overflow: hidden;
}
</style>
<body>
<canvas id="canvas" style="background: #111;"></canvas>
<script>
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
var W = window.innerWidth;
var H = window.innerHeight;
canvas.width = W;
canvas.height = H;
var fontSize = 16;
var columns = Math.floor(W / fontSize);
var drops = [];
for(var i=0; i<columns; i++){
drops.push(0);
}
var str = "a b c d e f g h i j k l n m o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 ! @ # $ % & ( ) - _ = + \ ; : * / ∾ Ↄ ∌ ∀ ⨉ ⨙ ⨢ ⨨/⨈ ৻ ₦ ₭ $ ¤ ¥ ₳ £ ₱ ɐ Σ Ω × ⁂ ⁐ ♪ ∖ ௹";
function draw(){
context.fillStyle = "rgba(0,0,0,0.05)";
context.fillRect(0, 0, W, H);
context.fontSize = "700" + fontSize + "px";
context.fillStyle = "#00cc33";
for(var i=0; i<columns; i++){
var index = Math.floor(Math.random()*str.length);
var x = i * fontSize;
var y = drops[i] * fontSize;
context.fillText(str[index], x, y);
if(y >= canvas.height && Math.random() > 0.99){
drops[i] = 0;
}
drops[i]++;
}
}
draw();
setInterval(draw, 35);
</script>
</body>
</html>