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

Override toPath() for Circle.

This commit is contained in:
Eduard Sergeev 2019-03-14 11:38:47 +07:00
parent 6758c3bbe0
commit 65b658dd39
3 changed files with 5 additions and 7 deletions

View File

@ -21,4 +21,8 @@ open class Circle: Locus {
open func arc(shift: Double, extent: Double) -> Arc {
return Arc(ellipse: Ellipse(cx: cx, cy: cy, rx: r, ry: r), shift: shift, extent: extent)
}
override open func toPath() -> Path {
return MoveTo(x: cx, y: cy).m(-r, 0).a(r, r, 0.0, true, false, r * 2.0, 0.0).a(r, r, 0.0, true, false, -(r * 2.0), 0.0).build()
}
}

View File

@ -2,10 +2,6 @@ import Foundation
extension Locus {
internal func circleToPath(_ circle: Circle) -> Path {
return MoveTo(x: circle.cx, y: circle.cy).m(-circle.r, 0).a(circle.r, circle.r, 0.0, true, false, circle.r * 2.0, 0.0).a(circle.r, circle.r, 0.0, true, false, -(circle.r * 2.0), 0.0).build()
}
internal func arcToPath(_ arc: Arc) -> Path {
let rx = arc.ellipse.rx
let ry = arc.ellipse.ry

View File

@ -20,9 +20,7 @@ open class Locus {
}
open func toPath() -> Path {
if let circle = self as? Circle {
return circleToPath(circle)
} else if let arc = self as? Arc {
if let arc = self as? Arc {
return arcToPath(arc)
} else if let point = self as? Point {
return MoveTo(x: point.x, y: point.y).lineTo(x: point.x, y: point.y).build()