Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Better behavior for turn_animation_into_updater and cycle_animations

Grant Sandersondb6958462f92
diff --git a/manimlib/mobject/mobject_update_utils.py b/manimlib/mobject/mobject_update_utils.py
index 767adf209..0f256f2c9 100644
--- a/manimlib/mobject/mobject_update_utils.py
+++ b/manimlib/mobject/mobject_update_utils.py
@@ -77,16 +77,15 @@ def turn_animation_into_updater(animation, cycle=False, **kwargs):
def update(m, dt):
run_time = animation.get_run_time()
- alpha = np.clip(
- animation.total_time / run_time,
- 0, 1,
- )
+ time_ratio = animation.total_time / run_time
if cycle:
- animation.total_time = animation.total_time % run_time
- elif alpha >= 1:
- animation.finish()
- m.remove_updater(update)
- return
+ alpha = time_ratio % 1
+ else:
+ alpha = np.clip(time_ratio, 0, 1)
+ if alpha >= 1:
+ animation.finish()
+ m.remove_updater(update)
+ return
animation.interpolate(alpha)
animation.update_mobjects(dt)
animation.total_time += dt