JSFiddle - React, Tailwind, and code Playground
HTML
<canvas height="500" width="500" id="canvas"></canvas>
CSS
canvas{border:solid 1px black;}
JavaScript
var context=document.getElementById("canvas").getContext("2d");
//Red Box
context.beginPath();
context.fillStyle="Red";
context.rect(10,10,50,50);
context.fill();
//Blue Box
context.beginPath();
context.fillStyle="Blue";
context.rect(70,10,50,50);
context.fill();
//Black Box
context.beginPath();
context.fillStyle="Orange";
context.rect(70,70,50,50);
context.fill();
//Green Box
context.beginPath();
context.fillStyle="Green";
context.rect(10,70,50,50);
context.fill();
//Green Box
context.beginPath();
context.lineWidth="3";
context.fillStyle="Pink";
context.arc(250,250,50,0,Math.PI*2,false);
context.fill();
context.stroke();
context.font="1.2em Verdana";
context.fillStyle="Black";
context.fillText(context.isPointInPath(35,35),35,35);
context.fillText(context.isPointInPath(95,35),95,35);
context.fillText(context.isPointInPath(95,95),95,95);
context.fillText(context.isPointInPath(35,95),35,95);
context.fillText(context.isPointInPath(250,250),250,250);