<!DOCTYPE html>
<html>
  <body>
    <canvas id="canvas" width="100" height="100"></canvas>
    <script>
  var c = document.getElementById("canvas");
  var ctx = c.getContext("2d");
  ctx.globalCompositeOperation = "copy";
  ctx.fillStyle = "green";
  ctx.fillRect(0, 0, 50, 50);
    </script>
  </body>
</html>