mirror of
https://github.com/3b1b/manim.git
synced 2025-08-19 21:08:53 +00:00
Add functionality for recovering mobjects from their ids (to enable copying and pasting)
This commit is contained in:
parent
fdeab8ca95
commit
cb768c26a0
1 changed files with 19 additions and 0 deletions
|
@ -295,6 +295,25 @@ class Scene(object):
|
|||
return mobject
|
||||
return None
|
||||
|
||||
def get_group(self, *mobjects):
|
||||
if all(isinstance(m, VMobject) for m in mobjects):
|
||||
return VGroup(*mobjects)
|
||||
else:
|
||||
return Group(*mobjects)
|
||||
|
||||
def id_to_mobject(self, id_value):
|
||||
for mob in self.mobjects:
|
||||
for sm in mob.get_family():
|
||||
if id(sm) == id_value:
|
||||
return sm
|
||||
return None
|
||||
|
||||
def ids_to_group(self, *id_values):
|
||||
return self.get_group(*filter(
|
||||
lambda x: x is not None,
|
||||
map(self.id_to_mobject, id_values)
|
||||
))
|
||||
|
||||
# Related to skipping
|
||||
def update_skipping_status(self) -> None:
|
||||
if self.start_at_animation_number is not None:
|
||||
|
|
Loading…
Add table
Reference in a new issue