1
1
mirror of https://github.com/exyte/Macaw.git synced 2024-09-11 05:05:23 +03:00

Override toPath() for Point.

This commit is contained in:
Eduard Sergeev 2019-03-14 11:45:21 +07:00
parent 6bebe3ba70
commit 90e8c66ced
3 changed files with 5 additions and 7 deletions

View File

@ -2,10 +2,6 @@ import Foundation
extension Locus {
internal func pointToPath(_ point: Point) -> Path {
return MoveTo(x: point.x, y: point.y).lineTo(x: point.x, y: point.y).build()
}
internal func pointsToPath(_ points: [Double], close: Bool = false) -> Path {
var pb = PathBuilder(segment: PathSegment(type: .M, data: [points[0], points[1]]))
if points.count > 2 {

View File

@ -20,9 +20,7 @@ open class Locus {
}
open func toPath() -> Path {
if let point = self as? Point {
return MoveTo(x: point.x, y: point.y).lineTo(x: point.x, y: point.y).build()
} else if let line = self as? Line {
if let line = self as? Line {
return MoveTo(x: line.x1, y: line.y1).lineTo(x: line.x2, y: line.y2).build()
} else if let polygon = self as? Polygon {
return pointsToPath(polygon.points, close: true)

View File

@ -27,4 +27,8 @@ open class Point: Locus {
open func rect(size: Size) -> Rect {
return Rect(point: self, size: size)
}
override open func toPath() -> Path {
return MoveTo(x: x, y: y).lineTo(x: x, y: y).build()
}
}