mirror of
https://github.com/exyte/Macaw.git
synced 2024-09-11 05:05:23 +03:00
Override toPath() for Rect.
This commit is contained in:
parent
fd64147a3a
commit
6758c3bbe0
@ -2,10 +2,6 @@ import Foundation
|
||||
|
||||
extension Locus {
|
||||
|
||||
internal func rectToPath(_ rect: Rect) -> Path {
|
||||
return MoveTo(x: rect.x, y: rect.y).lineTo(x: rect.x, y: rect.y + rect.h).lineTo(x: rect.x + rect.w, y: rect.y + rect.h).lineTo(x: rect.x + rect.w, y: rect.y).close().build()
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
@ -20,9 +20,7 @@ open class Locus {
|
||||
}
|
||||
|
||||
open func toPath() -> Path {
|
||||
if let rect = self as? Rect {
|
||||
return rectToPath(rect)
|
||||
} else if let circle = self as? Circle {
|
||||
if let circle = self as? Circle {
|
||||
return circleToPath(circle)
|
||||
} else if let arc = self as? Arc {
|
||||
return arcToPath(arc)
|
||||
|
@ -63,6 +63,9 @@ open class Rect: Locus {
|
||||
return Size(w: w, h: h)
|
||||
}
|
||||
|
||||
override open func toPath() -> Path {
|
||||
return MoveTo(x: x, y: y).lineTo(x: x, y: y + h).lineTo(x: x + w, y: y + h).lineTo(x: x + w, y: y).close().build()
|
||||
}
|
||||
}
|
||||
|
||||
extension Rect {
|
||||
|
Loading…
Reference in New Issue
Block a user