mirror of
https://github.com/3b1b/manim.git
synced 2025-07-31 14:03:59 +08:00
change Scene.apply to take in mob_to_anim function instead of Animation class
This commit is contained in:
@ -5,7 +5,7 @@ import copy
|
|||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from animation import Animation
|
from animation import Animation
|
||||||
from mobject import Mobject, Point
|
from mobject import Mobject, Point, ComplexPlane
|
||||||
from constants import *
|
from constants import *
|
||||||
from helpers import *
|
from helpers import *
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ class ScaleInPlace(ApplyMethod):
|
|||||||
ApplyMethod.__init__(self, mobject.scale_in_place, scale_factor, **kwargs)
|
ApplyMethod.__init__(self, mobject.scale_in_place, scale_factor, **kwargs)
|
||||||
|
|
||||||
class ApplyFunction(Transform):
|
class ApplyFunction(Transform):
|
||||||
def __init__(self, mobject, function, **kwargs):
|
def __init__(self, function, mobject, **kwargs):
|
||||||
Transform.__init__(
|
Transform.__init__(
|
||||||
self,
|
self,
|
||||||
mobject,
|
mobject,
|
||||||
@ -152,7 +152,7 @@ class ApplyPointwiseFunction(Transform):
|
|||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
"run_time" : DEFAULT_ANIMATION_RUN_TIME
|
"run_time" : DEFAULT_ANIMATION_RUN_TIME
|
||||||
}
|
}
|
||||||
def __init__(self, mobject, function, **kwargs):
|
def __init__(self, function, mobject, **kwargs):
|
||||||
digest_config(self, ApplyPointwiseFunction, kwargs)
|
digest_config(self, ApplyPointwiseFunction, kwargs)
|
||||||
map_image = copy.deepcopy(mobject)
|
map_image = copy.deepcopy(mobject)
|
||||||
map_image.points = np.array(map(function, map_image.points))
|
map_image.points = np.array(map(function, map_image.points))
|
||||||
@ -164,7 +164,7 @@ class ApplyPointwiseFunction(Transform):
|
|||||||
])
|
])
|
||||||
|
|
||||||
class ComplexFunction(ApplyPointwiseFunction):
|
class ComplexFunction(ApplyPointwiseFunction):
|
||||||
def __init__(self, mobject, function, **kwargs):
|
def __init__(self, function, mobject = ComplexPlane, **kwargs):
|
||||||
def point_map(point):
|
def point_map(point):
|
||||||
x, y, z = point
|
x, y, z = point
|
||||||
c = np.complex(x, y)
|
c = np.complex(x, y)
|
||||||
|
@ -163,9 +163,9 @@ class Scene(object):
|
|||||||
animation.clean_up()
|
animation.clean_up()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def apply(self, AnimationClass, *args, **kwargs):
|
def apply(self, mob_to_anim_func, **kwargs):
|
||||||
self.play(*[
|
self.play(*[
|
||||||
AnimationClass(mobject, *args, **kwargs)
|
mob_to_anim_func(mobject)
|
||||||
for mobject in self.mobjects
|
for mobject in self.mobjects
|
||||||
])
|
])
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user