Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Feature: Scene.wait_to(time) Can be useful for audio fitting, ignored in preview

mirefek7f97616c426b
diff --git a/extract_scene.py b/extract_scene.py
index 2580ac8f8..66c9f4d6d 100644
--- a/extract_scene.py
+++ b/extract_scene.py
@@ -85,6 +85,7 @@ def get_configuration():
#If -t is passed in (for transparent), this will be RGBA
"saved_image_mode": "RGBA" if args.transparent else "RGB",
"quiet" : args.quiet or args.write_all,
+ "ignore_waits" : args.preview,
"write_all" : args.write_all,
"output_name" : args.output_name,
"skip_to_animation_number" : args.skip_to_animation_number,
diff --git a/scene/scene.py b/scene/scene.py
index fbf2d2ff2..1f0afc725 100644
--- a/scene/scene.py
+++ b/scene/scene.py
@@ -28,6 +28,7 @@ class Scene(object):
"frame_duration" : LOW_QUALITY_FRAME_DURATION,
"construct_args" : [],
"skip_animations" : False,
+ "ignore_waits" : False,
"write_to_movie" : False,
"save_frames" : False,
"save_pngs" : False,
@@ -49,6 +50,7 @@ class Scene(object):
self.saved_frames = []
self.shared_locals = {}
self.frame_num = 0
+ self.current_scene_time = 0
if self.name is None:
self.name = self.__class__.__name__
if self.random_seed is not None:
@@ -465,6 +467,7 @@ class Scene(object):
return self
def add_frames(self, *frames):
+ self.current_scene_time += len(frames)*self.frame_duration
if self.write_to_movie:
for frame in frames:
if self.save_pngs:
@@ -551,6 +554,10 @@ class Scene(object):
else:
os.rename(*self.args_to_rename_file)
+ def wait_to(self, time, assert_positive = True):
+ if self.ignore_waits: return
+ time -= self.current_scene_time
+ if assert_positive: assert(time >= 0)
+ elif time < 0: return
-
-
+ self.dither(time)