Small fixes to AnimationGroup and Succession

This commit is contained in:
Grant Sanderson 2019-02-08 20:18:54 -08:00
parent 67817e9c6d
commit 88e700b5b0

View file

@ -29,16 +29,35 @@ class AnimationGroup(Animation):
[anim.mobject for anim in animations]
))
Animation.__init__(self, self.group, **kwargs)
self.init_run_time()
def get_all_mobjects(self):
return self.group
def begin(self):
self.init_run_time()
for anim in self.animations:
anim.begin()
def finish(self):
for anim in self.animations:
anim.finish()
def clean_up_from_scene(self, scene):
for anim in self.animations:
anim.clean_up_from_scene(scene)
def update_mobjects(self, dt):
for anim in self.animations:
anim.update_mobjects(dt)
def init_run_time(self):
self.build_animations_with_timings()
self.max_end_time = np.max([
awt[2] for awt in self.anims_with_timings
])
if self.anims_with_timings:
self.max_end_time = np.max([
awt[2] for awt in self.anims_with_timings
])
else:
self.max_end_time = 0
if self.run_time is None:
self.run_time = self.max_end_time
@ -61,22 +80,6 @@ class AnimationGroup(Animation):
start_time, end_time, self.lag_ratio
)
def begin(self):
for anim in self.animations:
anim.begin()
def finish(self):
for anim in self.animations:
anim.finish()
def clean_up_from_scene(self, scene):
for anim in self.animations:
anim.clean_up_from_scene(scene)
def update_mobjects(self, dt):
for anim in self.animations:
anim.update_mobjects(dt)
def interpolate(self, alpha):
# Note, if the run_time of AnimationGroup has been
# set to something other than its default, these
@ -101,11 +104,9 @@ class Succession(AnimationGroup):
"lag_ratio": 1,
}
def __init__(self, *animations, **kwargs):
self.active_animation = animations[0]
super().__init__(*animations, **kwargs)
def begin(self):
assert(len(self.animations) > 0)
self.active_animation = self.animations[0]
self.active_animation.begin()
def finish(self):