mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Add copy_submobjects option to Mobject.become
This commit is contained in:
parent
817fa065c4
commit
979cd3a38f
1 changed files with 8 additions and 4 deletions
|
@ -854,11 +854,11 @@ class Mobject(Container):
|
||||||
submob.shuffle_submobjects(recursive=True)
|
submob.shuffle_submobjects(recursive=True)
|
||||||
random.shuffle(self.submobjects)
|
random.shuffle(self.submobjects)
|
||||||
|
|
||||||
def print_get_family(self, n_tabs=0):
|
def print_submobject_family(self, n_tabs=0):
|
||||||
"""For debugging purposes"""
|
"""For debugging purposes"""
|
||||||
print("\t" * n_tabs, self, id(self))
|
print("\t" * n_tabs, self, id(self))
|
||||||
for submob in self.submobjects:
|
for submob in self.submobjects:
|
||||||
submob.print_get_family(n_tabs + 1)
|
submob.print_submobject_family(n_tabs + 1)
|
||||||
|
|
||||||
# Alignment
|
# Alignment
|
||||||
def align_data(self, mobject):
|
def align_data(self, mobject):
|
||||||
|
@ -972,14 +972,18 @@ class Mobject(Container):
|
||||||
def pointwise_become_partial(self, mobject, a, b):
|
def pointwise_become_partial(self, mobject, a, b):
|
||||||
pass # To implement in subclass
|
pass # To implement in subclass
|
||||||
|
|
||||||
def become(self, mobject):
|
def become(self, mobject, copy_submobjects=True):
|
||||||
"""
|
"""
|
||||||
Edit points, colors and submobjects to be idential
|
Edit points, colors and submobjects to be idential
|
||||||
to another mobject
|
to another mobject
|
||||||
"""
|
"""
|
||||||
self.align_points(mobject)
|
self.align_points(mobject)
|
||||||
self.interpolate(self, mobject, 1)
|
self.interpolate(self, mobject, 1)
|
||||||
self.submobjects = [sm.copy() for sm in mobject.submobjects]
|
self.submobjects = [
|
||||||
|
sm.copy() if copy_submobjects else sm
|
||||||
|
for sm in mobject.submobjects
|
||||||
|
]
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
class Group(Mobject):
|
class Group(Mobject):
|
||||||
|
|
Loading…
Add table
Reference in a new issue