Add an option for VMobject.add_line to add a null line

This commit is contained in:
Grant Sanderson 2024-08-21 14:29:40 -05:00
parent c83d03aeb7
commit b3386ad7a7
2 changed files with 3 additions and 3 deletions

View file

@ -687,7 +687,7 @@ class Arrow(Line):
if self.path_arc > 0 and self.buff > 0:
self.insert_n_curves(10) # Is this needed?
self.pointwise_become_partial(self, 0.0, 1.0 - alpha)
self.add_line_to(self.get_end())
self.add_line_to(self.get_end(), allow_null_line=True)
self.add_line_to(prev_end)
self.n_tip_points = 3
return self

View file

@ -513,10 +513,10 @@ class VMobject(Mobject):
self.append_points([handle, anchor])
return self
def add_line_to(self, point: Vect3) -> Self:
def add_line_to(self, point: Vect3, allow_null_line: bool = False) -> Self:
self.throw_error_if_no_points()
last_point = self.get_last_point()
if self.consider_points_equal(last_point, point):
if not allow_null_line and self.consider_points_equal(last_point, point):
return self
alphas = np.linspace(0, 1, 5 if self.long_lines else 3)
self.append_points(outer_interpolate(last_point, point, alphas[1:]))