From 2380ffd6162304e75d574c044301875329be2e3f Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Thu, 7 Mar 2024 09:41:47 -0300 Subject: [PATCH] Allow LaggedStart to accept an iterable as an argument --- manimlib/animation/composition.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/manimlib/animation/composition.py b/manimlib/animation/composition.py index 5526ab36..d23d90cb 100644 --- a/manimlib/animation/composition.py +++ b/manimlib/animation/composition.py @@ -13,7 +13,8 @@ from manimlib.utils.bezier import interpolate from manimlib.utils.iterables import remove_list_redundancies from manimlib.utils.simple_functions import clip -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Union, Iterable +AnimationType = Union[Animation, _AnimationBuilder] if TYPE_CHECKING: from typing import Callable, Optional @@ -28,13 +29,14 @@ DEFAULT_LAGGED_START_LAG_RATIO = 0.05 class AnimationGroup(Animation): def __init__( self, - *animations: Animation | _AnimationBuilder, + *args: AnimationType | Iterable[AnimationType], run_time: float = -1, # If negative, default to sum of inputed animation runtimes lag_ratio: float = 0.0, group: Optional[Mobject] = None, group_type: Optional[type] = None, **kwargs ): + animations = args[0] if isinstance(args[0], Iterable) else args self.animations = [prepare_animation(anim) for anim in animations] self.build_animations_with_timings(lag_ratio) self.max_end_time = max((awt[2] for awt in self.anims_with_timings), default=0)