Update matrix effect

This commit is contained in:
LSvekis
2021-10-04 17:47:51 -04:00
committed by GitHub
parent f33c672d41
commit 1b8454297e
+19 -24
View File
@@ -1,44 +1,39 @@
<!doctype html>
<html>
<head>
<title>Canvas HTML5</title>
</head>
<body>
<div class="output"></div>
<script>
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.setAttribute('width', '600');
canvas.setAttribute('height', '400');
const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
canvas.setAttribute("width", "500");
canvas.setAttribute("height", "300");
document.body.prepend(canvas);
const textPos = Array(60).join(0).split('');
console.log(textPos);
const colVal = [];
for(let x=0;x<50;x++){
colVal.push(0);
}
function matrix() {
let output = '0';
ctx.fillStyle = 'rgba(0,0,0,.05)';
console.log(colVal);
let output = "0";
ctx.fillStyle = "rgba(0,0,0,.05)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = 'green';
textPos.map((posY, index) => {
output = String.fromCharCode(62 + Math.random() * 26);
console.log(output);
ctx.fillStyle = "green";
colVal.map((posY, index) => {
output = Math.random()<0.5?0:1;
let posX = (index * 10) + 10;
ctx.fillText(output, posX, posY);
if (posY > 100 + Math.random() * 1000) {
textPos[index] = 0;
}
else {
textPos[index] = posY + 10;
if (posY > 100 + Math.random() * 300) {
colVal[index] = 0;
} else {
colVal[index] = posY + 10;
}
})
}
setInterval(matrix, 50);
</script>
</body>
</html>