Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Bug fix to how Succession behave when Scene.play changes its runtime

Grant Sanderson0e961c85e017
diff --git a/animation/simple_animations.py b/animation/simple_animations.py
index f6ac0e566..bac8ffcc0 100644
--- a/animation/simple_animations.py
+++ b/animation/simple_animations.py
@@ -382,6 +382,10 @@ class Succession(Animation):
run_time = sum(self.run_times)
self.num_anims = len(animations)
self.animations = animations
+ self.last_index = 0
+ #Have to keep track of this run_time, because Scene.play
+ #might very well mess with it.
+ self.original_run_time = run_time
mobject = Group(*[anim.mobject for anim in self.animations])
Animation.__init__(self, mobject, run_time = run_time, **kwargs)
@@ -392,11 +396,17 @@ class Succession(Animation):
return
run_times = self.run_times
index = 0
- time = alpha*self.run_time
+ time = alpha*self.original_run_time
while sum(run_times[:index+1]) < time:
index += 1
+ if index > self.last_index:
+ self.animations[self.last_index].update(1)
+ self.animations[self.last_index].clean_up()
+ self.last_index = index
curr_anim = self.animations[index]
- sub_alpha = (time - sum(run_times[:index]))/run_times[index]
+ sub_alpha = np.clip(
+ (time - sum(run_times[:index]))/run_times[index], 0, 1
+ )
curr_anim.update(sub_alpha)
class AnimationGroup(Animation):