JSFiddle - React, Tailwind, and code Playground

HTML

<script src="http://mokgames.com/pixi-experiments/pixi.js"></script>

JavaScript

var stage = new PIXI.Stage(0xFFFFFF, true);
stage.setInteractive(true);
var renderer = PIXI.autoDetectRenderer(600, 600);
/*
if (confirm("Full screen?")) {
   renderer.view.style.width = window.innerHeight + "px";
   renderer.view.style.height = window.innerHeight + "px";
}
*/
   renderer.view.style.display = "block";
document.body.appendChild(renderer.view);


// draw a square
var square = new PIXI.Graphics();
square.lineStyle(0, 0xFF0000, 1);
square.beginFill(0xFF0000, 1);
square.drawRect(50, 50, 400, 400);
stage.addChild(square);


// draw a circle
var circle = new PIXI.Graphics();
circle.lineStyle(0);
circle.beginFill(0x3399FF, 1);
circle.drawCircle(250, 250, 200);
stage.addChild(circle);


// draw a diamond (a square rotated to stand on one corner).
var diamond = new PIXI.Graphics();
diamond.lineStyle(0, 0xFFFF66, 0.5);
diamond.beginFill(0xFFFF66, 0.5);
diamond.drawRect(109, 109, 283, 283);
    // This defines the center.
diamond.position.x = 250;
diamond.position.y = 250;
    // This says to pivot around the center.
diamond.pivot = new PIXI.Point(250, 250);
    // This rotates the square 45 degrees, so that it becomes a diamond standing on its point.
diamond.rotation = 62.05;
stage.addChild(diamond);


var count = 0;
requestAnimFrame(animate);


function animate() {
   diamond.rotation += 0.05;
   var width = diamond.width / diamond.scale.x;
   var height = diamond.height / diamond.scale.y;
   var sin   = Math.sin(diamond.rotation),
       cos   = Math.cos(diamond.rotation);

    var x1 = cos * width,
        y1 = sin * width;

    var x2 = -sin * height,
        y2 = cos * height;

    var x3 = cos * width - sin * height,
        y3 = sin * width + cos * height;

    var minX = Math.min(0, x1, x2, x3),
        maxX = Math.max(0, x1, x2, x3),
        minY = Math.min(0, y1, y2, y3),
        maxY = Math.max(0, y1, y2, y3);

    var rotatedWidth  = maxX - minX,
        rotatedHeight = maxY - minY;
   
    diamond.scale.x = square.width/rotatedWidth;
   ...