mirror of
https://github.com/3b1b/manim.git
synced 2025-11-14 05:57:44 +00:00
Better behavior for turn_animation_into_updater and cycle_animations
This commit is contained in:
parent
043e3986f6
commit
db6958462f
1 changed files with 8 additions and 9 deletions
|
|
@ -77,16 +77,15 @@ def turn_animation_into_updater(animation, cycle=False, **kwargs):
|
|||
|
||||
def update(m, dt):
|
||||
run_time = animation.get_run_time()
|
||||
alpha = np.clip(
|
||||
animation.total_time / run_time,
|
||||
0, 1,
|
||||
)
|
||||
time_ratio = animation.total_time / run_time
|
||||
if cycle:
|
||||
animation.total_time = animation.total_time % run_time
|
||||
elif alpha >= 1:
|
||||
animation.finish()
|
||||
m.remove_updater(update)
|
||||
return
|
||||
alpha = time_ratio % 1
|
||||
else:
|
||||
alpha = np.clip(time_ratio, 0, 1)
|
||||
if alpha >= 1:
|
||||
animation.finish()
|
||||
m.remove_updater(update)
|
||||
return
|
||||
animation.interpolate(alpha)
|
||||
animation.update_mobjects(dt)
|
||||
animation.total_time += dt
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue