mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Finish last(?) digest_config vestige
This commit is contained in:
parent
a6db0877de
commit
a4272d11a2
2 changed files with 20 additions and 17 deletions
|
@ -4,7 +4,6 @@ from copy import deepcopy
|
|||
|
||||
from manimlib.mobject.mobject import _AnimationBuilder
|
||||
from manimlib.mobject.mobject import Mobject
|
||||
from manimlib.utils.config_ops import digest_config
|
||||
from manimlib.utils.rate_functions import smooth
|
||||
from manimlib.utils.rate_functions import squish_rate_func
|
||||
from manimlib.utils.simple_functions import clip
|
||||
|
@ -128,8 +127,15 @@ class Animation(object):
|
|||
def copy(self):
|
||||
return deepcopy(self)
|
||||
|
||||
def update_config(self, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
def update_rate_info(
|
||||
self,
|
||||
run_time: float | None = None,
|
||||
rate_func: Callable[[float], float] | None = None,
|
||||
lag_ratio: float | None = None,
|
||||
):
|
||||
self.run_time = run_time or self.run_time
|
||||
self.rate_func = rate_func or self.rate_func
|
||||
self.lag_ratio = lag_ratio or self.lag_ratio
|
||||
return self
|
||||
|
||||
# Methods for interpolation, the mean of an Animation
|
||||
|
|
|
@ -502,6 +502,7 @@ class Scene(object):
|
|||
self,
|
||||
animations: Iterable[Animation]
|
||||
) -> list[float] | np.ndarray | ProgressDisplay:
|
||||
animations = list(animations)
|
||||
run_time = self.get_run_time(animations)
|
||||
description = f"{self.num_plays} {animations[0]}"
|
||||
if len(animations) > 1:
|
||||
|
@ -520,18 +521,6 @@ class Scene(object):
|
|||
kw["override_skip_animations"] = True
|
||||
return self.get_time_progression(duration, **kw)
|
||||
|
||||
def prepare_animations(
|
||||
self,
|
||||
proto_animations: list[Animation | _AnimationBuilder],
|
||||
animation_config: dict,
|
||||
):
|
||||
animations = list(map(prepare_animation, proto_animations))
|
||||
for anim in animations:
|
||||
# This is where kwargs to play like run_time and rate_func
|
||||
# get applied to all animations
|
||||
anim.update_config(**animation_config)
|
||||
return animations
|
||||
|
||||
def handle_play_like_call(func):
|
||||
@wraps(func)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
|
@ -601,11 +590,19 @@ class Scene(object):
|
|||
self.update_mobjects(0)
|
||||
|
||||
@handle_play_like_call
|
||||
def play(self, *proto_animations, **animation_config) -> None:
|
||||
def play(
|
||||
self,
|
||||
*proto_animations: Animation | _AnimationBuilder,
|
||||
run_time: float | None = None,
|
||||
rate_func: Callable[[float], float] | None = None,
|
||||
lag_ratio: float | None = None,
|
||||
) -> None:
|
||||
if len(proto_animations) == 0:
|
||||
log.warning("Called Scene.play with no animations")
|
||||
return
|
||||
animations = self.prepare_animations(proto_animations, animation_config)
|
||||
animations = list(map(prepare_animation, proto_animations))
|
||||
for anim in animations:
|
||||
anim.update_rate_info(run_time, rate_func, lag_ratio)
|
||||
self.begin_animations(animations)
|
||||
self.progress_through_animations(animations)
|
||||
self.finish_animations(animations)
|
||||
|
|
Loading…
Add table
Reference in a new issue