mirror of
https://github.com/3b1b/manim.git
synced 2025-11-13 22:28:03 +00:00
Kill CONFIG in movement.py
This commit is contained in:
parent
7dcf5eff8e
commit
81615d9f4b
1 changed files with 31 additions and 28 deletions
|
|
@ -14,15 +14,13 @@ if TYPE_CHECKING:
|
|||
|
||||
|
||||
class Homotopy(Animation):
|
||||
CONFIG = {
|
||||
"run_time": 3,
|
||||
"apply_function_kwargs": {},
|
||||
}
|
||||
apply_function_config: dict = dict()
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
homotopy: Callable[[float, float, float, float], Sequence[float]],
|
||||
mobject: Mobject,
|
||||
run_time: float = 3.0,
|
||||
**kwargs
|
||||
):
|
||||
"""
|
||||
|
|
@ -30,13 +28,12 @@ class Homotopy(Animation):
|
|||
(x, y, z, t) to (x', y', z')
|
||||
"""
|
||||
self.homotopy = homotopy
|
||||
super().__init__(mobject, **kwargs)
|
||||
super().__init__(mobject, run_time=run_time, **kwargs)
|
||||
|
||||
def function_at_time_t(
|
||||
self,
|
||||
t: float
|
||||
) -> Callable[[np.ndarray], Sequence[float]]:
|
||||
return lambda p: self.homotopy(*p, t)
|
||||
def function_at_time_t(self, t: float) -> Callable[[np.ndarray], Sequence[float]]:
|
||||
def result(p):
|
||||
return self.homotopy(*p, t)
|
||||
return result
|
||||
|
||||
def interpolate_submobject(
|
||||
self,
|
||||
|
|
@ -47,20 +44,18 @@ class Homotopy(Animation):
|
|||
submob.match_points(start)
|
||||
submob.apply_function(
|
||||
self.function_at_time_t(alpha),
|
||||
**self.apply_function_kwargs
|
||||
**self.apply_function_config
|
||||
)
|
||||
|
||||
|
||||
class SmoothedVectorizedHomotopy(Homotopy):
|
||||
CONFIG = {
|
||||
"apply_function_kwargs": {"make_smooth": True},
|
||||
}
|
||||
apply_function_config: dict = dict(make_smooth=True)
|
||||
|
||||
|
||||
class ComplexHomotopy(Homotopy):
|
||||
def __init__(
|
||||
self,
|
||||
complex_homotopy: Callable[[complex, float], Sequence[float]],
|
||||
complex_homotopy: Callable[[complex, float], complex],
|
||||
mobject: Mobject,
|
||||
**kwargs
|
||||
):
|
||||
|
|
@ -72,24 +67,30 @@ class ComplexHomotopy(Homotopy):
|
|||
def homotopy(x, y, z, t):
|
||||
c = complex_homotopy(complex(x, y), t)
|
||||
return (c.real, c.imag, z)
|
||||
|
||||
super().__init__(homotopy, mobject, **kwargs)
|
||||
|
||||
|
||||
class PhaseFlow(Animation):
|
||||
CONFIG = {
|
||||
"virtual_time": 1,
|
||||
"rate_func": linear,
|
||||
"suspend_mobject_updating": False,
|
||||
}
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
function: Callable[[np.ndarray], np.ndarray],
|
||||
mobject: Mobject,
|
||||
virtual_time: float | None = None,
|
||||
suspend_mobject_updating: bool = False,
|
||||
rate_func: Callable[[float], float] = linear,
|
||||
run_time: float =3.0,
|
||||
**kwargs
|
||||
):
|
||||
self.function = function
|
||||
super().__init__(mobject, **kwargs)
|
||||
self.virtual_time = virtual_time or run_time
|
||||
super().__init__(
|
||||
mobject,
|
||||
rate_func=rate_func,
|
||||
run_time=run_time,
|
||||
suspend_mobject_updating=suspend_mobject_updating,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def interpolate_mobject(self, alpha: float) -> None:
|
||||
if hasattr(self, "last_alpha"):
|
||||
|
|
@ -101,13 +102,15 @@ class PhaseFlow(Animation):
|
|||
|
||||
|
||||
class MoveAlongPath(Animation):
|
||||
CONFIG = {
|
||||
"suspend_mobject_updating": False,
|
||||
}
|
||||
|
||||
def __init__(self, mobject: Mobject, path: Mobject, **kwargs):
|
||||
def __init__(
|
||||
self,
|
||||
mobject: Mobject,
|
||||
path: Mobject,
|
||||
suspend_mobject_updating: bool = False,
|
||||
**kwargs
|
||||
):
|
||||
self.path = path
|
||||
super().__init__(mobject, **kwargs)
|
||||
super().__init__(mobject, suspend_mobject_updating=suspend_mobject_updating, **kwargs)
|
||||
|
||||
def interpolate_mobject(self, alpha: float) -> None:
|
||||
point = self.path.point_from_proportion(alpha)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue