This may help someone ... You need to pass the boundary points of the form below the method and return the correct region of the polygon
static double areaOfCurveWithPoints(const NSArray *shapeEdgePoints) { CGPoint initialPoint = [shapeEdgePoints.firstObject CGPointValue]; CGMutablePathRef cgPath = CGPathCreateMutable(); CGPathMoveToPoint(cgPath, &CGAffineTransformIdentity, initialPoint.x, initialPoint.y); for (int i = 1;i<shapeEdgePoints.count ;i++) { CGPoint point = [[shapeEdgePoints objectAtIndex:i] CGPointValue]; CGPathAddLineToPoint(cgPath, &CGAffineTransformIdentity, point.x, point.y); } CGPathCloseSubpath(cgPath); CGRect frame = integralFrameForPath(cgPath); size_t bytesPerRow = bytesPerRowForWidth(frame.size.width); CGContextRef gc = createBitmapContextWithFrame(frame, bytesPerRow); CGContextSetFillColorWithColor(gc, [UIColor whiteColor].CGColor); CGContextAddPath(gc, cgPath); CGContextFillPath(gc); double area = areaFilledInBitmapContext(gc); CGPathRelease(cgPath); CGContextRelease(gc); return area; } static CGRect integralFrameForPath(CGPathRef path) { CGRect frame = CGPathGetBoundingBox(path); return CGRectIntegral(frame); } static size_t bytesPerRowForWidth(CGFloat width) { static const size_t kFactor = 64;
iOS_Binod
source share