Allow animations with run_time=0
and implement convenience Add
animation
#4017
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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