diff --git a/manimlib/mobject/coordinate_systems.py b/manimlib/mobject/coordinate_systems.py index 6498498f..1239c4d1 100644 --- a/manimlib/mobject/coordinate_systems.py +++ b/manimlib/mobject/coordinate_systems.py @@ -252,11 +252,11 @@ class CoordinateSystem(ABC): xs[:] = sorted([*x_values, *added_xs])[:len(x_values)] return self.c2p(xs, func(xs)) - graph.add_updater(lambda g: g.set_points_as_corners( - get_graph_points() - )) + graph.add_updater( + lambda g: g.set_points_as_corners(get_graph_points()) + ) if not jagged: - graph.add_updater(lambda g: g.make_approximately_smooth()) + graph.add_updater(lambda g: g.make_smooth(approx=True)) return graph def get_graph_label( diff --git a/manimlib/mobject/functions.py b/manimlib/mobject/functions.py index d4080e8a..1ff37e53 100644 --- a/manimlib/mobject/functions.py +++ b/manimlib/mobject/functions.py @@ -48,7 +48,7 @@ class ParametricCurve(VMobject): self.start_new_path(points[0]) self.add_points_as_corners(points[1:]) if self.use_smoothing: - self.make_approximately_smooth() + self.make_smooth(approx=True) if not self.has_points(): self.set_points(np.array([self.t_func(t_min)])) return self diff --git a/manimlib/mobject/types/vectorized_mobject.py b/manimlib/mobject/types/vectorized_mobject.py index 8ea51c2c..7df57544 100644 --- a/manimlib/mobject/types/vectorized_mobject.py +++ b/manimlib/mobject/types/vectorized_mobject.py @@ -578,13 +578,10 @@ class VMobject(Mobject): def set_points_smoothly( self, points: Iterable[Vect3], - true_smooth: bool = False + approx: bool = False ): self.set_points_as_corners(points) - if true_smooth: - self.make_smooth() - else: - self.make_approximately_smooth() + self.make_smooth(approx=approx) return self def is_smooth(self) -> bool: @@ -608,32 +605,23 @@ class VMobject(Mobject): self.add_subpath(new_subpath) return self - def make_smooth(self, recurse=True): + def make_smooth(self, approx=False, recurse=True): """ Edits the path so as to pass smoothly through all the current anchor points. - This may increase the total number of points. + If approx is False, this may increase the total + number of points. """ + mode = "approx_smooth" if approx else "true_smooth" for submob in self.get_family(recurse): if submob.is_smooth(): continue - submob.change_anchor_mode("true_smooth") + submob.change_anchor_mode(mode) return self def make_approximately_smooth(self, recurse=True): - """ - Unlike make_smooth, this will not change the number of - points, but it also does not result in a perfectly smooth - curve. It's most useful when the points have been - sampled at a not-too-low rate from a continuous function, - as in the case of ParametricCurve - """ - for submob in self.get_family(recurse): - if submob.is_smooth(): - continue - submob.change_anchor_mode("approx_smooth") - return self + self.make_smooth(approx=True, recurse=recurse) def make_jagged(self, recurse=True): for submob in self.get_family(recurse): @@ -1145,7 +1133,7 @@ class VMobject(Mobject): ): super().apply_function(function, **kwargs) if self.make_smooth_after_applying_functions or make_smooth: - self.make_approximately_smooth() + self.make_smooth(approx=True) return self def apply_points_function(self, *args, **kwargs): diff --git a/manimlib/mobject/vector_field.py b/manimlib/mobject/vector_field.py index 695cc0c9..86c9a181 100644 --- a/manimlib/mobject/vector_field.py +++ b/manimlib/mobject/vector_field.py @@ -250,7 +250,7 @@ class StreamLines(VGroup): line.virtual_time = time step = max(1, int(len(points) / self.n_samples_per_line)) line.set_points_as_corners(points[::step]) - line.make_approximately_smooth() + line.make_smooth(approx=True) lines.append(line) self.set_submobjects(lines)