如何在HTML 5 canvas中删除区域的片段 [英] How to remove the clip of a region in html 5 canvas
问题描述
我正在画布中使用 clip()
.
我已经为 clip()
设置了一个区域,如下所示
I have made a region to clip()
, as specified below
this.svgRenderer.ctx.rect(positionX, positionY, Width, Height);
this.svgRenderer.ctx.clip();
在同一画布上绘制几张图之后,我试图通过使用 save()
和 restore()
删除该区域的剪辑.
After few drawing on the same canvas, I am trying to remove the clip for that region by using save()
and restore()
.
但是我犯了错误,无法理解.因此,建议使用其他任何方法删除指定区域的剪辑,而无需使用 save()
和 restore()
But I am making mistakes and can't get that.
So suggest any other way to remove the clip for the specified region without using save()
and restore()
推荐答案
.clip
是永久的上下文状态更改.
.clip
is a permanent context state change.
只能通过将其包装在 .save
和 .restore
中来删除.
It can only be removed by wrapping it in .save
and .restore
.
更改画布元素的宽度将清除上下文状态(并删除裁剪),但也会擦除现有图形.
Changing the canvas element width will clear the context state (and remove clipping) but will also erase the existing drawings.
这篇关于如何在HTML 5 canvas中删除区域的片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!