Let's say I have a Shape:
struct Triangle: Shape {
func path(in rect: CGRect) -> Path {
var path = Path()
path.move(to: CGPoint(x: rect.midX, y: rect.minY))
path.addLine(to: CGPoint(x: rect.minX, y: rect.maxY))
path.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY))
path.addLine(to: CGPoint(x: rect.midX, y: rect.minY))
return path
}
}
How can I get the Path of this Shape and iterate over all points of this path? This rectangle is just an example. I have a lot of different shapes with relative/absolute positions. For a specific use case I need to compare the points with a given point
I'm looking for something like:
public func checkPath(shape: Shape) {
for point in shape.path {
// do calculation
}
}