• 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: Erasing drawn content
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Erasing drawn content


  • Subject: Re: Erasing drawn content
  • From: Matej Bukovinski <email@hidden>
  • Date: Wed, 9 Jun 2010 23:30:38 +0200

> 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 (email@hidden)

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:

This email sent to email@hidden

References: 
 >Re: Erasing drawn content (From: "Paul Sanders" <email@hidden>)
 >Re: Erasing drawn content (From: Matej Bukovinski <email@hidden>)
 >Re: Erasing drawn content (From: Quincey Morris <email@hidden>)
 >Re: Erasing drawn content (From: Matej Bukovinski <email@hidden>)
 >Re: Erasing drawn content (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Erasing drawn content
  • Next by Date: Re: Question about scaling text within a subView
  • Previous by thread: Re: Erasing drawn content
  • Next by thread: Re: Erasing drawn content
  • Index(es):
    • Date
    • Thread