Skip to content

Commit 6e6fd0c

Browse files
committed
fix a crash in the demos.
1 parent 9ba7e9e commit 6e6fd0c

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

BezierKit/Library/BezierCurve.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,12 +461,27 @@ extension BezierCurve {
461461
}
462462
alen = alen + slen
463463
}
464-
464+
465+
func cleanupCurves(_ curves: inout [BezierCurve]) {
466+
// ensures the curves are contiguous
467+
for i in 0..<curves.count {
468+
if i > 0 {
469+
curves[i].startingPoint = curves[i-1].endingPoint
470+
}
471+
if i < curves.count-1 {
472+
curves[i].endingPoint = 0.5 * ( curves[i].endingPoint + curves[i+1].startingPoint )
473+
}
474+
}
475+
}
476+
477+
cleanupCurves(&fcurves)
478+
cleanupCurves(&bcurves)
479+
465480
// reverse the "return" outline
466481
bcurves = bcurves.map({(s: BezierCurve) in
467482
return s.reversed()
468483
}).reversed()
469-
484+
470485
// form the endcaps as lines
471486
let fs = fcurves[0].points[0]
472487
let fe = fcurves[len-1].points[fcurves[len-1].points.count-1]

0 commit comments

Comments
 (0)