Let's say I have a random bezier path, like this:
let bezierPath = UIBezierPath()
bezierPath.move(to: CGPoint(x: 3, y: 0.84))
bezierPath.addCurve(to: CGPoint(x: 11, y: 8.84), controlPoint1: CGPoint(x: 3, y: 1.84), controlPoint2: CGPoint(x: 9, y: 4.59))
// [...]
bezierPath.addCurve(to: CGPoint(x: 3, y: 0.84), controlPoint1: CGPoint(x: 7, y: 4.84), controlPoint2: CGPoint(x: 3, y: -0.16))
bezierPath.close()
I would like to create a function that compute a CGPoint for a given percentage, where 0% is the first point and 100% the last point of the bezierPath:
extension UIBezierPath {
func getPointFor(percentage: Float) -> CGPoint {
//Computation logic
return result
}
}
I have found this post but the solution doesn't allow me to get all points (position at 15.5% of the path for example).
Is there a way to do this?