簡體   English   中英

如何在 html 5 畫布中刪除區域的剪輯

[英]How to remove the clip of a region in html 5 canvas

我正在畫布中使用clip()

我已經為clip()創建了一個區域,如下所示

this.svgRenderer.ctx.rect(positionX, positionY, Width, Height);
this.svgRenderer.ctx.clip();

在同一畫布上繪制幾次之后,我嘗試使用save()restore()刪除該區域的剪輯。

但我犯了錯誤,無法理解。 所以建議任何其他方法來刪除指定區域的剪輯,而不使用save()restore()

.clip是永久的上下文狀態更改。

它只能通過將其包裝在.save.restore中來刪除。

ctx.save();
ctx.clip(); // assuming the clipping path was already declared
// draw whatever needs to be clipped
ctx.restore(); // reset the clipping region
               // (and any other attributes that have been modified since .save())

更改畫布元素寬度將清除上下文狀態(並刪除剪輯),但也會刪除現有繪圖。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM