A community-maintained Python framework for creating mathematical animations.
Remove CycleAnimation ContinualAnimation, replace with cycle_animation which adds a mobject updater
Grant Sanderson605ca08e6f22
diff --git a/manimlib/continual_animation/from_animation.py b/manimlib/continual_animation/from_animation.pydeleted file mode 100644index f48179166..000000000--- a/manimlib/continual_animation/from_animation.py+++ /dev/null@@ -1,12 +0,0 @@-from manimlib.continual_animation.continual_animation import ContinualAnimation---class CycleAnimation(ContinualAnimation):- def __init__(self, animation, **kwargs):- self.animation = animation- ContinualAnimation.__init__(self, animation.mobject, **kwargs)-- def update_mobject(self, dt):- mod_value = self.internal_time % self.animation.run_time- alpha = mod_value / float(self.animation.run_time)- self.animation.update(alpha)diff --git a/manimlib/continual_animation/numbers.py b/manimlib/continual_animation/numbers.pyindex f8763ec6e..a08396f89 100644--- a/manimlib/continual_animation/numbers.py+++ b/manimlib/continual_animation/numbers.py@@ -1,9 +1,9 @@-from manimlib.animation.numbers import ChangingDecimal-from manimlib.continual_animation.from_animation import NormalAnimationAsContinualAnimation+# from manimlib.animation.numbers import ChangingDecimal+# from manimlib.continual_animation.from_animation import NormalAnimationAsContinualAnimation-class ContinualChangingDecimal(NormalAnimationAsContinualAnimation):- def __init__(self, *args, **kwargs):- NormalAnimationAsContinualAnimation.__init__(- self, ChangingDecimal(*args, **kwargs)- )+# class ContinualChangingDecimal(NormalAnimationAsContinualAnimation):+# def __init__(self, *args, **kwargs):+# NormalAnimationAsContinualAnimation.__init__(+# self, ChangingDecimal(*args, **kwargs)+# )diff --git a/manimlib/mobject/mobject_update_utils.py b/manimlib/mobject/mobject_update_utils.pyindex f8407a214..5fc0ce174 100644--- a/manimlib/mobject/mobject_update_utils.py+++ b/manimlib/mobject/mobject_update_utils.py@@ -34,29 +34,41 @@ def always_rotate(mobject, rate=20 * DEGREES, **kwargs):return mobject-def turn_animation_into_updater(animation):+def turn_animation_into_updater(animation, cycle=False, **kwargs):"""- Note sure if this is actually useful. This is really- here just to replace past usage of- turn_animation_into_updater+ Add an updater to the animation's mobject which applies+ the interpolation and update functions of the animation++ If cycle is True, this repeats over and over. Otherwise,+ the updater will be popped uplon completion"""mobject = animation.mobject+ animation.update_config(**kwargs)animation.suspend_mobject_updating = Falseanimation.begin()animation.total_time = 0def update(m, dt):+ run_time = animation.get_run_time()alpha = np.clip(- animation.total_time / animation.get_run_time(),+ animation.total_time / run_time,0, 1,)- if alpha >= 1:+ if cycle:+ animation.total_time = animation.total_time % run_time+ elif alpha >= 1:animation.finish()m.remove_updater(update)- else:- animation.interpolate(alpha)- animation.total_time += dt- animation.update_mobjects(dt)+ return+ animation.interpolate(alpha)+ animation.update_mobjects(dt)+ animation.total_time += dtmobject.add_updater(update)return mobject+++def cycle_animation(animation, **kwargs):+ return turn_animation_into_updater(+ animation, cycle=True, **kwargs+ )diff --git a/old_projects/alt_calc.py b/old_projects/alt_calc.pyindex c636fef1f..5bb80b87e 100644--- a/old_projects/alt_calc.py+++ b/old_projects/alt_calc.py@@ -2259,7 +2259,7 @@ class GraphOnePlusOneOverX(GraphScene):lag_ratio=0.5,run_time=2)- line.continual_anim = CycleAnimation(line_anim)+ cycle_animation(line_anim)lines.add(line)phi_line, phi_bro_line = linesdiff --git a/old_projects/dandelin.py b/old_projects/dandelin.pyindex 0bf1e3986..496fda958 100644--- a/old_projects/dandelin.py+++ b/old_projects/dandelin.py@@ -634,7 +634,7 @@ class EccentricityInThumbtackCase(ShowArrayOfEccentricities):def get_ellipse_point_update(self, ellipse):dot = Dot(color=RED)- return CycleAnimation(MoveAlongPath(+ return cycle_animation(MoveAlongPath(dot, ellipse,run_time=5,rate_func=linear@@ -1584,7 +1584,7 @@ class EllipseLengthsLinedUp(EccentricityInThumbtackCase):foci = self.get_foci(ellipse)point = VectorizedPoint()- point_movement = CycleAnimation(+ point_movement = cycle_animation(MoveAlongPath(point, ellipse,run_time=5,