Skip to content

Conversation

@ishu9bansal
Copy link
Contributor

@ishu9bansal ishu9bansal commented Jun 20, 2025

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_colors treats the RGBA value [0, 0, 0, 0] (fully transparent black) as equivalent to None.
As a result, during the initialization of certain objects, the fill_color is effectively set to None, while in other cases it defaults to WHITE.
Therefore, when we explicitly set fill_color to BLACK, it ends up being interpreted as WHITE due to this inconsistency.

The code that interprets [0,0,0,0] as None can be found here:

# TODO: Does this just do a copy?
# TODO: I have the feeling that this function should not return None, does that have any usage ?
def get_fill_colors(self) -> list[ManimColor | None]:
return [
ManimColor(rgba[:3]) if rgba.any() else None
for rgba in self.get_fill_rgbas()
]

Mitigation:
Initialize the VMobject with a fill_opacity value from the input parameters (which defaults to 1 for a DecimalNumber object). This ensures the fill_color is applied correctly.
By default, fill_opacity is 0 for a VMobject, which causes the internal fill_color to be [0, 0, 0, 0] (interpreted as None) even when BLACK is specified.
Setting fill_opacity = 1 ensures that the fill_color is preserved as BLACK as intended.

Note:
This is a workaround. The underlying issue is that a fill_color of BLACK is effectively ignored when fill_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

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

Copy link
Member

@behackl behackl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workaround seems fine to me, thank you.

@github-project-automation github-project-automation bot moved this from 🆕 New to 👍 To be merged in Dev Board Jun 21, 2025
@behackl behackl linked an issue Jun 21, 2025 that may be closed by this pull request
@behackl behackl merged commit 23a2df1 into ManimCommunity:main Jun 21, 2025
22 checks passed
@github-project-automation github-project-automation bot moved this from 👍 To be merged to ✅ Done in Dev Board Jun 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Axes and its submobjects does not respect passed colors

2 participants