Brijesh's Git Server — matrix @ 1cd5ddb5c0c0f6aeb613225696f4a4371e2c6000

iykyk

script.js (view raw)

 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
const canvas = document.getElementById("canvas");
const context = canvas.getContext("2d");

canvas.width = window.innerWidth;
canvas.height = window.innerHeight;

const texts =
  "1234567890!@#$%^&*()_+[]{};':,.<>?/|~`±§QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm'";

const fontSize = 16;

const columnCount = canvas.width / fontSize;

const yAxisPositions = [];

for (let x = 0; x < columnCount; x++) {
  yAxisPositions[x] = 0;
}

const draw = () => {
  context.fillStyle = "rgba(0,0,0,0.05)";
  context.fillRect(0, 0, canvas.width, canvas.height);
  context.fillStyle = "#0f0";
  context.font = `${fontSize}px monospace`;

  for (let x = 0; x < yAxisPositions.length; x++) {
    const randomCharacter = texts[Math.floor(Math.random() * texts.length)];
    context.fillText(
      randomCharacter,
      x * fontSize,
      yAxisPositions[x] * fontSize,
    );
    if (yAxisPositions[x] * fontSize > canvas.height && Math.random() > 0.975) {
      yAxisPositions[x] = 0;
    }
    yAxisPositions[x]++;
  }
};

setInterval(draw, 100);