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();

        /*
         * leave center point positioned
         * at the default which is the top left
         * corner of the rectangle
         */
        var blueRect = new Kinetic.Rect({
          x: 50,
          y: 75,
          width: 100,
          height: 50,
          fill: '#00D2FF',
          stroke: 'black',
          strokeWidth: 4
        });

        /*
         * move center point to the center
         * of the rectangle with offset
         */
        var yellowRect = new Kinetic.Rect({
          x: 220,
          y: 75,
          width: 100,
          height: 50,
          fill: 'yellow',
          stroke: 'black',
          strokeWidth: 4,
          offset: [50, 25]
        });

        /*
         * move center point outside of the rectangle
         * with offset
         */
        var redRect = new Kinetic.Rect({
          x: 400,
          y: 75,
          width: 100,
          height: 50,
          fill: 'red',
          stroke: 'black',
          strokeWidth: 4,
          offset: [-100, 0]
        });

        layer.add(blueRect);
        layer.add(yellowRect);
        layer.add(redRect);
        stage.add(layer);

        // one revolution per 4 seconds
        var angularSpeed = Math.PI / 2;
        var anim = new Kinetic.Animation({
          func: function(frame) {
            var angleDiff = frame.timeDiff * angularSpeed / 1000;
            blueRect.rotate(angleDiff);
            yellowRect.rotate(angleDiff);
            redRect.rotate(angleDiff);
   ...