views:

215

answers:

2

I found that there's a clearRect method, but can't find any to clear arc.

  1. Is there're any way to clear object from canvas (arc), if I also have that instance saved somewhere... ?

  2. What method is to clear arc?

+1  A: 

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.

robertc
+1  A: 

There is no clearArc however you can use Compsoite Operations to acheive the same thing

context.globalCompositeOperation = 'destination-out'

According to MDC the effect of this setting is

The existing content is kept where it doesn't overlap the new shape.

https://developer.mozilla.org/en/Canvas_tutorial/Compositing

So any filled shape with this mode on will end up erasing current canvas content.

MooGoo