A community-maintained Python framework for creating mathematical animations.
Fixed animations not respecting the specified rate function (#2211)
Benjamin Hackl80a988b43da4
diff --git a/manim/animation/animation.py b/manim/animation/animation.pyindex 681cde54e..e7da5833d 100644--- a/manim/animation/animation.py+++ b/manim/animation/animation.py@@ -64,6 +64,16 @@ class Animation:Whether updaters of the mobject should be suspended during the animation.+ .. NOTE::++ In the current implementation of this class, the specified rate function is applied+ within :meth:`.Animation.interpolate_mobject` call as part of the call to+ :meth:`.Animation.interpolate_submobject`. For subclasses of :class:`.Animation`+ that are implemented by overriding :meth:`interpolate_mobject`, the rate function+ has to be applied manually (e.g., by passing ``self.rate_func(alpha)`` instead+ of just ``alpha``).++Examples--------diff --git a/manim/animation/creation.py b/manim/animation/creation.pyindex 83ddc54d3..4a8a2115c 100644--- a/manim/animation/creation.py+++ b/manim/animation/creation.py@@ -430,7 +430,7 @@ class ShowIncreasingSubsets(Animation):def interpolate_mobject(self, alpha: float) -> None:n_submobs = len(self.all_submobs)- index = int(self.int_func(alpha * n_submobs))+ index = int(self.int_func(self.rate_func(alpha) * n_submobs))self.update_submobject_list(index)def update_submobject_list(self, index: int) -> None:diff --git a/manim/animation/numbers.py b/manim/animation/numbers.pyindex 94e547997..57b388617 100644--- a/manim/animation/numbers.py+++ b/manim/animation/numbers.py@@ -29,7 +29,7 @@ class ChangingDecimal(Animation):raise TypeError("ChangingDecimal can only take in a DecimalNumber")def interpolate_mobject(self, alpha: float) -> None:- self.mobject.set_value(self.number_update_func(alpha))+ self.mobject.set_value(self.number_update_func(self.rate_func(alpha)))class ChangeDecimalToValue(ChangingDecimal):diff --git a/manim/animation/rotation.py b/manim/animation/rotation.pyindex d8236c638..d8d308dfa 100644--- a/manim/animation/rotation.py+++ b/manim/animation/rotation.py@@ -37,7 +37,7 @@ class Rotating(Animation):def interpolate_mobject(self, alpha: float) -> None:self.mobject.become(self.starting_mobject)self.mobject.rotate(- alpha * self.radians,+ self.rate_func(alpha) * self.radians,axis=self.axis,about_point=self.about_point,about_edge=self.about_edge,diff --git a/manim/animation/update.py b/manim/animation/update.pyindex d6fb376cc..d1b57c9c5 100644--- a/manim/animation/update.py+++ b/manim/animation/update.py@@ -37,7 +37,7 @@ class UpdateFromFunc(Animation):class UpdateFromAlphaFunc(UpdateFromFunc):def interpolate_mobject(self, alpha: float) -> None:- self.update_function(self.mobject, alpha)+ self.update_function(self.mobject, self.rate_func(alpha))class MaintainPositionRelativeTo(Animation):