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

无人久伴 提交于 2021-02-07 05:34:27

问题


I am working with clip() in canvas.

I have made a region to clip(), as specified below

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

After few drawing on the same canvas, I am trying to remove the clip for that region by using save() and 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()


回答1:


.clip is a permanent context state change.

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.



来源:https://stackoverflow.com/questions/25282793/how-to-remove-the-clip-of-a-region-in-html-5-canvas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!