Re: CGContextClip Works with Rect Paths, but not with Arc Paths
Re: CGContextClip Works with Rect Paths, but not with Arc Paths
- Subject: Re: CGContextClip Works with Rect Paths, but not with Arc Paths
- From: David Duncan <email@hidden>
- Date: Tue, 7 Nov 2006 17:04:43 -0800
On Nov 5, 2006, at 2:25 PM, Jordan Evans wrote:
When I use the the exerpt code below with CGContextAddRect commented
in and I draw outside that rect, the drawing is clipped as I expect.
But, it is not clipped when I comment in the CGContextAddArc. Anyone
know what is going on?
CGContextBeginPath (context);
// CGContextAddRect(context, CGRectMake(0,0,100,100));
CGContextAddArc( context, 0, 0, 200, 0.0, 3.14, NO);
CGContextClosePath (context);
CGContextEOClip (context);
I added your clipping code to a test harness that I have, and it
seems to work fine for me -- the view drawing code is:
CGContextRef currentContext = (CGContextRef)[[NSGraphicsContext
currentContext] graphicsPort];
CGContextBeginPath(currentContext);
//CGContextAddRect(currentContext, CGRectMake(0,0,100,100));
CGContextAddArc(currentContext, 0, 0, 200, 0.0, 3.14, NO);
CGContextClosePath(currentContext);
CGContextEOClip(currentContext);
CGContextSetRGBFillColor( currentContext, 0.5, 0.0, 0.0, 1.0 );
CGContextSetRGBStrokeColor( currentContext, 0.0, 1.0, 0.0, 1.0 );
CGContextSetLineWidth( currentContext, 5.0 );
CGContextFillRect( currentContext, CGRectMake( rect.origin.x,
rect.origin.y, rect.size.width, rect.size.height ) );
CGContextStrokeRect( currentContext, CGRectMake( rect.origin.x,
rect.origin.y, rect.size.width, rect.size.height ) );
Which results in a red wedge with green outline along the left and
bottom sides. I do notice that your arc has twice the size of your
rect however, so perhaps this is why your not seeing the clipping
your expecting?
--
David Duncan
Apple DTS Quartz and Printing
email@hidden
_______________________________________________
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