-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
89 lines (73 loc) · 1.73 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>The GG's Website</title>
<style type="text/css">
canvas {display: block;}
html
{
background:black;
margin:0px;
padding:0px;
border:0px;
height:100%;
width:100%;
overflow:hidden;
}
</style>
</head>
<body>
<canvas id="c">
<script type="text/javascript">
window.onload=function()
{
var c = document.getElementById("c");
var ctx = c.getContext("2d");
c.addEventListener('click', function(e)
{
}, false);
//全屏显示
c.height = window.innerHeight;
c.width = window.innerWidth;
var txts = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
txts = txts.split("");
var font_size = 28;
var columns = c.width/font_size;
//每行要输出数组
var drops = [];
for(var x = 0; x < columns; x++)
drops[x] = 1;
//字符随机颜色
var wh_color = new Array();
wh_color[0]="#57CE13";
wh_color[1]="#50BF7F";
wh_color[2]="#50BF7F";
//绘出字符
function draw()
{
//黑色背景,半透明显示
ctx.fillStyle = "rgba(0, 0, 0, 0.09)";
ctx.fillRect(0, 0, c.width, c.height);
//ctx.fillStyle = "#50BF7F";
ctx.fillStyle = wh_color[parseInt(Math.random()*100+1)%3];
ctx.font = font_size + "px arial";
//drops循环
for(var i = 0; i < drops.length; i++)
{
//随机打印字符
var text = txts[Math.floor(Math.random()*txts.length)];
//x = i*font_size
//y = value of drops[i]*font_size
ctx.fillText(text, i*font_size, drops[i]*font_size);
if(drops[i]*font_size > c.height || Math.random() > 0.95)
drops[i] = 0;
//Y坐标增加
drops[i]++;
}
}
setInterval(draw, 50);
}
</script>
</body>
</html>