Fix: Axes submobject colors are not being set properly
#4291
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?
Mitigates the issue, that setting the color of a DecimalNumber object to BLACK will actually render a number with WHITE fill.
Further details about the issue can be found on the issue itself #3633
Motivation and Explanation: Why and how do your changes improve the library?
Root Cause:
The method
get_fill_colorstreats the RGBA value[0, 0, 0, 0](fully transparent black) as equivalent toNone.As a result, during the initialization of certain objects, the
fill_coloris effectively set toNone, while in other cases it defaults toWHITE.Therefore, when we explicitly set
fill_colortoBLACK, it ends up being interpreted asWHITEdue to this inconsistency.The code that interprets [0,0,0,0] as None can be found here:
manim/manim/mobject/types/vectorized_mobject.py
Lines 566 to 573 in 3377f6c
Mitigation:
Initialize the
VMobjectwith afill_opacityvalue from the input parameters (which defaults to1for aDecimalNumberobject). This ensures thefill_coloris applied correctly.By default,
fill_opacityis0for aVMobject, which causes the internalfill_colorto be[0, 0, 0, 0](interpreted asNone) even whenBLACKis specified.Setting
fill_opacity = 1ensures that thefill_coloris preserved asBLACKas intended.Note:
This is a workaround. The underlying issue is that a
fill_colorofBLACKis effectively ignored whenfill_opacity = 0, due to its[0, 0, 0, 0]representation.We should investigate whether this behavior is expected or a design flaw, and address it in a separate issue.
Reviewer Checklist