mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Add a "clear" option for Mobjects
This not only sets the submobject list to 0, but removes self from the parent lists
This commit is contained in:
parent
f296dd8df5
commit
1a62314719
1 changed files with 10 additions and 2 deletions
|
@ -408,8 +408,13 @@ class Mobject(object):
|
|||
self.assemble_family()
|
||||
return self
|
||||
|
||||
def remove(self, *to_remove: Mobject, reassemble: bool = True):
|
||||
for parent in self.get_family():
|
||||
def remove(
|
||||
self,
|
||||
*to_remove: Mobject,
|
||||
reassemble: bool = True,
|
||||
recurse: bool = True
|
||||
):
|
||||
for parent in self.get_family(recurse):
|
||||
for child in to_remove:
|
||||
if child in parent.submobjects:
|
||||
parent.submobjects.remove(child)
|
||||
|
@ -419,6 +424,9 @@ class Mobject(object):
|
|||
parent.assemble_family()
|
||||
return self
|
||||
|
||||
def clear(self):
|
||||
self.remove(*self.submobjects, recurse=False)
|
||||
|
||||
def add_to_back(self, *mobjects: Mobject):
|
||||
self.set_submobjects(list_update(mobjects, self.submobjects))
|
||||
return self
|
||||
|
|
Loading…
Add table
Reference in a new issue