Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Using a Path for Hit Testing

In Mac OS X v10.4 and later, you can use the function CGPathContainsPoint to find out if a point is inside a closed path. A direct replacement for PtInRgn, this function is useful when you have a corresponding path for each shape being tested. Here’s the prototype:

bool CGPathContainsPoint (CGPathRef path, const CGAffineTransform *m,
                            CGPoint point, bool eoFill);

CGPathContainsPoint returns true if the point is inside the area that’s painted when the path is filled using the specified fill rule. You can also specify a transform that’s applied to the point before the test is performed. (Assuming the point is in local view coordinates and the path uses the same coordinate space, a transform is probably not needed.)



< Previous PageNext Page > Hide TOC


Last updated: 2006-09-05




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice