Say I have a circle (an arc) on HTML5 canvas. I can just fill it like this:
ctx.arc(100, 100, 50, 0, 2 * Math.PI);
ctx.fill();
It works a treat. However, how can one fill the opposite area? Now it’s white with a black circle, but I’d like it to be along the lines of the following image (on which white is the background color and black is the filling color):

I know I could just use a black background and paint a white circle, but the background can be anything (all kinds of things have been drawn there before, so just swapping colors is not possible).
Another thing is that not the complete canvas should be filled, but rather a square with an circle canceled out.
I was thinking of a globalCompositeOperation but it does not seem to fit my needs as none of them act according to what I need.
So, how can I accomplish filling the ‘opposite’ area like in the example image?
You can do that using another canvas as mask :
Demo here.