Default to allowing null lines, except for SVGPaths

This commit is contained in:
Grant Sanderson 2024-08-21 14:44:33 -05:00
parent b3386ad7a7
commit eea8416d57
3 changed files with 6 additions and 6 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(), allow_null_line=True)
self.add_line_to(self.get_end())
self.add_line_to(prev_end)
self.n_tip_points = 3
return self

View file

@ -321,8 +321,8 @@ class VMobjectFromSVGPath(VMobject):
segment_class_to_func_map = {
se.Move: (self.start_new_path, ("end",)),
se.Close: (self.close_path, ()),
se.Line: (self.add_line_to, ("end",)),
se.QuadraticBezier: (self.add_quadratic_bezier_curve_to, ("control", "end")),
se.Line: (lambda p: self.add_line_to(p, allow_null_line=False), ("end",)),
se.QuadraticBezier: (lambda c, e: self.add_quadratic_bezier_curve_to(c, e, allow_null_curve=False), ("control", "end")),
se.CubicBezier: (self.add_cubic_bezier_curve_to, ("control1", "control2", "end"))
}
for segment in self.path_obj:

View file

@ -502,10 +502,10 @@ class VMobject(Mobject):
self.append_points(quad_approx[1:])
return self
def add_quadratic_bezier_curve_to(self, handle: Vect3, anchor: Vect3) -> Self:
def add_quadratic_bezier_curve_to(self, handle: Vect3, anchor: Vect3, allow_null_curve=True) -> Self:
self.throw_error_if_no_points()
last_point = self.get_last_point()
if self.consider_points_equal(last_point, anchor):
if not allow_null_curve and self.consider_points_equal(last_point, anchor):
return self
if self.consider_points_equal(handle, last_point):
# This is to prevent subpaths from accidentally being marked closed
@ -513,7 +513,7 @@ class VMobject(Mobject):
self.append_points([handle, anchor])
return self
def add_line_to(self, point: Vect3, allow_null_line: bool = False) -> Self:
def add_line_to(self, point: Vect3, allow_null_line: bool = True) -> Self:
self.throw_error_if_no_points()
last_point = self.get_last_point()
if not allow_null_line and self.consider_points_equal(last_point, point):