1
1
mirror of https://github.com/exyte/Macaw.git synced 2024-10-05 16:57:12 +03:00

Merge pull request #360 from f3dm76/task/polygonPointsCount

Fix crash when polygon points count is odd
This commit is contained in:
Yuri Strot 2018-05-16 14:47:11 +07:00 committed by GitHub
commit 906357b965
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -161,7 +161,8 @@ class RenderUtils {
}
fileprivate class func pointsToPath(_ points: [Double]) -> MBezierPath {
let parts = stride(from: 0, to: points.count, by: 2).map { Array(points[$0 ..< $0 + 2]) }
let count = points.count / 2 * 2 // points count divisible by 2
let parts = stride(from: 0, to: count, by: 2).map { Array(points[$0 ..< $0 + 2]) }
let path = MBezierPath()
var first = true
for part in parts {

View File

@ -781,6 +781,9 @@ open class SVGParser {
}
}
if resultPoints.count % 2 == 1 {
resultPoints.removeLast()
}
return resultPoints
}