mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Cleand up movement.py for new Animation structure
This commit is contained in:
parent
3714446eea
commit
2b64656f35
1 changed files with 16 additions and 11 deletions
|
@ -1,5 +1,4 @@
|
|||
from manimlib.animation.animation import Animation
|
||||
from manimlib.constants import *
|
||||
from manimlib.utils.config_ops import digest_config
|
||||
from manimlib.utils.rate_functions import linear
|
||||
|
||||
|
@ -12,13 +11,14 @@ class Homotopy(Animation):
|
|||
|
||||
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):
|
||||
return lambda p: homotopy(p[0], p[1], p[2], t)
|
||||
self.function_at_time_t = function_at_time_t
|
||||
digest_config(self, kwargs)
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
self.homotopy = homotopy
|
||||
super().__init__(mobject, **kwargs)
|
||||
|
||||
def function_at_time_t(self, t):
|
||||
return lambda p: self.homotopy(*p, t)
|
||||
|
||||
def interpolate_submobject(self, submob, start, alpha):
|
||||
submob.points = start.points
|
||||
|
@ -49,11 +49,12 @@ class PhaseFlow(Animation):
|
|||
CONFIG = {
|
||||
"virtual_time": 1,
|
||||
"rate_func": linear,
|
||||
"suspend_mobject_updating": False,
|
||||
}
|
||||
|
||||
def __init__(self, function, mobject, **kwargs):
|
||||
digest_config(self, kwargs, locals())
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
self.function = function
|
||||
super().__init__(mobject, **kwargs)
|
||||
|
||||
def interpolate_mobject(self, alpha):
|
||||
if hasattr(self, "last_alpha"):
|
||||
|
@ -65,9 +66,13 @@ class PhaseFlow(Animation):
|
|||
|
||||
|
||||
class MoveAlongPath(Animation):
|
||||
CONFIG = {
|
||||
"suspend_mobject_updating": False,
|
||||
}
|
||||
|
||||
def __init__(self, mobject, path, **kwargs):
|
||||
digest_config(self, kwargs, locals())
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
self.path = path
|
||||
super().__init__(mobject, **kwargs)
|
||||
|
||||
def interpolate_mobject(self, alpha):
|
||||
point = self.path.point_from_proportion(alpha)
|
||||
|
|
Loading…
Add table
Reference in a new issue