Skip to content

Commit

Permalink
fix a crash in the demos.
Browse files Browse the repository at this point in the history
  • Loading branch information
hfutrell committed Mar 18, 2019
1 parent 9ba7e9e commit 6e6fd0c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions BezierKit/Library/BezierCurve.swift
Original file line number Diff line number Diff line change
Expand Up @@ -461,12 +461,27 @@ extension BezierCurve {
}
alen = alen + slen
}


func cleanupCurves(_ curves: inout [BezierCurve]) {
// ensures the curves are contiguous
for i in 0..<curves.count {
if i > 0 {
curves[i].startingPoint = curves[i-1].endingPoint
}
if i < curves.count-1 {
curves[i].endingPoint = 0.5 * ( curves[i].endingPoint + curves[i+1].startingPoint )
}
}
}

cleanupCurves(&fcurves)
cleanupCurves(&bcurves)

// reverse the "return" outline
bcurves = bcurves.map({(s: BezierCurve) in
return s.reversed()
}).reversed()

// form the endcaps as lines
let fs = fcurves[0].points[0]
let fe = fcurves[len-1].points[fcurves[len-1].points.count-1]
Expand Down

0 comments on commit 6e6fd0c

Please sign in to comment.