How to check UIBezierPath
is closed path or not (closed path is like closed contour means it creates any shape like triangle, square, polygon etc), and if it is closed then only fill in the path?
The following represents the area where it should fill in the shape; last 2 shape defining closed contour and simple closed contour which in only color can be filled:
The following is my code for the same, There are 4 Squares in it but fills in only 3 squares; also want to know is it possible to find the area of filled area in square feet as I get 4 squares here how to check the total area it covered in 4 squares?
UIBezierPath *mainPath =[UIBezierPath bezierPath];
[mainPath moveToPoint:CGPointMake(50, 100)];
[mainPath addLineToPoint:CGPointMake(0, 100)];
[mainPath addLineToPoint:CGPointMake(0, 150)];
[mainPath addLineToPoint:CGPointMake(50, 150)];
[mainPath addLineToPoint:CGPointMake(50, 200)];
[mainPath addLineToPoint:CGPointMake(100, 200)];
[mainPath addLineToPoint:CGPointMake(100, 150)];
[mainPath addLineToPoint:CGPointMake(50, 150)];
[mainPath addLineToPoint:CGPointMake(50, 100)];
[mainPath addLineToPoint:CGPointMake(100, 100)];
[mainPath addLineToPoint:CGPointMake(150, 100)];
[mainPath addLineToPoint:CGPointMake(150, 150)];
[mainPath addLineToPoint:CGPointMake(100, 150)];
[mainPath addLineToPoint:CGPointMake(100, 100)];
CAShapeLayer *shapeLayer = [[CAShapeLayer alloc] init];
shapeLayer.lineWidth = 5.0;
shapeLayer.strokeColor = [UIColor blueColor].CGColor;
shapeLayer.path =mainPath.CGPath;
shapeLayer.fillColor = [[UIColor redColor] colorWithAlphaComponent:0.5].CGColor;
[[self.view layer] addSublayer:shapeLayer];