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

后端 未结 6 2032
谎友^
谎友^ 2021-02-04 02:06

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?

6条回答
  •  情深已故
    2021-02-04 02:38

    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

提交回复
热议问题