-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
67 lines (57 loc) · 1.83 KB
/
index.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
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Happy 21th birthday, Summer!</title>
<body>
<canvas id="c"></canvas>
<style type="text/css">canvas {display: block;}</style>
<script type="text/javascript">
var c = document.getElementById("c");
var ctx = c.getContext("2d");
//fullscreen
var font_size = 32;
c.height = window.innerHeight-font_size;
c.width = window.innerWidth-font_size;
//charset
var txts = "#0123456789&matrix^neo|".split("");
var signature = "by Tangyao".split("");
var title = "Happy 21th birthday, Summer! ".split("");
var columns = c.width/font_size;
//char pos in each column
var drops = [];
//init
for(var x = 0; x < columns; x++)
drops[x] = 1;
//drop words
function draw()
{
//background
ctx.fillStyle = "rgba(0, 0, 0, 0.05)";
ctx.fillRect(0, 0, c.width, c.height);
//matrix green
ctx.fillStyle = "#0F0";
ctx.font = font_size + "px arial";
//each column
for(var i = 0; i < drops.length; i++)
{
//random char
// var text = txts[Math.floor(Math.random()*txts.length)];
var text = title[i%title.length];
//fill char to bottom of each column
ctx.fillText(text, i*font_size, drops[i]*font_size);
//full screen or cut
if((drops[i]*font_size > c.height || Math.random() > 0.95) && drops[i] > 1)
drops[i] = 0;
drops[i]++;
}
for(var i = 0; i < signature.length; i++)
{
if(Math.random() > 0.95)
ctx.fillText(signature[i], (i+1)*font_size, c.height-font_size);
}
}
setInterval(draw, 50);
</script>
</body>
</html>