๐LineShape
SwiftUI โฉ Drawing โฉ Shape โฉ Helper Shapes โฉ

// 2022.02.10
import SwiftUI
/// a line (invisible shape) relative to a rect.
/// ```
/// LineShape([0,0], [1,1])
/// ```
struct LineShape: Shape {
let p1: UnitPoint
let p2: UnitPoint
func path(in rect: CGRect) -> Path {
Path { path in
// ๐Path+ line(), ๐
ฟ๏ธ Rectangular
path.line(rect[p1], rect[p2])
}
}
}
// convenience init
extension LineShape {
init(_ p1: UnitPoint, _ p2: UnitPoint) {
self.init(p1: p1, p2: p2)
}
}
Last updated
Was this helpful?