From 979cd3a38f91b800fd9834dfbbcbdc6885bdbf71 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Sat, 25 Aug 2018 18:31:41 -0700 Subject: [PATCH] Add copy_submobjects option to Mobject.become --- mobject/mobject.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mobject/mobject.py b/mobject/mobject.py index 4fe733ee..5bb034b5 100644 --- a/mobject/mobject.py +++ b/mobject/mobject.py @@ -854,11 +854,11 @@ class Mobject(Container): submob.shuffle_submobjects(recursive=True) random.shuffle(self.submobjects) - def print_get_family(self, n_tabs=0): + def print_submobject_family(self, n_tabs=0): """For debugging purposes""" print("\t" * n_tabs, self, id(self)) for submob in self.submobjects: - submob.print_get_family(n_tabs + 1) + submob.print_submobject_family(n_tabs + 1) # Alignment def align_data(self, mobject): @@ -972,14 +972,18 @@ class Mobject(Container): def pointwise_become_partial(self, mobject, a, b): pass # To implement in subclass - def become(self, mobject): + def become(self, mobject, copy_submobjects=True): """ Edit points, colors and submobjects to be idential to another mobject """ self.align_points(mobject) 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):