mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Allow for saving and loading mobjects from file at the Scene level
This commit is contained in:
parent
97400a5cf2
commit
777b6d3778
1 changed files with 13 additions and 0 deletions
|
@ -588,6 +588,19 @@ class Scene(object):
|
|||
mob.become(mob_state)
|
||||
self.mobjects.append(mob)
|
||||
|
||||
def save_mobect(self, mobject: Mobject, file_name: str):
|
||||
directory = self.file_writer.get_saved_mobject_directory()
|
||||
path = os.path.join(directory, file_name)
|
||||
mobject.save_to_file(path)
|
||||
|
||||
def load_mobject(self, file_name):
|
||||
if os.path.exists(file_name):
|
||||
path = file_name
|
||||
else:
|
||||
directory = self.file_writer.get_saved_mobject_directory()
|
||||
path = os.path.join(directory, file_name)
|
||||
return Mobject.load(path)
|
||||
|
||||
# Event handling
|
||||
|
||||
def on_mouse_motion(
|
||||
|
|
Loading…
Add table
Reference in a new issue