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