diff --git a/manim/renderer/cairo_renderer.py b/manim/renderer/cairo_renderer.py index b97fa50299..0b13fb8638 100644 --- a/manim/renderer/cairo_renderer.py +++ b/manim/renderer/cairo_renderer.py @@ -252,13 +252,13 @@ def update_skipping_status(self): if config["save_last_frame"]: self.skip_animations = True if ( - config["from_animation_number"] - and self.num_plays < config["from_animation_number"] + config.from_animation_number > 0 + and self.num_plays < config.from_animation_number ): self.skip_animations = True if ( - config["upto_animation_number"] - and self.num_plays > config["upto_animation_number"] + config.upto_animation_number >= 0 + and self.num_plays > config.upto_animation_number ): self.skip_animations = True raise EndSceneEarlyException() diff --git a/manim/renderer/opengl_renderer.py b/manim/renderer/opengl_renderer.py index ead0d0d82b..2f0ad398fe 100644 --- a/manim/renderer/opengl_renderer.py +++ b/manim/renderer/opengl_renderer.py @@ -400,13 +400,13 @@ def update_skipping_status(self): if self.file_writer.sections[-1].skip_animations: self.skip_animations = True if ( - config["from_animation_number"] - and self.num_plays < config["from_animation_number"] + config.from_animation_number > 0 + and self.num_plays < config.from_animation_number ): self.skip_animations = True if ( - config["upto_animation_number"] - and self.num_plays > config["upto_animation_number"] + config.upto_animation_number >= 0 + and self.num_plays > config.upto_animation_number ): self.skip_animations = True raise EndSceneEarlyException() diff --git a/tests/test_config.py b/tests/test_config.py index a245f4027a..0703b31bf4 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -244,3 +244,24 @@ def test_tex_template_file(tmp_path): assert Path(custom_config.tex_template_file) == tex_file assert custom_config.tex_template.body == "Hello World!" + + +def test_from_to_animations_only_first_animation(config): + config: ManimConfig + config.from_animation_number = 0 + config.upto_animation_number = 0 + + class SceneWithTwoAnimations(Scene): + def construct(self): + self.after_first_animation = False + s = Square() + self.add(s) + self.play(s.animate.scale(2)) + self.renderer.update_skipping_status() + self.after_first_animation = True + self.play(s.animate.scale(2)) + + scene = SceneWithTwoAnimations() + scene.render() + + assert scene.after_first_animation is False