JSFiddle - React, Tailwind, and code Playground

HTML

<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="40" height="40" style="border:1px solid black;">
Your browser does not support the HTML5 canvas tag.</canvas>

<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
// Clip a rectangular area
ctx.rect(2, 2, 10, 10);
ctx.clip();
// Draw red rectangle after clip()
ctx.fillStyle = "red";
ctx.fillRect(0, 0, 8, 8);

</script> 


<canvas id="myCanvas2" width="40" height="40" style="border:1px solid black;">
Your browser does not support the HTML5 canvas tag.</canvas>

<script>
var c = document.getElementById("myCanvas2");
var ctx = c.getContext("2d");
ctx.translate(0.5, 0.5);
// Clip a rectangular area
ctx.rect(2, 2, 10, 10);
ctx.clip();
// Draw red rectangle after clip()
ctx.fillStyle = "red";
ctx.fillRect(0, 0, 8.5, 8.5);

</script> 

</body>
</html>