【发布时间】:2021-12-23 10:12:27
【问题描述】:
所以我的目标很简单……我想。我想画一个中间有一个洞的矩形。但我不希望那个洞穿过画布上的任何其他东西。 现在我有这样的东西:
context.fillStyle = 'blue';
context.fillRect(0, 0, width, height);
context.fillStyle = "#000000";
context.beginPath();
context.rect(0, 0 , width, height);
context.fill();
enter code here
context.globalCompositeOperation="destination-out";
context.beginPath();
context.arc(width / 2, height / 2 , 80, 0, 50);
context.fill();
但这也切穿了背景,我怎样才能让它只切穿黑色矩形而没有别的呢?
视觉示例,以防我解释得不好:
【问题讨论】: