I want to use javascript to shade in specific parts of canvas drawings on click. Here is my code below that draws a square inside a circle.
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<canvas width="300" height="300" id="myCanvas" style="border:1px solid #000000;"></canvas>
<script>
const canvas = document.getElementById('myCanvas');
const context = canvas.getContext('2d');
const centerX = canvas.width / 2;
const centerY = canvas.height / 2;
const radius = 70;
context.beginPath();
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
context.rect(centerX-25, centerY-25, 50, 50)
context.lineWidth = 5;
context.strokeStyle = '#003300';
context.stroke();
</script>
</body>
</html>
And after clicking on the area outside the square but still inside the circle, I want to just shade that part in and have something like this: