mirror of
https://github.com/3b1b/manim.git
synced 2025-11-17 13:17:48 +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):
|
def update(m, dt):
|
||||||
run_time = animation.get_run_time()
|
run_time = animation.get_run_time()
|
||||||
alpha = np.clip(
|
time_ratio = animation.total_time / run_time
|
||||||
animation.total_time / run_time,
|
|
||||||
0, 1,
|
|
||||||
)
|
|
||||||
if cycle:
|
if cycle:
|
||||||
animation.total_time = animation.total_time % run_time
|
alpha = time_ratio % 1
|
||||||
elif alpha >= 1:
|
else:
|
||||||
animation.finish()
|
alpha = np.clip(time_ratio, 0, 1)
|
||||||
m.remove_updater(update)
|
if alpha >= 1:
|
||||||
return
|
animation.finish()
|
||||||
|
m.remove_updater(update)
|
||||||
|
return
|
||||||
animation.interpolate(alpha)
|
animation.interpolate(alpha)
|
||||||
animation.update_mobjects(dt)
|
animation.update_mobjects(dt)
|
||||||
animation.total_time += dt
|
animation.total_time += dt
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue