JSFiddle - React, Tailwind, and code Playground

HTML

<canvas></canvas>

JavaScript

var ctx = document.querySelector('canvas').getContext('2d');

ctx.fillStyle = 'red';

ctx.fillRect(10, 10, 70, 70);

ctx.globalCompositeOperation = 'source-out';

ctx.fillStyle = 'green';

ctx.fillRect(5, 5, 170, 170);