到目前为止,我得到了这个:http: //jsfiddle.net/Lt7VN/
但是它会剪切/剪切红色和黑色的矩形,而我希望它只剪切黑色的矩形,我该怎么做呢?
context.beginPath();
context.rect(20,20,160,200);
context.fillStyle = "red";
context.fill();
context.beginPath();
context.rect(20,20,150,100);
context.fillStyle = "black";
context.fill();
context.globalCompositeOperation = "destination-out";
context.beginPath();
context.arc(100, 100, 50, 0, 2*Math.PI);
context.fill();