JSFiddle - React, Tailwind, and code Playground

by totoromaum

HTML

<!DOCTYPE html>
<html>

  <head>
    <title>Canvas</title>
  </head>

  <body>
    <canvas id="canvas" width="200" height="200"></canvas>
    <script>
      var canvas = document.getElementById("canvas");
      var ctx = canvas.getContext("2d");
      var position = 0;
      setInterval(function() {
        ctx.clearRect(0, 0, 200, 200);
        ctx.fillRect(position, 0, 20, 20);
        position++;

        if (position > 200) {
          position = 0;
        }

      }, 30);

    </script>

  </body>

</html>