I'am trying in SwiftUI to draw a line between to CGPoint(x:0, y:0), CGPoint(x:100, y:100)
struct Line : Shape {
func path(in rect: CGRect) -> Path {
var path = Path()
path.move(to: CGPoint(x: 0, y: 0))
path.addLine(to: CGPoint(x: 0, y: 100))
path.addLine(to: CGPoint(x: 5, y: 100))
path.addLine(to: CGPoint(x: 5, y: 0))
return path
}
}
struct GpsView: View {
var body: some View {
Line()
.fill(Color.red)
.frame(width: 300, height: 300)
}
}
Is there any way around easiest instead to specify 4 CGPoint, something where I can just say from point 1 to point 2? Thanks.