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

Re: NSBezierPath


  • Subject: Re: NSBezierPath
  • From: Scott Thompson <email@hidden>
  • Date: Mon, 27 Jun 2005 09:02:39 -0500


On Jun 27, 2005, at 8:47 AM, Eric Brunstad wrote:

Hi everyone,

Looking through the NSBezierPath docs, I see it is possible to find if a path contains a point. However, I need to find if a NSBezierPath contains a rect.

How should I do this?

Note: I'm looking to see if the actual path contains a rect, not just the path's bounds.

That is, in general, a "hard problem". There are several ways you could create trivial rejects:


If the paths's bounds and the rectangle' don't intersect then reject
If the path's control polygon and the rectangle don't intersect then reject.
If the four corners of the rectangle do not lie within the path, then reject.



At that point you'd be pretty confident that the rectangle intersects the path (though you still can't say for sure). At that point you'd either have to use numerical methods to determine if the path crosses the edge of the rectangle at any point, or not.


The above assumes you want to find out if a rectangle is in a path in the resolution independent space they are defined in. If you are working at a fixed resolution... it's probably easiest to either flatten the path, and see if the rectangle lies inside of the resulting polygon, or intersect the two shapes as bitmaps and see if all of the pixels in the rectangle intersect pixels of the path.

Scott
_______________________________________________
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: 
 >NSBezierPath (From: Eric Brunstad <email@hidden>)

  • Prev by Date: Key View Loop does not work
  • Next by Date: Re: Is return value of -readDataOfLength: autoreleased?
  • Previous by thread: NSBezierPath
  • Next by thread: Key View Loop does not work
  • Index(es):
    • Date
    • Thread