Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Minor improvements to some details of Successor implementation

Sridhar Rameshf0ed90a8845b
diff --git a/animation/simple_animations.py b/animation/simple_animations.py
index c151a3268..94dad47d1 100644
--- a/animation/simple_animations.py
+++ b/animation/simple_animations.py
@@ -431,20 +431,25 @@ class Succession(Animation):
self.current_anim_index = 0 #TODO: What if self.num_anims == 0?
self.mobject = Group()
- self.jump_to_start_of_anim(0)
+ self.current_anim_index = 0
+ self.current_alpha = 0
+
Animation.__init__(self, self.mobject, run_time = run_time, **kwargs)
+ # Beware: This does NOT take care of updating the subanimation to 0
+ # This was important to avoid a pernicious possibility in which subanimations were called
+ # with update(0) twice, which could in turn call a sub-Succession with update(0) four times,
+ # continuing exponentially
def jump_to_start_of_anim(self, index):
+ if index != self.current_anim_index:
+ self.mobject.remove(*self.mobject.submobjects) # Should probably have a cleaner "remove_all" method...
+ self.mobject.add(self.animations[index].mobject)
+ for m in self.scene_mobjects_at_time[index].submobjects:
+ self.mobject.add(m)
+
self.current_anim_index = index
self.current_alpha = self.critical_alphas[index]
- self.mobject.remove(*self.mobject.submobjects) # Should probably have a cleaner "remove_all" method...
- self.mobject.add(self.animations[index].mobject)
- for m in self.scene_mobjects_at_time[index].submobjects:
- self.mobject.add(m)
-
- self.animations[index].update(0)
-
def update_mobject(self, alpha):
i = 0
while self.critical_alphas[i + 1] < alpha: