mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Added ShowSubmobjectsOneByOne
This commit is contained in:
parent
ffecd03cb2
commit
307ac852a6
1 changed files with 17 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
from manimlib.animation.animation import Animation
|
||||
from manimlib.mobject.types.vectorized_mobject import VMobject
|
||||
from manimlib.mobject.mobject import Group
|
||||
from manimlib.utils.bezier import integer_interpolate
|
||||
from manimlib.utils.config_ops import digest_config
|
||||
from manimlib.utils.rate_functions import linear
|
||||
|
@ -132,4 +133,20 @@ class ShowIncreasingSubsets(Animation):
|
|||
def interpolate_mobject(self, alpha):
|
||||
n_submobs = len(self.all_submobs)
|
||||
index = int(self.int_func(alpha * n_submobs))
|
||||
self.update_submobject_list(index)
|
||||
|
||||
def update_submobject_list(self, index):
|
||||
self.mobject.submobjects = self.all_submobs[:index]
|
||||
|
||||
|
||||
class ShowSubmobjectsOneByOne(ShowIncreasingSubsets):
|
||||
def __init__(self, group, **kwargs):
|
||||
new_group = Group(*group)
|
||||
super().__init__(new_group, **kwargs)
|
||||
|
||||
def update_submobject_list(self, index):
|
||||
# N = len(self.all_submobs)
|
||||
if index == 0:
|
||||
self.mobject.submobjects = []
|
||||
else:
|
||||
self.mobject.submobjects = self.all_submobs[index - 1]
|
||||
|
|
Loading…
Add table
Reference in a new issue