-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
69 lines (49 loc) · 1.79 KB
/
script.js
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
const fetchSvg = (image) => {
fetch(image.src)
.then((response) => response.text())
.then((response) => {
const span = document.createElement('span');
span.innerHTML = response;
const inlineSvg = span.getElementsByTagName('svg')[0];
image.parentNode.replaceChild(inlineSvg, image);
return true;
})
};
var root = {
wavecolor: {
r: 0,
g: 255,
b: 0
},
font_size: 14,
matrixspeed: 50
};
var c = document.getElementById("matrix");
var ctx = c.getContext("2d");
c.height = window.innerHeight;
c.width = window.innerWidth;
var konkani = "゠アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレワヰヱヲンヺ・ーヽヿ0123456789"
var characters = konkani.split("");
var font_size = root.font_size;
var columns = c.width / font_size;
var gradient = ctx.createLinearGradient(0, 10, 0, 200);
var drops = [];
for (var x = 0; x < columns; x++)
drops[x] = 1;
function draw() {
ctx.fillStyle = "rgba(0,0,0, 0.05)";
ctx.fillRect(0, 0, c.width, c.height);
ctx.fillStyle = "#BBB";
ctx.font = font_size + "px arial";
for (var i = 0; i < drops.length; i++) {
ctx.fillStyle = "rgba(10,10,10, 1)";
ctx.fillRect(i * font_size, drops[i] * font_size, font_size, font_size);
var text = characters[Math.floor(Math.random() * characters.length)];
ctx.fillStyle = 'rgba(' + root.wavecolor.r + ',' + root.wavecolor.g + ',' + root.wavecolor.b + ')';
ctx.fillText(text, i * font_size, drops[i] * font_size);
drops[i]++;
if (drops[i] * font_size > c.height && Math.random() > 0.975)
drops[i] = 0;
}
}
setInterval(draw, root.matrixspeed);