fix(animation): time_span doesn't work for mobjects with submobjects#2147
Merged
3b1b merged 2 commits into3b1b:masterfrom Aug 26, 2024
Merged
fix(animation): time_span doesn't work for mobjects with submobjects#21473b1b merged 2 commits into3b1b:masterfrom
time_span doesn't work for mobjects with submobjects#21473b1b merged 2 commits into3b1b:masterfrom
Conversation
Owner
|
Good fix, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation / 修改原因
time_spandoesn't work for animations of mobjects with submobjects, such asDashedLine.像
DashedLine这样含有多个子物件的图形的动画无法正确处理time_span。Proposed changes / 修改内容
time_spanned_alphainAnimationto calculate the animation progress instead of changingrate_funcwhenbeginis called在
Animation类中添加了计算动画进度的方法time_spanned_alpha,专门用来计算存在time_span时的动画进度,而不在调用begin时改变rate_funcRotatingalso usesrate_functo decide the animation progress ininterpolate_mobject, changes ofrotation.pyare made to correspond由于
Rotating类的interpolate_mobject也是用rate_func计算动画进度,为了保持一致还修改了rotation.pyTest / 测试
Code / 代码:
We hope the dashed line on the right side start to show later than the solid line on the left side.
右侧动画应比左侧晚开始。
Result / 结果:


After this change: (obviously the right one start later)
修改后:(右侧动画开始更晚)
Before this change: (two animations seem to start at the same time)
修改前:(两侧动画几乎同时开始)