Kill Animation CONFIG

This commit is contained in:
Grant Sanderson 2022-12-13 15:45:57 -08:00
parent a801aefcea
commit 6f470679f7

View file

@ -22,33 +22,41 @@ DEFAULT_ANIMATION_LAG_RATIO = 0
class Animation(object): class Animation(object):
CONFIG = { def __init__(
"run_time": DEFAULT_ANIMATION_RUN_TIME, self,
"time_span": None, # Tuple of times, between which the animation will run mobject: Mobject,
"rate_func": smooth, run_time: float = DEFAULT_ANIMATION_RUN_TIME,
"name": None, # Tuple of times, between which the animation will run
# Does this animation add or remove a mobject form the screen time_span: tuple[float, float] | None = None,
"remover": False, # If 0, the animation is applied to all submobjects at the same time
# What to enter into the update function upon completion
"final_alpha_value": 1,
# If 0, the animation is applied to all submobjects
# at the same time
# If 1, it is applied to each successively. # If 1, it is applied to each successively.
# If 0 < lag_ratio < 1, its applied to each # If 0 < lag_ratio < 1, its applied to each with lagged start times
# with lagged start times lag_ratio: float = DEFAULT_ANIMATION_LAG_RATIO,
"lag_ratio": DEFAULT_ANIMATION_LAG_RATIO, rate_func: Callable[[float], float] = smooth,
"suspend_mobject_updating": True, name: str = "",
} # Does this animation add or remove a mobject form the screen
remover: bool = False,
def __init__(self, mobject: Mobject, **kwargs): # What to enter into the update function upon completion
assert(isinstance(mobject, Mobject)) final_alpha_value: float = 1.0,
digest_config(self, kwargs) suspend_mobject_updating: bool = True,
**kwargs
):
self.mobject = mobject self.mobject = mobject
self.run_time = run_time
self.time_span = time_span
self.rate_func = rate_func
self.name = name or self.__class__.__name__ + str(self.mobject)
self.remover = remover
self.final_alpha_value = final_alpha_value
self.lag_ratio = lag_ratio
self.suspend_mobject_updating = suspend_mobject_updating
assert(isinstance(mobject, Mobject))
digest_config(self, kwargs) # Need to delete
def __str__(self) -> str: def __str__(self) -> str:
if self.name: return self.name
return self.name
return self.__class__.__name__ + str(self.mobject)
def begin(self) -> None: def begin(self) -> None:
# This is called right as an animation is being # This is called right as an animation is being