docs: add explanation about the rate_func in the custom animation #4278
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.
Overview: What does this pull request change?
Fixes #4031
Change code snipped to “Creating a custom animation” page in documentation
In detail:
rate_func
parameter to work in a custom animation.Motivation and Explanation: Why and how do your changes improve the library?
The code snippet provided in the current documentation contains a parameter that does not influence the behavior of the generated animation. The segment
rate_func=linear
in the line of codeself.play(Count(number, 0, 100), run_time=4, rate_func=linear)
can be modified or removed, as it does not affect the animation produced in the example.For the animation style (speed curves for animations) to be effectively modified by the parameter, it is required to invoke
self.rate_func()
on thealpha
value. This allows the animation style to be altered through therate_func
parameter in theself.play()
method.Links to added or changed documentation pages
Manim’s building blocks > Creating a custom animation
Further Information and Comments
The difficulty arises because the
rate_func
is implemented within theinterpolate_object
method. When this method is overridden, the call torate_func
is omitted. Therefore, passingrate_func
as an argument to a custom animation has no effect. By includingself.rate_func(alpha)
, the variation function is applied to thealpha
value, causing it to vary according to the specified function.Reviewer Checklist