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:
commit
906357b965
@ -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 {
|
||||
|
@ -781,6 +781,9 @@ open class SVGParser {
|
||||
}
|
||||
}
|
||||
|
||||
if resultPoints.count % 2 == 1 {
|
||||
resultPoints.removeLast()
|
||||
}
|
||||
return resultPoints
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user