JSFiddle - React, Tailwind, and code Playground

by suri_295

HTML

<!DOCTYPE HTML>
<html>
  <head>
    <style>
      body {
        margin: 0px;
        padding: 0px;
      }
      canvas {
        border: 1px solid #9C9898;
      }
    </style>
    <script src="http://www.html5canvastutorials.com/libraries/kinetic-v4.0.0.js"></script>
    <script>
      window.onload = function() {
        var stage = new Kinetic.Stage({
          container: 'container',
          width: 578,
          height: 200
        });
        var layer = new Kinetic.Layer();

        var hexagon = new Kinetic.RegularPolygon({
          x: stage.getWidth() / 2,
          y: stage.getHeight() / 2,
          sides: 6,
          radius: 70,
          fill: 'red',
          stroke: 'black',
          strokeWidth: 4
        });

        layer.add(hexagon);
        stage.add(layer);

        var amplitude = 150;
        var period = 2000;
        // in ms
        var centerX = stage.getWidth() / 2;

        var anim = new Kinetic.Animation({
          func: function(frame) {
            hexagon.setX(amplitude * Math.sin(frame.time * 2 * Math.PI / period) + centerX);
          },
          node: layer
        });

        anim.start();
      };

    </script>
  </head>
  <body>
    <div id="container"></div>
  </body>
</html>