Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Minor cleanup to animation/update.py

Grant Sanderson92eaa733cdf9
diff --git a/manimlib/animation/update.py b/manimlib/animation/update.py
index 89b88c32f..57856a2ff 100644
--- a/manimlib/animation/update.py
+++ b/manimlib/animation/update.py
@@ -1,6 +1,6 @@
+import operator as op
+
from manimlib.animation.animation import Animation
-from manimlib.constants import *
-from manimlib.utils.config_ops import digest_config
class UpdateFromFunc(Animation):
@@ -9,10 +9,13 @@ class UpdateFromFunc(Animation):
to be used when the state of one mobject is dependent
on another simultaneously animated mobject
"""
+ CONFIG = {
+ "suspend_mobject_updating": False,
+ }
def __init__(self, mobject, update_function, **kwargs):
- digest_config(self, kwargs, locals())
- Animation.__init__(self, mobject, **kwargs)
+ self.update_function = update_function
+ super().__init__(mobject, **kwargs)
def interpolate_mobject(self, alpha):
self.update_function(self.mobject)
@@ -24,18 +27,15 @@ class UpdateFromAlphaFunc(UpdateFromFunc):
class MaintainPositionRelativeTo(Animation):
- CONFIG = {
- "tracked_critical_point": ORIGIN
- }
-
def __init__(self, mobject, tracked_mobject, **kwargs):
- digest_config(self, kwargs, locals())
- tcp = self.tracked_critical_point
- self.diff = mobject.get_critical_point(tcp) - \
- tracked_mobject.get_critical_point(tcp)
- Animation.__init__(self, mobject, **kwargs)
+ self.tracked_mobject = tracked_mobject
+ self.diff = op.sub(
+ mobject.get_center(),
+ tracked_mobject.get_center(),
+ )
+ super().__init__(mobject, **kwargs)
def interpolate_mobject(self, alpha):
- target = self.tracked_mobject.get_critical_point(self.tracked_critical_point)
- location = self.mobject.get_critical_point(self.tracked_critical_point)
+ target = self.tracked_mobject.get_center()
+ location = self.mobject.get_center()
self.mobject.shift(target - location + self.diff)