<div class="wrapper">
  <canvas id="canvas"></canvas>
</div>
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
}

.wrapper {
  width: 100%;
  height: 100%;
}

canvas {
  image-rendering: pixelated;
}
const canvas = document.getElementById("canvas");
const outputContainer = document.getElementsByClassName("wrapper")[0];
const ctx = canvas.getContext("2d");

canvas.width = outputContainer.offsetWidth;
canvas.height = outputContainer.offsetHeight;

const colors = ["#048243", "#32BF84", "#CAFFFB"];
const pixelSize = 8;
const animationInterval = 200;
let timer = 0;

animate();

function animate(time) {
  for (let y = 0; y < canvas.height; y += pixelSize) {
    for (let x = 0; x < canvas.width; x += pixelSize) {
      ctx.fillStyle = colors[randomNum(0, colors.length - 1)];
      ctx.fillRect(x, y, pixelSize, pixelSize);
    }
  }

  setTimeout(() => requestAnimationFrame(animate), animationInterval);
}

function randomNum(min, max) {
  return Math.floor(Math.random() * (max - min + 1) + min);
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.