Javascript / jQuery:从canvas中删除shape / path [英] Javascript/jQuery: remove shape/path from canvas
问题描述
我无法在画布创建后找到删除形状或路径的函数。
I can't seem to find the function to remove a shape or path from the canvas after it has been created.
所以我创建了一个贝塞尔曲线在2分之间与
So I'm creating a bezier curve between 2 points with
beginPath();
bezierCurveTo();
stroke();
closePath();
。如何在创建后将其从画布中删除?我需要能够通过toggle()和blur()调用remove函数。我确定这里有东西存在...
. How can I remove this from the canvas once it's been created? I need to be able to call the remove function via toggle() and blur(). I'm sure something exists for this...
先感谢任何帮助!
推荐答案
感谢您对我们的大力支持 - 帮助我找到了解决方案:
Thanks for the great input to all of you - it helped me find the solution:
context.clearRect(x,y,w,h);
( link )
这将清除该矩形内的任何内容。
This will clear anything within that rectangle.
我在找到ILog的回答保存/恢复上下文时发现的页面上的方法,它都在那里。再次感谢。
I found the method on the page I found while digging for ILog's answer to save/restore the context, and it's all on there. Thanks again.
这篇关于Javascript / jQuery:从canvas中删除shape / path的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!