@@ -1201,6 +1201,34 @@ class PathTests: XCTestCase {
12011201 XCTAssertTrue ( componentsEqualAsideFromElementOrdering ( resultAlt. components [ 0 ] , expectedResult. components [ 0 ] ) )
12021202 }
12031203
1204+ func testCrossingsRemovedIssue64( ) {
1205+ let outerEllipse : Path = {
1206+ let cgPath = CGPath ( ellipseIn: CGRect ( x: 0 , y: 0 , width: 5 , height: 5 ) , transform: nil )
1207+ return Path ( cgPath: cgPath)
1208+ } ( )
1209+ let innerEllipse : Path = {
1210+ let cgPath = CGPath ( ellipseIn: CGRect ( x: 1 , y: 1 , width: 3 , height: 5 ) , transform: nil )
1211+ return Path ( cgPath: cgPath) . reversed ( )
1212+ } ( )
1213+ // the inner ellipse intersects the outer ellipse at the top
1214+ let shape = Path ( components: outerEllipse. components + innerEllipse. components)
1215+ let result = shape. crossingsRemoved ( )
1216+ XCTAssertEqual ( result. components. count, 2 )
1217+ let point1 = CGPoint ( x: 2.5 , y: 0.5 )
1218+ let point2 = CGPoint ( x: 2.5 , y: 2.5 )
1219+ let point3 = CGPoint ( x: 2.5 , y: 5.5 )
1220+ /// a "U" shape formed by the outer ellipse, minus where the inner ellipse intersects it
1221+ let firstComponent = result. components [ 0 ]
1222+ /// a "bump" shape where the inner ellipse pokes through the outer one
1223+ let secondComponent = result. components [ 1 ]
1224+ XCTAssertTrue ( firstComponent. contains ( point1) )
1225+ XCTAssertFalse ( firstComponent. contains ( point2) )
1226+ XCTAssertFalse ( firstComponent. contains ( point3) )
1227+ XCTAssertFalse ( secondComponent. contains ( point1) )
1228+ XCTAssertFalse ( secondComponent. contains ( point2) )
1229+ XCTAssertTrue ( secondComponent. contains ( point3) )
1230+ }
1231+
12041232 func testCrossingsRemovedNoCrossings( ) {
12051233 // a test which ensures that if a path has no crossings then crossingsRemoved does not modify it
12061234 let square = Path ( cgPath: CGPath ( ellipseIn: CGRect ( x: 0.0 , y: 0.0 , width: 1.0 , height: 1.0 ) , transform: nil ) )
0 commit comments