• 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: Quincey Morris <email@hidden>
  • Date: Wed, 9 Jun 2010 11:55:54 -0700

On Jun 9, 2010, at 11:06, Matej Bukovinski wrote:

> The clipping path approach doesn't really help. It turns out that you can only intersect the current clipping path (initially the view's bounds) with a new path and the intersected region is the region where drawing is visible. This means that when you're drawing a larger rectangle over a smaller one, you would need to set the clipping path to all areas NOT covered by the smaller rectangle. This is basically the same problem as calculating which parts of the larger rectangle to draw and just drawing there.

I think you can do it, but it just takes an extra step. For each overlay (front to back):

1. Intersect the rect for the current overlay with the "drawRect" (i.e. the rect passed to drawRect:) producing the effective "tintRect".

1a. If tintRect is empty, nothing to draw, so skip 2-4.

2. Fill the tint rect with the appropriate color.

3. Construct a new bezier compound-path object with one path from drawRect (+[NSBezierPath bezierPathWithRect:]), plus a path from the tintRect (-[NSBezierPath appendBezierPathWithRect:]). That essentially "inverts" the tintRect within drawRect. Set the even-odd winding rule on the path, so that you don't have to be concerned about subpath directions (although I believe creating a compound path in the order I described will give correct results with non-zero winding rule, too).

4. Intersect this compound path with the current clipping path (-[NSBezierPath addClip]).

Repeat for each overlay rect.


_______________________________________________

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

  • Follow-Ups:
    • Re: Erasing drawn content
      • From: Matej Bukovinski <email@hidden>
References: 
 >Re: Erasing drawn content (From: "Paul Sanders" <email@hidden>)
 >Re: Erasing drawn content (From: Matej Bukovinski <email@hidden>)

  • Prev by Date: Re: Erasing drawn content
  • Next by Date: Re: Erasing drawn content
  • Previous by thread: Re: Erasing drawn content
  • Next by thread: Re: Erasing drawn content
  • Index(es):
    • Date
    • Thread