Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
Hi,
I can look elsewhere for C code,
but I'm wondering if iOS has a way to check inside a path used to
draw polygons with Quartz2d.

I have saved all of the screen coordinates in the path,
so I can do something with them after the polygon is drawn to screen.
Cheers, Art.
 
Last edited:
Assuming you have a Path, see the documentation for CGPathContainsPoint.

Awesome! 5 minutes to get it working. Don't even have to save coordinates
that make up the polygon, just check it before you fill the path:
Code:
    CGContextAddLineToPoint(context, sscreenx, sscreeny);
    
    if (isnp == 1) {
    bool shapeContainsPoint = CGContextPathContainsPoint(context, cPoint, kCGPathFillStroke );
    if (shapeContainsPoint == TRUE) {inboundsnp = 1;}
    } // isnp
        
    CGContextFillPath(context);

Sure beats virtually drawing the polygon again just to hit test it, Thanks :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.