I'm currently drawing an angular gradient using a method similar to the one shown by Rob's answer here. I have added an extension to CGContext to draw an angular gradient and would like it to handle the clipping path, so that callers can treat it similar to a method like fillPath(using:)
.
I have tried using func pathContains(CGPoint, mode: CGPathDrawingMode)
on CGContext and func contains(CGPoint, using: CGPathFillRule, transform: CGAffineTransform)
on the CGPath returned from the context.
Both of these appear to not use the clipping path, so my drawing goes outside the clipping area.
Is there a way to get either the path clipped already or a copy of the current clipping path so I can also check whether the pixel is contained inside that path also?