mirror of
https://github.com/3b1b/manim.git
synced 2025-08-19 21:08:53 +00:00
Added LaggedStart animation
This commit is contained in:
parent
02de9ad909
commit
507dd9d9dd
1 changed files with 32 additions and 1 deletions
|
@ -294,6 +294,38 @@ class ApplyToCenters(Animation):
|
||||||
center_mob.get_center()-mobject.get_center()
|
center_mob.get_center()-mobject.get_center()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class LaggedStart(Animation):
|
||||||
|
CONFIG = {
|
||||||
|
"run_time" : 2,
|
||||||
|
"lag_ratio" : 0.5,
|
||||||
|
}
|
||||||
|
def __init__(self, AnimationClass, mobject, arg_creator = None, **kwargs):
|
||||||
|
digest_config(self, kwargs)
|
||||||
|
for key in "rate_func", "run_time", "lag_ratio":
|
||||||
|
if key in kwargs:
|
||||||
|
kwargs.pop(key)
|
||||||
|
if arg_creator is None:
|
||||||
|
arg_creator = lambda mobject : (mobject,)
|
||||||
|
self.subanimations = [
|
||||||
|
AnimationClass(
|
||||||
|
*arg_creator(submob),
|
||||||
|
run_time = self.run_time,
|
||||||
|
rate_func = squish_rate_func(
|
||||||
|
self.rate_func, beta, beta + self.lag_ratio
|
||||||
|
),
|
||||||
|
**kwargs
|
||||||
|
)
|
||||||
|
for submob, beta in zip(
|
||||||
|
mobject,
|
||||||
|
np.linspace(0, 1-self.lag_ratio, len(mobject))
|
||||||
|
)
|
||||||
|
]
|
||||||
|
Animation.__init__(self, mobject, **kwargs)
|
||||||
|
|
||||||
|
def update(self, alpha):
|
||||||
|
for anim in self.subanimations:
|
||||||
|
anim.update(alpha)
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
class DelayByOrder(Animation):
|
class DelayByOrder(Animation):
|
||||||
|
@ -325,7 +357,6 @@ class DelayByOrder(Animation):
|
||||||
])
|
])
|
||||||
self.animation.update_mobject(alpha_array)
|
self.animation.update_mobject(alpha_array)
|
||||||
|
|
||||||
|
|
||||||
class Succession(Animation):
|
class Succession(Animation):
|
||||||
def __init__(self, *animations, **kwargs):
|
def __init__(self, *animations, **kwargs):
|
||||||
if "run_time" in kwargs:
|
if "run_time" in kwargs:
|
||||||
|
|
Loading…
Add table
Reference in a new issue