Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions manim/mobject/mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.')

Expand All @@ -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`.
Expand All @@ -1129,18 +1118,18 @@ 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`
The Mobject itself, after :attr:`z_index` is set. (Returns `self`.)
"""
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`
Expand Down
14 changes: 13 additions & 1 deletion manim/mobject/value_tracker.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.
"""
Comment on lines +32 to +35
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to comment about documentation guidelines, but I guess we can just copy the interpolate docs from when we finish them from Mobject into this, so should be ok

self.points = path_func(
mobject1.points, mobject2.points, alpha
)
return self


class ExponentialValueTracker(ValueTracker):
"""
Expand Down