• 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
CGContextClip and Passing Graphics Context
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: CGContextClip and Passing Graphics Context
      • From: David Duncan <email@hidden>
  • Prev by Date: Re: Indicate loading while bindings read from Core Data
  • Next by Date: Re: General development tips
  • Previous by thread: Re: General development tips
  • Next by thread: Re: CGContextClip and Passing Graphics Context
  • Index(es):
    • Date
    • Thread