Alex Ivasyuv Alex Ivasyuv - 1 year ago 146
Javascript Question

How can I clear an arc or circle in HTML5 canvas?

I found that there's a

method, but can't find any to clear an arc (or a full circle).

Is there any way to clear an arc in canvas?

Answer Source

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.

Edit: MooGoo has given a much better answer below

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download