CGContextClip and Passing Graphics Context
CGContextClip and Passing Graphics Context
- Subject: CGContextClip and Passing Graphics Context
- From: "Jordan Evans" <email@hidden>
- Date: Sun, 5 Nov 2006 15:57:52 -0800
I am getting the current graphics context in the drawRect of my view
and passing the context as an argument to objects that have draw
methods.
- (void)drawRect:(NSRect)rect
{
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
[myFullDrawing draw:context];
}
myDrawing instance above has child objects that all have draw methods.
myDrawing then sends the context passed to it's child objects.
- (void)draw:(CGContextRef)context
{
// object draws itself here.
}
Everything works fine, except when I try to clip the context in a
child draw method. In the draw: method above, if I clip the context
with something like the following, everything is clipped as usual:
CGContextBeginPath (context);
CGContextAddRect( rect );
CGContextClosePath (context);
CGContextClip (context);
When I draw outside the rect defined above, it's clipped.
But, when I use a path that is created from lines or arcs, it will not
clip it. All my paths are closed. No lines cross. I don't use
moveToPoint. So, even-odd rule doesn't apply here.
I took the code out of the child object's and put it in the view's
drawRect: method and it did clip as expected!
I'm not sure why this is happening? I'm I restricted from passing a
graphics context to child objects and expecting it to work?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden