Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

change Scene.apply to take in mob_to_anim function instead of Animation class

Grant Sandersonc95f31385e2c
diff --git a/animation/transform.py b/animation/transform.py
index 1f3907cf4..a077d0d14 100644
--- a/animation/transform.py
+++ b/animation/transform.py
@@ -5,7 +5,7 @@ import copy
import warnings
from animation import Animation
-from mobject import Mobject, Point
+from mobject import Mobject, Point, ComplexPlane
from constants import *
from helpers import *
@@ -139,7 +139,7 @@ class ScaleInPlace(ApplyMethod):
ApplyMethod.__init__(self, mobject.scale_in_place, scale_factor, **kwargs)
class ApplyFunction(Transform):
- def __init__(self, mobject, function, **kwargs):
+ def __init__(self, function, mobject, **kwargs):
Transform.__init__(
self,
mobject,
@@ -152,7 +152,7 @@ class ApplyPointwiseFunction(Transform):
DEFAULT_CONFIG = {
"run_time" : DEFAULT_ANIMATION_RUN_TIME
}
- def __init__(self, mobject, function, **kwargs):
+ def __init__(self, function, mobject, **kwargs):
digest_config(self, ApplyPointwiseFunction, kwargs)
map_image = copy.deepcopy(mobject)
map_image.points = np.array(map(function, map_image.points))
@@ -164,7 +164,7 @@ class ApplyPointwiseFunction(Transform):
])
class ComplexFunction(ApplyPointwiseFunction):
- def __init__(self, mobject, function, **kwargs):
+ def __init__(self, function, mobject = ComplexPlane, **kwargs):
def point_map(point):
x, y, z = point
c = np.complex(x, y)
diff --git a/scene/scene.py b/scene/scene.py
index 5d27ff577..9da4bcd33 100644
--- a/scene/scene.py
+++ b/scene/scene.py
@@ -163,9 +163,9 @@ class Scene(object):
animation.clean_up()
return self
- def apply(self, AnimationClass, *args, **kwargs):
+ def apply(self, mob_to_anim_func, **kwargs):
self.play(*[
- AnimationClass(mobject, *args, **kwargs)
+ mob_to_anim_func(mobject)
for mobject in self.mobjects
])