A community-maintained Python framework for creating mathematical animations.
Decided not to alter (effective) run times of concurrent animations
Grant Sanderson4ebcef23c925
diff --git a/animation/animation.py b/animation/animation.pyindex 000e8d957..4c9b9452f 100644--- a/animation/animation.py+++ b/animation/animation.py@@ -51,12 +51,18 @@ class Animation(object):self.run_time = timereturn self+ def get_run_time(self):+ return self.run_time+def set_rate_func(self, rate_func):if rate_func is None:rate_func = lambda x : xself.rate_func = rate_funcreturn self+ def get_rate_func(self):+ return self.rate_func+def set_name(self, name):self.name = namereturn selfdiff --git a/scene/scene.py b/scene/scene.pyindex 189053c60..7d59a5311 100644--- a/scene/scene.py+++ b/scene/scene.py@@ -134,10 +134,18 @@ class Scene(object):def align_run_times(self, *animations, **kwargs):if "run_time" in kwargs:run_time = kwargs["run_time"]+ for animation in animations:+ animation.set_run_time(run_time)else:- run_time = animations[0].run_time- for animation in animations:- animation.set_run_time(run_time)+ max_run_time = max([a.run_time for a in animations])+ for animation in animations:+ if animation.run_time != max_run_time:+ new_rate_func = squish_rate_func(+ animation.get_rate_func(),+ 0, 1./max_run_time+ )+ animation.set_rate_func(new_rate_func)+ animation.set_run_time(max_run_time)return animationsdef separate_moving_and_static_mobjects(self, *animations):@@ -168,7 +176,6 @@ class Scene(object):raise Warning("Called Scene.play with no animations")returnself.num_animations += 1- self.mobjects_from_last_animation = []animations = self.align_run_times(*animations, **kwargs)moving_mobjects, static_mobjects = \@@ -186,6 +193,7 @@ class Scene(object):return selfdef clean_up_animations(self, *animations):+ self.mobjects_from_last_animation = []for animation in animations:animation.clean_up()if animation.is_remover():