mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-05-21 20:46:01 +08:00
WIP: ThreeDSlide
This commit is contained in:
@ -9,7 +9,7 @@ from .defaults import FOLDER_PATH
|
||||
|
||||
class Slide(Scene):
|
||||
def __init__(self, *args, output_folder=FOLDER_PATH, **kwargs):
|
||||
super(Slide, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.output_folder = output_folder
|
||||
self.slides = list()
|
||||
self.current_slide = 1
|
||||
@ -18,16 +18,19 @@ class Slide(Scene):
|
||||
self.pause_start_animation = 0
|
||||
|
||||
def play(self, *args, **kwargs):
|
||||
super(Slide, self).play(*args, **kwargs)
|
||||
print("PLAY", *args, kwargs.items())
|
||||
super().play(*args, **kwargs)
|
||||
self.current_animation += 1
|
||||
|
||||
def pause(self):
|
||||
self.slides.append(dict(
|
||||
type="slide",
|
||||
start_animation=self.pause_start_animation,
|
||||
end_animation=self.current_animation,
|
||||
number=self.current_slide
|
||||
))
|
||||
self.slides.append(
|
||||
dict(
|
||||
type="slide",
|
||||
start_animation=self.pause_start_animation,
|
||||
end_animation=self.current_animation,
|
||||
number=self.current_slide,
|
||||
)
|
||||
)
|
||||
self.current_slide += 1
|
||||
self.pause_start_animation = self.current_animation
|
||||
|
||||
@ -36,13 +39,17 @@ class Slide(Scene):
|
||||
self.loop_start_animation = self.current_animation
|
||||
|
||||
def end_loop(self):
|
||||
assert self.loop_start_animation is not None, "You have to start a loop before ending it"
|
||||
self.slides.append(dict(
|
||||
type="loop",
|
||||
start_animation=self.loop_start_animation,
|
||||
end_animation=self.current_animation,
|
||||
number=self.current_slide
|
||||
))
|
||||
assert (
|
||||
self.loop_start_animation is not None
|
||||
), "You have to start a loop before ending it"
|
||||
self.slides.append(
|
||||
dict(
|
||||
type="loop",
|
||||
start_animation=self.loop_start_animation,
|
||||
end_animation=self.current_animation,
|
||||
number=self.current_slide,
|
||||
)
|
||||
)
|
||||
self.current_slide += 1
|
||||
self.loop_start_animation = None
|
||||
self.pause_start_animation = self.current_animation
|
||||
@ -52,7 +59,7 @@ class Slide(Scene):
|
||||
max_files_cached = config["max_files_cached"]
|
||||
config["max_files_cached"] = float("inf")
|
||||
|
||||
super(Slide, self).render(*args, **kwargs)
|
||||
super().render(*args, **kwargs)
|
||||
|
||||
config["max_files_cached"] = max_files_cached
|
||||
|
||||
@ -78,12 +85,10 @@ class Slide(Scene):
|
||||
shutil.copyfile(src_file, dst_file)
|
||||
files.append(dst_file)
|
||||
|
||||
f = open(os.path.join(self.output_folder, "%s.json" % (scene_name, )), "w")
|
||||
json.dump(dict(
|
||||
slides=self.slides,
|
||||
files=files
|
||||
), f)
|
||||
f = open(os.path.join(self.output_folder, "%s.json" % (scene_name,)), "w")
|
||||
json.dump(dict(slides=self.slides, files=files), f)
|
||||
f.close()
|
||||
|
||||
class ThreeDSlide(ThreeDScene, Slide):
|
||||
|
||||
class ThreeDSlide(Slide, ThreeDScene):
|
||||
pass
|
||||
|
Reference in New Issue
Block a user