-
Couldn't load subscription status.
- Fork 2.5k
Deprecate color enum usage and change constants from `str to type Color
#2606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate color enum usage and change constants from `str to type Color
#2606
Conversation
* Converts values in setting_args dict in _get_settings_from_t2xs to string to make sure that all values are of type string. * Makes color constants instances of Color-class from colour-module and updates color_gradient to handle gradient with one color, fixes #7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your work! Other than some minor typehint problems, I think this is good to go.
| self, | ||
| mobject, | ||
| color: Colors | None = None, | ||
| color: str | None = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| color: str | None = None, | |
| color: Color | str | None = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure that a color object would work fine here too.
| # Background rectangle | ||
| def add_background_rectangle( | ||
| self, color: Optional[Colors] = None, opacity: float = 0.75, **kwargs | ||
| self, color: str = None, opacity: float = 0.75, **kwargs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| self, color: str = None, opacity: float = 0.75, **kwargs | |
| self, color: Color | str | None = None, opacity: float = 0.75, **kwargs |
|
@BrorSebastianSjovald @ludwigjo any updates here? |
|
Closing this for now. Making Colors the main source of truth again with exporting constants shouldn't break anything. |
Overview: What does this pull request change?
This PR improves the color handling by deprecating uses of the Colors class and replace usage of the Enums with color constants as specified in #2451 . At this point, a deprecation warning is raised when trying to use the Colors class using
manim.utils.deprecation.Motivation and Explanation: Why and how do your changes improve the library?
The overall goal is to simplify the use of color by standardizing the approach as stated in #2451 . By deprecating the use of the Enums and providing a way of using the constants in a similar way, we're creating a standard for how colors should be used.
Links to added or changed documentation pages
Further Information and Comments
Reviewer Checklist