From 6ff937e89385e7f84d78861efcf3be6d666c7fcd Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Tue, 20 Feb 2018 17:50:39 -0800 Subject: [PATCH] Fixed one-off error for number of frames rendered during an animation, and made it so that a final frame is always rendered after the construct method is called --- scene/scene.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scene/scene.py b/scene/scene.py index cc5c386a..5d7a0862 100644 --- a/scene/scene.py +++ b/scene/scene.py @@ -68,6 +68,12 @@ class Scene(Container): self.construct(*self.construct_args) except EndSceneEarlyException: pass + + # Always tack on one last frame, so that scenes + # with no play calls still display something + self.skip_animations = False + self.wait(self.frame_duration) + if self.write_to_movie: self.close_movie_pipe() print("Played a total of %d animations"%self.num_plays) @@ -340,7 +346,7 @@ class Scene(Container): times = [run_time] else: step = self.frame_duration - times = np.arange(0, run_time + step, step) + times = np.arange(0, run_time, step) time_progression = ProgressDisplay(times) return time_progression @@ -475,13 +481,12 @@ class Scene(Container): self.continual_update() self.update_frame() self.add_frames(self.get_frame()) - elif not self.skip_animations: + elif self.skip_animations: + #Do nothing + return self + else: self.update_frame() self.add_frames(*[self.get_frame()]*int(duration / self.frame_duration)) - else: - #If self.skip_animations is set, do nothing - pass - return self def wait_to(self, time, assert_positive = True): @@ -602,7 +607,6 @@ class Scene(Container): class EndSceneEarlyException(Exception): pass -