JSFiddle - React, Tailwind, and code Playground
HTML
<canvas id="myCanvas" width="500" height="500"></canvas>
JavaScript
var canvas = document.getElementById("myCanvas");
var ctx2 = canvas.getContext("2d");
ctx2.fillStyle='#333';
ctx2.fillRect(20,20,100,100);
var ctx = canvas.getContext("2d");
ctx.fillStyle='red';
var deg = Math.PI/180;
ctx.save();
ctx.translate(70, 70);
ctx.rotate(45 * deg);
ctx.fillRect(-50,-50,100,100);
ctx.restore();