<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<canvas id="canvas" width="800" height="600"></canvas>
</body>
<script type="text/javascript">
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
context.fillStyle = "lightgreen";
context.fillRect(0, 0, canvas.width, canvas.height);
context.beginPath();
context.fillRect(100, 100, 200, 100);
context.clip();
context.closePath();
context.fillStyle = "lightblue";
context.fillRect(0, 0, canvas.width, canvas.height);
</script>
</html>
context.beginPath();
context.rect(100, 100, 200, 100);
context.clip();