JSFiddle - React, Tailwind, and code Playground

HTML

<canvas id="canvas" height="600" width="800"></canvas>

JavaScript

var ctx = canvas.getContext("2d");
var cornerpad = 0;
var rectwidth = 790;
var rectheight = 590;

function drawrectangles() {
    ctx.beginPath();
    ctx.rect(cornerpad, cornerpad, rectwidth, rectheight);
    ctx.fillStyle = 'hsl(' + 360 * Math.random() + ', 50%, 50%)'
    ctx.stroke()
    ctx.fill();    
}   

while(rectheight > 5) {
    rectheight -= 10;
    rectwidth -= 10;
    cornerpad+=10;
    drawrectangles();
}