-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
58 lines (47 loc) · 1.56 KB
/
Copy pathindex.html
File metadata and controls
58 lines (47 loc) · 1.56 KB
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
<html>
<div class="background" style="position: absolute; z-index:-1; left:0; top:0; ">
<canvas width="max-width" height="max-height" id="canv" />
</div>
<script type="text/javascript">
// Initialising the canvas
var canvas = document.querySelector('canvas'),
ctx = canvas.getContext('2d');
// Setting the width and height of the canvas
//canvas.width = window.innerWidth;
//canvas.height = window.innerHeight;
canvas.width = screen.width;
let scrollHeight = Math.max(
document.body.scrollHeight, document.documentElement.scrollHeight,
document.body.offsetHeight, document.documentElement.offsetHeight,
document.body.clientHeight, document.documentElement.clientHeight
);
canvas.height = screen.height;
// Setting up the letters
var letters = 'ABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZ123456789!@#$%^&*()?{}[]';
letters = letters.split('');
// Setting up the columns
var fontSize = 15,
columns = canvas.width / fontSize;
// Setting up the drops
var drops = [];
for (var i = 0; i < columns; i++) {
drops[i] = 1;
}
// Setting up the draw function
function draw() {
ctx.fillStyle = 'rgba(0, 0, 0, .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 = '#0f0';
ctx.fillText(text, i * fontSize, drops[i] * fontSize);
drops[i]++;
if (drops[i] * fontSize > canvas.height && Math.random() > .95) {
drops[i] = 0;
}
}
}
// Loop the animation
setInterval(draw, 60);
</script>
</html>