> I see a couple of minor issues with this:
> 
> 1. I don't think it's necessary or desirable to save/restore the graphics 
> state around the drawRect: behavior, because I believe that's done for you 
> around the drawRect: invocation itself. You'd only need it if you had other 
> non-clipped drawing to do after drawing your annotations.

That's correct. I have some additional (debug) drawing code after (that I din't 
include in the posting) and needed to restore the full clipping path for this. 
I should have probably deleted the NSGraphicsContext calls when posting the 
code here. 

> 
> 2. Instead of this:
> 
>       [clipPath appendBezierPathWithRect:nodeRect];
> 
> I actually meant this:
> 
>       [clipPath appendBezierPathWithRect: NSIntersectionRect (drawRect, 
> nodeRect)];
> 
> Otherwise the compound shape isn't what you want it to be. However, the two 
> versions are probably equivalent in this context, because everything's 
> clipped to drawRect anyway.

I see why this makes sense, but I don't think it's necessary, since anything 
that would have been outside the drawRect would be removed when doing the 
addClip call (since we make an intersection with an existing clipping path that 
is at most drawRect size). It doesn't hurt though if it's included, it might 
even make things easier for NSBezierPath. 

> 
> 3. Since your 2.0-point strokes are drawn centered on the nodeRect path, only 
> the interior half of the strokes get protected by the clipping changes. The 
> effect may or may not be what you want, and may or may not be visible, 
> depending on the alpha values of the various colors involved.
> 
> One solution is to draw the strokes *inside* the nodeRect (by creating an 
> inset bezier path specifically for stroking, for example). Or, expand your 
> clipping protection to include the stroke:
> 
>       [clipPath appendBezierPathWithRect: NSIntersectionRect (drawRect, 
> NSInsetRect (nodeRect, -1.0, -1.0))]; // 1.0 == strokeWidth / 2

Thanks for pointing this out. I would have noticed this sooner or later. At 
least I hope so. :)

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to