• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CGContextClip Works with Rect Paths, but not with Arc Paths
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >CGContextClip Works with Rect Paths, but not with Arc Paths (From: "Jordan Evans" <email@hidden>)

  • Prev by Date: Re: First click in custom window?
  • Next by Date: Re: CGContextClip and Passing Graphics Context
  • Previous by thread: CGContextClip Works with Rect Paths, but not with Arc Paths
  • Next by thread: General development tips
  • Index(es):
    • Date
    • Thread