diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py index 350d0c1069..e657c9617c 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -1088,17 +1088,6 @@ def interpolate(self, mobject1, mobject2, def interpolate_color(self, mobject1, mobject2, alpha): raise NotImplementedError('Please override in a child class.') - def become_partial(self, mobject, a, b): - """ - Set points in such a way as to become only - part of mobject. - Inputs 0 <= a < b <= 1 determine what portion - of mobject to become. - """ - raise NotImplementedError('Please override in a child class.') - - # TODO, color? - def pointwise_become_partial(self, mobject, a, b): raise NotImplementedError('Please override in a child class.') @@ -1120,7 +1109,7 @@ def throw_error_if_no_points(self): "for a Mobject with no points" caller_name = sys._getframe(1).f_code.co_name raise Exception(message.format(caller_name)) - + # About z-index def set_z_index(self, z_index_value): """Sets the mobject's :attr:`z_index` to the value specified in `z_index_value`. @@ -1129,7 +1118,7 @@ def set_z_index(self, z_index_value): ---------- z_index_value : Union[:class:`int`, :class:`float`] The new value of :attr:`z_index` set. - + Returns ------- :class:`Mobject` @@ -1137,10 +1126,10 @@ def set_z_index(self, z_index_value): """ self.z_index = z_index_value return self - + def set_z_index_by_z_coordinate(self): """Sets the mobject's z coordinate to the value of :attr:`z_index`. - + Returns ------- :class:`Mobject` diff --git a/manim/mobject/value_tracker.py b/manim/mobject/value_tracker.py index 5872d7105e..f832c172ed 100644 --- a/manim/mobject/value_tracker.py +++ b/manim/mobject/value_tracker.py @@ -1,11 +1,12 @@ import numpy as np +from ..utils.paths import straight_path from ..mobject.mobject import Mobject class ValueTracker(Mobject): """ - Note meant to be displayed. Instead the position encodes some + Not meant to be displayed. Instead the position encodes some number, often one which another animation or continual_animation uses for its update function, and by treating it as a mobject it can still be animated and manipulated just like anything else. @@ -26,6 +27,17 @@ def set_value(self, value): def increment_value(self, d_value): self.set_value(self.get_value() + d_value) + def interpolate(self, mobject1, mobject2, + alpha, path_func=straight_path): + """ + Turns self into an interpolation between mobject1 + and mobject2. + """ + self.points = path_func( + mobject1.points, mobject2.points, alpha + ) + return self + class ExponentialValueTracker(ValueTracker): """