-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
34 lines (27 loc) · 845 Bytes
/
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
const canvas = document.getElementById("lienzo")
console.log(canvas);
const ctx = canvas.getContext('2d');
canvas.width = window.screen.width;
canvas.height = window.screen.height;
console.log("height: " + screen.height);
const w = canvas.width;
const h = canvas.height;
ctx.fillStyle = '#000';
ctx.fillRect(0,0,w,h);
const cols = Math.floor(w/20) + 1;
const posicion_y = Array(cols).fill(0);
function matrix(){
ctx.fillStyle = '#0001';
ctx.fillRect(0,0,w,h);
ctx.fillStyle = '#0f0';
ctx.font = '15pt monospace';
posicion_y.forEach((y,ind) => {
const text = String.fromCharCode(Math.random() * 128);
const x = ind * 20;
ctx.fillText(text,x,y);
if(y > 100 + Math.random() * 10000){
posicion_y[ind] =0;
}else posicion_y[ind] = y + 20;
})
}
setInterval(matrix,50);