如何在HTML5画布中清除圆弧或圆? [英] How can I clear an arc or circle in HTML5 canvas?

查看:602
本文介绍了如何在HTML5画布中清除圆弧或圆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现有一个 clearRect()方法,但找不到任何清除弧(或一个完整的圆)。

I found that there's a clearRect() method, but can't find any to clear an arc (or a full circle).

有没有办法在画布上清除一个弧?

Is there any way to clear an arc in canvas?

推荐答案

在画布上绘制的东西没有要清除的对象,只是您绘制的像素。 clearRect 方法不会清除先前绘制的对象,它只是清除由参数定义的空间中的像素。如果你知道一个包含它的矩形,你可以使用 clearRect 方法来清除弧。这当然会清除区域中的任何其他像素,因此您必须重新绘制它们。

Nope, once you've drawn something on a canvas there is no object to clear, just the pixels you've drawn. The clearRect method doesn't clear a previously drawn object, it just clears the pixels in the space defined by the parameters. You can use the clearRect method to clear the arc if you know a rectangle which contains it. This will of course clear any other pixels in the area, so you'll have to redraw them.

编辑: MooGoo在下面给出了更好的答案

这篇关于如何在HTML5画布中清除圆弧或圆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆