Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if a set of coordinates are contained within a shape [duplicate]

Possible Duplicate:
Detect if CGPoint within polygon

I have the coordinates of a set of touches from a UIEvent. Is there a way to check if they are contained within a certain shape -- a polygon -- that I can define?

I have experience in Java, and I would use the polygon class and call the contains(int x, int y) method. Is there a similar way to do this in Cocoa Touch?

like image 413
user1941895 Avatar asked Jan 02 '13 04:01

user1941895


1 Answers

If you define your polygon as a CGPath, you can use CGPathContainsPoint()... Can you tell us more about your application concept?

EDIT:

There's also the higher-level UIBezierPath and/or NSBezierPath.. both of those objects have a -containsPoint method.

like image 170
nielsbot Avatar answered Sep 29 '22 16:09

nielsbot