This PR refactors the Animation.run_time validation. Instead of checking in Animation.begin() that each individual animation has a positive run_time which is large enough for the current frame rate, we now have the following:
Animation.run_time is now a property that only checks that the given value is not negative. A run_time of 0 is allowed.
validate_run_time, originally a function defined in manim.animation.animation, is now a Scene class method, because it's now called only inside other Scene methods. Instead of it being called inside Animation.begin() to validate the run_time of a single animation, it's now called inside Scene.get_run_time() to validate the total obtained run time. This is the one which is not allowed to be 0. If it's too small for the current frame rate, it will be enlarged. Individual animations will not be affected.
This PR also introduces a convenience animation: Add. It is similar to Scene.add, but it's an animation which can be grouped inside other animations and has a default run_time of 0. Thus, if people needs to instantly add Mobjects in the middle of an animation, they can now do so in an easier way.
Closes #4004
This PR refactors the
Animation.run_time
validation. Instead of checking inAnimation.begin()
that each individual animation has a positiverun_time
which is large enough for the current frame rate, we now have the following:Animation.run_time
is now a property that only checks that the given value is not negative. Arun_time
of 0 is allowed.validate_run_time
, originally a function defined inmanim.animation.animation
, is now aScene
class method, because it's now called only inside otherScene
methods. Instead of it being called insideAnimation.begin()
to validate therun_time
of a single animation, it's now called insideScene.get_run_time()
to validate the total obtained run time. This is the one which is not allowed to be 0. If it's too small for the current frame rate, it will be enlarged. Individual animations will not be affected.This PR also introduces a convenience animation:
Add
. It is similar toScene.add
, but it's an animation which can be grouped inside other animations and has a defaultrun_time
of 0. Thus, if people needs to instantly addMobject
s in the middle of an animation, they can now do so in an easier way.Examples for using
Add
are also provided in the documentation: https://manimce--4017.org.readthedocs.build/en/4017/reference/manim.animation.animation.Add.htmlReviewer Checklist