mirror of
https://github.com/3b1b/manim.git
synced 2025-07-29 21:12:35 +08:00
29 lines
914 B
Python
29 lines
914 B
Python
from manimlib.continual_animation.continual_animation import ContinualAnimation
|
|
|
|
|
|
class NormalAnimationAsContinualAnimation(ContinualAnimation):
|
|
CONFIG = {
|
|
"start_up_time": 0,
|
|
"wind_down_time": 0,
|
|
}
|
|
|
|
def __init__(self, animation, **kwargs):
|
|
self.animation = animation
|
|
ContinualAnimation.__init__(self, animation.mobject, **kwargs)
|
|
|
|
def update_mobject(self, dt):
|
|
self.animation.update(
|
|
min(float(self.internal_time) / self.animation.run_time, 1)
|
|
)
|
|
|
|
|
|
class CycleAnimation(ContinualAnimation):
|
|
def __init__(self, animation, **kwargs):
|
|
self.animation = animation
|
|
ContinualAnimation.__init__(self, animation.mobject, **kwargs)
|
|
|
|
def update_mobject(self, dt):
|
|
mod_value = self.internal_time % self.animation.run_time
|
|
alpha = mod_value / float(self.animation.run_time)
|
|
self.animation.update(alpha)
|