JSFiddle - React, Tailwind, and code Playground

by Oscar Handsome

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="assets/css/styles.css" />
    <title>Matrix</title>
  </head>
  <body>
    <div class="container" id="board"></div>
    <script src="assets/js/app.js"></script>
  </body>
</html>

CSS

@font-face {
  font-family: "Matrix";
  src: url("../fonts/matrix.ttf") format("ttf");
}

* {
  box-sizing: border-box;
}

body {
  background-color: #111;
  display: flex;
  height: 100vh;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

.container {
  display: flex;
  flex-grow: 1;
  /* border: solid 1px red; */
}

.column {
  display: flex;
  flex-direction: column;
  /* margin-right: 10px; */
}

.square {
  display: flex;
  justify-content: center;
  align-items: center;

  margin: 0;
  width: 20px;
  height: 20px;
  /* background-color: #1d1d1d; */
  box-shadow: 0 0 2px #000;
  transition: 5s ease;
  /* animation: rotation 2000ms infinite; */
}

.square:hover {
  transition-duration: 0s;
}

@keyframes rotation {
  0% {
    transform: rotateX(0);
  }
  100% {
    transform: rotate(360deg);
  }
}

JavaScript

const board = document.querySelector("#board");
const colors = ["54,186,1", "0,154,34", "0,255,43", "0,154,34", "54,186,1"];

// const SQUARES_NUMBERS = window.innerWidth - 30;
const SQUARES_COLUMNS = Math.floor(window.innerWidth / 20 - 20);
const SQUARES_NUMBERS = Math.floor((window.innerHeight / 20) * 2 - 20);
console.log(window.innerWidth, window.innerHeight);
console.log(SQUARES_COLUMNS, SQUARES_NUMBERS);

/* SET TIMERS */
const RANDOM_SPEED = 200;
const SPPED_FILLING_IDX = 50;
const STOP_TITMER_COLUMNS = 30000;
const HIDE_SPPED_FILLING_IDX = 600;

const randomIdn = Math.floor(Math.random * SQUARES_COLUMNS.length);
let filledColumns = [];

const INFINITE = true;

for (let idxCol = 0; idxCol < SQUARES_COLUMNS; idxCol++) {
  const column = document.createElement("div");
  column.classList.add("column");
  board.append(column);

  for (let iSq = 0; iSq < SQUARES_NUMBERS; iSq++) {
    const square = document.createElement("div");
    square.classList.add("square");
    column.append(square);
  }
}

function removeСharacter(element) {
  element.style.opacity = 0;
  setInterval(() => {
    element.remove();
  }, 200);
}

function randomChar() {
  let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  return possible.charAt(Math.floor(Math.random() * possible.length));
}

// HELPERS
function getRandomArbitrary(min, max) {
  return Math.random() * (max - min) + min;
}

function getRandomColor() {
  return colors[Math.floor(Math.random() * colors.length)];
}

function runFillingCollumn(columIdx) {
  const column = document.querySelectorAll(".column")[columIdx];
  const color = `rgba(${getRandomColor()}, 1)`;
  setСharacter(column, color);
}

function setСharacter(column, color) {
  let counter = 0;
  let randomSpeed = getRandomArbitrary(
    SPPED_FILLING_IDX,
    SPPED_FILLING_IDX * 2
  );
  let randomFontSize = getRandomArbitrary(8, 16);

  let timerIdChar = setInterval(() => {
    element = column.querySelectorAll(".square")[counter];
    const...