Given:
- a CGContextRef (
ctx
) with frame{0,0,100,100}
- and a rect (
r
), with frame{25,25,50,50}
It's easy to clip the context to that rect:
CGContextClipToRect(ctx, r);
to mask out the red area below (red == mask):
But I want to invert this clipping rect to convert it into a clipping mask. The desired outcome is to mask the red portion below (red == mask):
I want to do this programmatically at runtime.
I do not want to manually prepare a bitmap image to ship statically with my app.
Given ctx
and r
, how can this be done at runtime most easily/straightforwardly?