Repository navigation
Keep submobject opacity in ShowIncreasingSubsets and its subclasses - #5117
Open
Thanatos9404 wants to merge 1 commit into
Open
Thanatos9404 wants to merge 1 commit into
Thanatos9404 wants to merge 1 commit into
Conversation
ShowIncreasingSubsets hid each submobject with set_opacity(0) and showed it again with set_opacity(1), so a translucent submobject ended up fully opaque. Record each submobject's fill and stroke opacities before hiding it and restore them when it is shown. ShowSubmobjectsOneByOne, AddTextLetterByLetter and TypeWithCursor use the same code. The opacities are recorded again in begin() when another animation has shown the submobjects since, for example the previous one in a Succession, and a submobject that is still fully transparent is shown at full opacity as before. Fixes ManimCommunity#3424.
This branch has not been deployed
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.
Overview: What does this pull request change?
Fixed :class:
.ShowIncreasingSubsets, :class:.ShowSubmobjectsOneByOne, :class:.AddTextLetterByLetterand :class:.TypeWithCursormaking translucent submobjects fully opaque.Motivation and Explanation: Why and how do your changes improve the library?
Fixes #3424. These animations hide submobjects with
set_opacity(0)and show them withset_opacity(1), so a square withfill_opacity=0.2ends the animation fully opaque.The animation now records each submobject's fill and stroke opacities before hiding it, for every member of its family (also the background stroke for Cairo
VMobjects). It restores those values when the submobject is shown. Anything that is not a vectorized mobject still usesset_opacity(1), as before:ImageMobject.set_opacityis already relative to its own alpha.I did not use
save_state()/restore()from the issue, because it would overwrite a state the user saved and also restore positions.Two details:
Succession(AddTextLetterByLetter(t), RemoveTextLetterByLetter(t)), the second animation is created while the first has already hidden the text. So the opacities are recorded again inbegin()once the submobjects are visible again. A submobject that is fully transparent when recorded falls back to opacity 1, as before.ease_out_back) still work, because the shown submobjects are taken from a slice as before.The cursor of
TypeWithCursoris unchanged: it is still shown at opacity 1.Links to added or changed documentation pages
None.
Further Information and Comments
Tests in
tests/module/animation/test_creation.pycover the four animations, two animations built back to back, an overshooting rate function, and the restoredfill_opacityattribute. They fail on main.The rest of the suite gives the same results with and without this change. I don't have LaTeX installed, so the TeX tests fail locally on both. pre-commit passes.
Reviewer Checklist