Handle edge case of single point passed into approx_smooth_quadratic_bezier_handles

This commit is contained in:
Grant Sanderson 2024-08-07 12:12:29 -05:00
parent 0dcf630222
commit e130625b9b

View file

@ -198,7 +198,9 @@ def approx_smooth_quadratic_bezier_handles(
another that would produce a parabola passing through P0, call it smooth_to_left,
and use the midpoint between the two.
"""
if len(points) == 2:
if len(points) == 1:
return points[0]
elif len(points) == 2:
return midpoint(*points)
smooth_to_right, smooth_to_left = [
0.25 * ps[0:-2] + ps[1:-1] - 0.25 * ps[2:]