Allow for AnimationGroup to specify that parts belong to a VGroup

This commit is contained in:
Grant Sanderson 2022-12-29 12:02:48 -08:00
parent 3738f0a48e
commit ef09d6fce2

View file

@ -29,6 +29,7 @@ class AnimationGroup(Animation):
run_time: float = -1, # If negative, default to sum of inputed animation runtimes run_time: float = -1, # If negative, default to sum of inputed animation runtimes
lag_ratio: float = 0.0, lag_ratio: float = 0.0,
group: Mobject | None = None, group: Mobject | None = None,
group_type: type = Group,
**kwargs **kwargs
): ):
self.animations = [prepare_animation(anim) for anim in animations] self.animations = [prepare_animation(anim) for anim in animations]
@ -38,7 +39,7 @@ class AnimationGroup(Animation):
self.lag_ratio = lag_ratio self.lag_ratio = lag_ratio
self.group = group self.group = group
if self.group is None: if self.group is None:
self.group = Group(*remove_list_redundancies( self.group = group_type(*remove_list_redundancies(
[anim.mobject for anim in self.animations] [anim.mobject for anim in self.animations]
)) ))
@ -49,7 +50,7 @@ class AnimationGroup(Animation):
**kwargs **kwargs
) )
def get_all_mobjects(self) -> Group: def get_all_mobjects(self) -> Mobject:
return self.group return self.group
def begin(self) -> None: def begin(self) -> None: