Question

I am drawing a rounded image in the centre of my custom view by creating a rounded NSBezierPath and adding it to the clipping region of the graphics context. This is working well, but I'm wondering if I can improve the performance of drawing the background of the view (the area outside of the rounded centred image) but inverting this clip and performing the background draw (an NSGradient fill).

Can anyone suggest a method of inverting a clip path?

Was it helpful?

Solution

You won't improve the drawing performance of the background by doing this. If anything, using a more complex clipping path will slow down drawing.

If you want to draw objects over a background without significant overhead of redrawing the background, you could use Core Animation layers as I explained in my answer to this question.

OTHER TIPS

Regardless of performance, this question comes first when you try to invert clip.

So if that's what you're looking for: Using NSBezierPath addClip - How to invert clip

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top