mirror of
https://github.com/3b1b/manim.git
synced 2025-07-28 04:23:16 +08:00
Cleand up movement.py for new Animation structure
This commit is contained in:
@ -1,5 +1,4 @@
|
|||||||
from manimlib.animation.animation import Animation
|
from manimlib.animation.animation import Animation
|
||||||
from manimlib.constants import *
|
|
||||||
from manimlib.utils.config_ops import digest_config
|
from manimlib.utils.config_ops import digest_config
|
||||||
from manimlib.utils.rate_functions import linear
|
from manimlib.utils.rate_functions import linear
|
||||||
|
|
||||||
@ -12,13 +11,14 @@ class Homotopy(Animation):
|
|||||||
|
|
||||||
def __init__(self, homotopy, mobject, **kwargs):
|
def __init__(self, homotopy, mobject, **kwargs):
|
||||||
"""
|
"""
|
||||||
Homotopy a function from (x, y, z, t) to (x', y', z')
|
Homotopy is a function from
|
||||||
|
(x, y, z, t) to (x', y', z')
|
||||||
"""
|
"""
|
||||||
def function_at_time_t(t):
|
self.homotopy = homotopy
|
||||||
return lambda p: homotopy(p[0], p[1], p[2], t)
|
super().__init__(mobject, **kwargs)
|
||||||
self.function_at_time_t = function_at_time_t
|
|
||||||
digest_config(self, kwargs)
|
def function_at_time_t(self, t):
|
||||||
Animation.__init__(self, mobject, **kwargs)
|
return lambda p: self.homotopy(*p, t)
|
||||||
|
|
||||||
def interpolate_submobject(self, submob, start, alpha):
|
def interpolate_submobject(self, submob, start, alpha):
|
||||||
submob.points = start.points
|
submob.points = start.points
|
||||||
@ -49,11 +49,12 @@ class PhaseFlow(Animation):
|
|||||||
CONFIG = {
|
CONFIG = {
|
||||||
"virtual_time": 1,
|
"virtual_time": 1,
|
||||||
"rate_func": linear,
|
"rate_func": linear,
|
||||||
|
"suspend_mobject_updating": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, function, mobject, **kwargs):
|
def __init__(self, function, mobject, **kwargs):
|
||||||
digest_config(self, kwargs, locals())
|
self.function = function
|
||||||
Animation.__init__(self, mobject, **kwargs)
|
super().__init__(mobject, **kwargs)
|
||||||
|
|
||||||
def interpolate_mobject(self, alpha):
|
def interpolate_mobject(self, alpha):
|
||||||
if hasattr(self, "last_alpha"):
|
if hasattr(self, "last_alpha"):
|
||||||
@ -65,9 +66,13 @@ class PhaseFlow(Animation):
|
|||||||
|
|
||||||
|
|
||||||
class MoveAlongPath(Animation):
|
class MoveAlongPath(Animation):
|
||||||
|
CONFIG = {
|
||||||
|
"suspend_mobject_updating": False,
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, mobject, path, **kwargs):
|
def __init__(self, mobject, path, **kwargs):
|
||||||
digest_config(self, kwargs, locals())
|
self.path = path
|
||||||
Animation.__init__(self, mobject, **kwargs)
|
super().__init__(mobject, **kwargs)
|
||||||
|
|
||||||
def interpolate_mobject(self, alpha):
|
def interpolate_mobject(self, alpha):
|
||||||
point = self.path.point_from_proportion(alpha)
|
point = self.path.point_from_proportion(alpha)
|
||||||
|
Reference in New Issue
Block a user