Allow LaggedStart to accept an iterable as an argument

This commit is contained in:
Grant Sanderson 2024-03-07 09:41:47 -03:00
parent 1372cf101c
commit 2380ffd616

View file

@ -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)