All graphic outside the shape will not be dispayed.
ctx.fillStyle = "blue";
ctx.beginPath();
ctx.rect(40, 40, 360, 220);
ctx.fill();
ctx.clip();
ctx.strokeStyle = "#000000";
ctx.lineWidth = 5;
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(400, 300);
ctx.stroke();