Reputation: 35
I have path being made by CGMutablePathRef
CGMutablePathRef pointsPathpath = CGPathCreateMutable();
CGPathMoveToPoint(pointsPathpath, NULL, firstPoint.x, firstPoint.y);
CGPathAddLineToPoint(pointsPathpath, NULL, secondPoint.x, secondPoint.y);
CGPathAddLineToPoint(pointsPathpath, NULL, thirdPoint.x, thirdPoint.y);
CGPathAddLineToPoint(pointsPathpath, NULL, fourthPoint.x, fourthPoint.y);
CGPathCloseSubpath(pointsPathpath);
Is there any way to get its boundary points?
Thanks in Advance.
Upvotes: 0
Views: 179
Reputation: 56645
Core Graphics has two method to calculate the "bounding box" of a CGPath.
CGPathGetPathBoundingBox()
CGPathGetBoundingBox()
The first one returns the smallest bounding box that encloses all the points in the path but not including control points for curves.
The second one does include control points for curves.
Your path doesn't have any curves so they will both return the same rectangle but for more advanced paths they generally return different areas.
The below image illustrates their difference. The black lines with circles in the end are the control points for the curves in the path.
Upvotes: 3
Reputation: 10069
You can use either CGPathGetBoundingBox() or CGPathGetPathBoundingBox().
Both of these are listed in the CGPath documentation: http://developer.apple.com/library/ios/#documentation/graphicsimaging/Reference/CGPath/Reference/reference.html
Upvotes: 1