Skip to content

Commit

Permalink
Merge pull request #19 from hfutrell/0.1.12-release
Browse files Browse the repository at this point in the history
fixed critical logic error in CrossingsRemoved and added unit test as…
  • Loading branch information
hfutrell authored Sep 21, 2018
2 parents 27a8111 + 982aedd commit ccaa27e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion BezierKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Pod::Spec.new do |s|
s.name = "BezierKit"
s.version = "0.1.11"
s.version = "0.1.12"
s.summary = "comprehensive Bezier curve library written in Swift"
s.homepage = "https://github.com/hfutrell/BezierKit"
s.license = "MIT"
Expand Down
9 changes: 9 additions & 0 deletions BezierKit/BezierKitTests/PathTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ class PathTests: XCTestCase {
CGPoint(x: 1, y: 1),
CGPoint(x: 2, y: 1),
CGPoint(x: 0, y: 3),
CGPoint(x: 0, y: 0)
]
let cgPath = CGMutablePath()
cgPath.addLines(between: points)
Expand All @@ -437,6 +438,14 @@ class PathTests: XCTestCase {
XCTAssertEqual(result.subpaths.count, 1)
XCTAssertTrue(componentsEqualAsideFromElementOrdering(result.subpaths[0], expectedResult.subpaths[0]))

// check also that the algorithm works when the first point falls *inside* the path
let cgPathAlt = CGMutablePath()
cgPathAlt.addLines(between: Array(points[3..<points.count]) + Array(points[1...3]))
let pathAlt = Path(cgPath: cgPathAlt)

let resultAlt = pathAlt.crossingsRemoved()
XCTAssertEqual(resultAlt.subpaths.count, 1)
XCTAssertTrue(componentsEqualAsideFromElementOrdering(resultAlt.subpaths[0], expectedResult.subpaths[0]))
}

func testCrossingsRemovedNoCrossings() {
Expand Down
6 changes: 4 additions & 2 deletions BezierKit/Library/AugmentedGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,16 @@ internal class PathLinkedListRepresentation {
// determine the initial winding count (winding count before first vertex)
var initialWinding = 0
if useRelativeWinding {
var minimumWinding = Int.max
self.forEachVertexInComponent(atIndex: i) { v in
guard v.isIntersection else {
return
}
if v.intersectionInfo.nextWinding < -initialWinding {
initialWinding = v.intersectionInfo.nextWinding
if v.intersectionInfo.nextWinding < minimumWinding {
minimumWinding = v.intersectionInfo.nextWinding
}
}
initialWinding = -minimumWinding
}
else {
initialWinding = path.windingCount(lists[i][0].emitPrevious().compute(0.5))
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ To integrate BezierKit into your Xcode project using CocoaPods, add it to your t

```ruby
target '<Your Target Name>' do
pod 'BezierKit', '>= 0.1.11'
pod 'BezierKit', '>= 0.1.12'
end
```

Expand Down

0 comments on commit ccaa27e

Please sign in to comment.