mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Further fixes to Succession animations
This commit is contained in:
parent
7bcde6713d
commit
123bae00a6
2 changed files with 18 additions and 22 deletions
|
@ -395,13 +395,22 @@ class Succession(Animation):
|
||||||
mobject = Group(*[anim.mobject for anim in self.animations])
|
mobject = Group(*[anim.mobject for anim in self.animations])
|
||||||
Animation.__init__(self, mobject, run_time = run_time, **kwargs)
|
Animation.__init__(self, mobject, run_time = run_time, **kwargs)
|
||||||
|
|
||||||
|
def rewind_to_start(self):
|
||||||
|
for anim in reversed(self.animations):
|
||||||
|
anim.update(0)
|
||||||
|
|
||||||
def update_mobject(self, alpha):
|
def update_mobject(self, alpha):
|
||||||
|
self.rewind_to_start()
|
||||||
|
|
||||||
for i in range(len(self.animations)):
|
for i in range(len(self.animations)):
|
||||||
sub_alpha = anti_interpolate(
|
sub_alpha = inverse_interpolate(
|
||||||
self.critical_alphas[i],
|
self.critical_alphas[i],
|
||||||
self.critical_alphas[i + 1],
|
self.critical_alphas[i + 1],
|
||||||
alpha
|
alpha
|
||||||
)
|
)
|
||||||
|
if sub_alpha < 0:
|
||||||
|
return
|
||||||
|
|
||||||
sub_alpha = clamp(0, 1, sub_alpha) # Could possibly adopt a non-clamping convention here
|
sub_alpha = clamp(0, 1, sub_alpha) # Could possibly adopt a non-clamping convention here
|
||||||
self.animations[i].update(sub_alpha)
|
self.animations[i].update(sub_alpha)
|
||||||
|
|
||||||
|
@ -424,23 +433,10 @@ class AnimationGroup(Animation):
|
||||||
for anim in self.sub_anims:
|
for anim in self.sub_anims:
|
||||||
anim.update(alpha)
|
anim.update(alpha)
|
||||||
|
|
||||||
|
# Parallel animations where shorter animations are not stretched out to match the longest
|
||||||
|
class UnsyncedParallel(AnimationGroup):
|
||||||
|
def __init__(self, *sub_anims, **kwargs):
|
||||||
|
digest_config(self, kwargs, locals())
|
||||||
|
self.run_time = max([a.run_time for a in sub_anims])
|
||||||
|
everything = Mobject(*[a.mobject for a in sub_anims])
|
||||||
|
Animation.__init__(self, everything, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -307,7 +307,7 @@ def interpolate(start, end, alpha):
|
||||||
def mid(start, end):
|
def mid(start, end):
|
||||||
return (start + end)/2.0
|
return (start + end)/2.0
|
||||||
|
|
||||||
def anti_interpolate(start, end, value):
|
def inverse_interpolate(start, end, value):
|
||||||
return np.true_divide(value - start, end - start)
|
return np.true_divide(value - start, end - start)
|
||||||
|
|
||||||
def clamp(lower, upper, val):
|
def clamp(lower, upper, val):
|
||||||
|
|
Loading…
Add table
Reference in a new issue