Closed prasad1120 closed 4 years ago
That'd odd, it should be giving you two shapes if i'm understanding correctly. the green portion inside the black box and the smaller triangle green portion outside the box. Can you reply with the contents of each path? if you print description
of them in the Xcode console debugger, then it'll print out an obj-c representation of the path. that'll help me track down specifics of what might be going on.
print(splitterPath.debugDescription)
path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(19.000000, 26.870058)];
[path addLineToPoint:CGPointMake(201.000000, 26.870058)];
[path addLineToPoint:CGPointMake(201.000000, 121.000000)];
[path addLineToPoint:CGPointMake(19.000000, 121.000000)];
[path closePath];
print(splittingPath.debugDescription)
path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(19.000000, 39.000000)];
[path addCurveToPoint:CGPointMake(19.000000, 39.000000) controlPoint1:CGPointMake(19.000000, 39.000000) controlPoint2:CGPointMake(19.000000, 39.000000)];
[path addLineToPoint:CGPointMake(19.000000, 19.000000)];
[path addLineToPoint:CGPointMake(19.000000, 121.000000)];
[path addCurveToPoint:CGPointMake(19.000000, 121.000000) controlPoint1:CGPointMake(19.000000, 121.000000) controlPoint2:CGPointMake(19.000000, 121.000000)];
[path addLineToPoint:CGPointMake(201.000000, 121.000000)];
[path addLineToPoint:CGPointMake(201.000000, 121.000000)];
[path addCurveToPoint:CGPointMake(201.000000, 121.000000) controlPoint1:CGPointMake(201.000000, 121.000000) controlPoint2:CGPointMake(201.000000, 121.000000)];
[path addLineToPoint:CGPointMake(201.000000, 39.000000)];
[path addLineToPoint:CGPointMake(201.000000, 39.000000)];
[path addCurveToPoint:CGPointMake(201.000000, 39.000000) controlPoint1:CGPointMake(201.000000, 39.000000) controlPoint2:CGPointMake(201.000000, 39.000000)];
[path addLineToPoint:CGPointMake(220.000000, 39.000000)];
[path addLineToPoint:CGPointMake(220.000000, 39.000000)];
[path addCurveToPoint:CGPointMake(206.564971, 33.435029) controlPoint1:CGPointMake(214.960887, 39.000000) controlPoint2:CGPointMake(210.128162, 36.998220)];
[path addLineToPoint:CGPointMake(200.000000, 26.870058)];
[path addLineToPoint:CGPointMake(195.778175, 31.091883)];
[path addLineToPoint:CGPointMake(195.778175, 31.091883)];
[path addCurveToPoint:CGPointMake(176.686292, 39.000000) controlPoint1:CGPointMake(190.714692, 36.155365) controlPoint2:CGPointMake(183.847137, 39.000000)];
[path addLineToPoint:CGPointMake(19.000000, 39.000000)];
ah, the issue is that splittingPath needs to b a closedPath. It does end at the same point it starts at, but needs to have an explicit closePath
element. splittingPath.close()
should do the trick
I was the under the impression that returning back to the starting point is same as .close()
. Two values are getting returned after closing the path now. Thanks a lot!
Glad that sorted it! :)
Hi Adam,
I am trying to split a path with another path like so:
However,
uniqueShapesCreatedFromSlicing
returns an empty array. I was hoping for a green shape to be returned without the extraneous part outside the black box(splitterPath).Please let me know if I am missing something and how to get the desired result.