JSFiddle - React, Tailwind, and code Playground
by writen
HTML
<canvas id="myGame" width="350" height="350">
</canvas>
JavaScript
var c = document.getElementById("myGame");
var ctx = c.getContext("2d");
ctx.fillStyle = "#FF0000";
var width = c.width;
var height = c.height;
function draw() {
ctx.clearRect(0, 0, c.width, c.height);
ctx.translate(width/2-40, height/2-40);
ctx.rotate(Math.PI / 180);
ctx.translate(-width/2+40, -height/2+40);
ctx.fillRect(width/4, height/4, width/2-80, height/2-80);
window.requestAnimationFrame(draw);
}
window.requestAnimationFrame(draw);