Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

update_submobject -> interpolate_submobject

Grant Sandersonbf738b70d74f
diff --git a/manimlib/animation/animation.py b/manimlib/animation/animation.py
index 5896dc154..e7cd2f033 100644
--- a/manimlib/animation/animation.py
+++ b/manimlib/animation/animation.py
@@ -57,7 +57,7 @@ class Animation(object):
digest_config(self, kwargs)
return self
- def update_mobjects_alt(self, dt):
+ def update_mobjects(self, dt):
for mob in self.get_all_mobjects():
mob.update(dt)
@@ -69,7 +69,11 @@ class Animation(object):
families = self.get_all_families_zipped()
for i, mobs in enumerate(families):
sub_alpha = self.get_sub_alpha(alpha, i, len(families))
- self.update_submobject(*mobs, sub_alpha)
+ self.interpolate_submobject(*mobs, sub_alpha)
+
+ def interpolate_submobject(self, submobject, starting_sumobject, alpha):
+ # Typically ipmlemented by subclass
+ pass
def get_sub_alpha(self, alpha, index, num_submobjects):
if self.submobject_mode in ["lagged_start", "smoothed_lagged_start"]:
@@ -86,13 +90,9 @@ class Animation(object):
return alpha
raise Exception("Invalid submobject mode")
- def update_submobject(self, submobject, starting_sumobject, alpha):
- # Typically ipmlemented by subclass
- pass
-
def get_all_mobjects(self):
"""
- Ordering must match the ording of arguments to update_submobject
+ Ordering must match the ording of arguments to interpolate_submobject
"""
return self.mobject, self.starting_mobject
diff --git a/manimlib/animation/creation.py b/manimlib/animation/creation.py
index e54dfd365..251a5ce45 100644
--- a/manimlib/animation/creation.py
+++ b/manimlib/animation/creation.py
@@ -16,7 +16,7 @@ from manimlib.utils.rate_functions import smooth
class ShowPartial(Animation):
- def update_submobject(self, submobject, starting_submobject, alpha):
+ def interpolate_submobject(self, submobject, starting_submobject, alpha):
submobject.pointwise_become_partial(
starting_submobject, *self.get_bounds(alpha)
)
@@ -55,7 +55,7 @@ class DrawBorderThenFill(Animation):
self.reached_halfway_point_before = False
Animation.__init__(self, vmobject, **kwargs)
- def update_submobject(self, submobject, starting_submobject, alpha):
+ def interpolate_submobject(self, submobject, starting_submobject, alpha):
submobject.pointwise_become_partial(
starting_submobject, 0, min(2 * alpha, 1)
)
@@ -215,7 +215,7 @@ class VFadeIn(Animation):
then) in a way that does not work with FadeIn and FadeOut
"""
- def update_submobject(self, submobject, starting_submobject, alpha):
+ def interpolate_submobject(self, submobject, starting_submobject, alpha):
submobject.set_stroke(
opacity=interpolate(0, starting_submobject.get_stroke_opacity(), alpha)
)
@@ -229,8 +229,8 @@ class VFadeOut(VFadeIn):
"remover": True
}
- def update_submobject(self, submobject, starting_submobject, alpha):
- VFadeIn.update_submobject(
+ def interpolate_submobject(self, submobject, starting_submobject, alpha):
+ VFadeIn.interpolate_submobject(
self, submobject, starting_submobject, 1 - alpha
)
diff --git a/manimlib/animation/indication.py b/manimlib/animation/indication.py
index d824aed9e..04e46b7bb 100644
--- a/manimlib/animation/indication.py
+++ b/manimlib/animation/indication.py
@@ -236,7 +236,7 @@ class WiggleOutThenIn(Animation):
self.rotate_about_point = mobject.get_center()
Animation.__init__(self, mobject, **kwargs)
- def update_submobject(self, submobject, starting_sumobject, alpha):
+ def interpolate_submobject(self, submobject, starting_sumobject, alpha):
submobject.points[:, :] = starting_sumobject.points
submobject.scale(
interpolate(1, self.scale_value, there_and_back(alpha)),
diff --git a/manimlib/animation/movement.py b/manimlib/animation/movement.py
index ca5a9d0f5..6e7d4428d 100644
--- a/manimlib/animation/movement.py
+++ b/manimlib/animation/movement.py
@@ -20,7 +20,7 @@ class Homotopy(Animation):
digest_config(self, kwargs)
Animation.__init__(self, mobject, **kwargs)
- def update_submobject(self, submob, start, alpha):
+ def interpolate_submobject(self, submob, start, alpha):
submob.points = start.points
submob.apply_function(
self.function_at_time_t(alpha),
@@ -29,8 +29,8 @@ class Homotopy(Animation):
class SmoothedVectorizedHomotopy(Homotopy):
- def update_submobject(self, submob, start, alpha):
- Homotopy.update_submobject(self, submob, start, alpha)
+ def interpolate_submobject(self, submob, start, alpha):
+ Homotopy.interpolate_submobject(self, submob, start, alpha)
submob.make_smooth()
diff --git a/manimlib/animation/rotation.py b/manimlib/animation/rotation.py
index 022d11778..de1674cbe 100644
--- a/manimlib/animation/rotation.py
+++ b/manimlib/animation/rotation.py
@@ -18,7 +18,7 @@ class Rotating(Animation):
"about_edge": None,
}
- def update_submobject(self, submobject, starting_submobject, alpha):
+ def interpolate_submobject(self, submobject, starting_submobject, alpha):
submobject.points = np.array(starting_submobject.points)
def interpolate_mobject(self, alpha):
diff --git a/manimlib/animation/transform.py b/manimlib/animation/transform.py
index 13bc7bff4..0619ba60a 100644
--- a/manimlib/animation/transform.py
+++ b/manimlib/animation/transform.py
@@ -80,7 +80,7 @@ class Transform(Animation):
def get_all_mobjects(self):
return self.mobject, self.starting_mobject, self.target_mobject
- def update_submobject(self, submob, start, end, alpha):
+ def interpolate_submobject(self, submob, start, end, alpha):
submob.interpolate(start, end, alpha, self.path_func)
return self
diff --git a/old_projects/WindingNumber.py b/old_projects/WindingNumber.py
index af5855389..9b7a4c3a8 100644
--- a/old_projects/WindingNumber.py
+++ b/old_projects/WindingNumber.py
@@ -539,7 +539,7 @@ class WalkerAnimation(Animation):
Animation.__init__(self, self.compound_walker, **kwargs)
# Perhaps abstract this out into an "Animation updating from original object" class
- def update_submobject(self, submobject, starting_submobject, alpha):
+ def interpolate_submobject(self, submobject, starting_submobject, alpha):
submobject.points = np.array(starting_submobject.points)
def interpolate_mobject(self, alpha):
@@ -1315,7 +1315,7 @@ class FuncRotater(Animation):
}
# Perhaps abstract this out into an "Animation updating from original object" class
- def update_submobject(self, submobject, starting_submobject, alpha):
+ def interpolate_submobject(self, submobject, starting_submobject, alpha):
submobject.points = np.array(starting_submobject.points)
def interpolate_mobject(self, alpha):
diff --git a/old_projects/efvgt.py b/old_projects/efvgt.py
index 3273bccd5..49b8db666 100644
--- a/old_projects/efvgt.py
+++ b/old_projects/efvgt.py
@@ -50,7 +50,7 @@ class ConfettiSpiril(Animation):
Animation.__init__(self, mobject, **kwargs)
- def update_submobject(self, submobject, starting_submobject, alpha):
+ def interpolate_submobject(self, submobject, starting_submobject, alpha):
submobject.points = np.array(starting_submobject.points)
def interpolate_mobject(self, alpha):