fix(vectorized_mobject,mobject): Removing explicit opacity attributes…#3862
Open
MrDiver wants to merge 9 commits into
Open
fix(vectorized_mobject,mobject): Removing explicit opacity attributes…#3862MrDiver wants to merge 9 commits into
MrDiver wants to merge 9 commits into
Conversation
… and remapping to ManimColor
for more information, see https://pre-commit.ci
JasonGrace2282
left a comment
Member
There was a problem hiding this comment.
Quick stuff I noticed ;)
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing_extensions import deprecated |
Member
There was a problem hiding this comment.
Maybe use manim.utils.deprecation.deprecated?
| The opacity of the ManimColor | ||
| """ | ||
|
|
||
| def opacity(self, opacity=None): |
Member
There was a problem hiding this comment.
Suggested change
| def opacity(self, opacity=None): | |
| def opacity(self, opacity: float | None = None) -> ManimColor | float: |
Comment on lines
+166
to
+167
| # if fill_color is not None or stroke_color is not None: | ||
| # color = None |
Check notice
Code scanning / CodeQL
Commented-out code
chopan050
reviewed
Oct 25, 2024
Comment on lines
+524
to
+555
| @overload | ||
| def opacity(self, opacity: float) -> ManimColor: | ||
| """Returns a new ManimColor with the same color and the given opacity | ||
|
|
||
| Parameters | ||
| ---------- | ||
| opacity : float | ||
| The opacity for the new ManimColor | ||
|
|
||
| Returns | ||
| ------- | ||
| ManimColor | ||
| The new ManimColor object with changed opacity | ||
| """ | ||
|
|
||
| @overload | ||
| def opacity(self, opacity: None) -> float: | ||
| """Returns the opacity of the current ManimColor in a range from zero to one | ||
|
|
||
| Returns | ||
| ------- | ||
| float | ||
| The opacity of the ManimColor | ||
| """ | ||
|
|
||
| def opacity(self, opacity=None): | ||
| """Returns a new ManimColor with the same color and a new opacity or changes the opacity""" | ||
| if opacity is None: | ||
| return self._internal_value[3] | ||
| tmp = self._internal_value.copy() | ||
| tmp[3] = opacity | ||
| return ManimColor.parse(tmp) |
Member
There was a problem hiding this comment.
I'm not sure about this overload. Could it be, instead, something like ManimColor.with_opacity(opacity) to return a new ManimColor with that different opacity, and ManimColor.get_opacity() or ManimColor.opacity as a property to get the current opacity?
Suggested change
| @overload | |
| def opacity(self, opacity: float) -> ManimColor: | |
| """Returns a new ManimColor with the same color and the given opacity | |
| Parameters | |
| ---------- | |
| opacity : float | |
| The opacity for the new ManimColor | |
| Returns | |
| ------- | |
| ManimColor | |
| The new ManimColor object with changed opacity | |
| """ | |
| @overload | |
| def opacity(self, opacity: None) -> float: | |
| """Returns the opacity of the current ManimColor in a range from zero to one | |
| Returns | |
| ------- | |
| float | |
| The opacity of the ManimColor | |
| """ | |
| def opacity(self, opacity=None): | |
| """Returns a new ManimColor with the same color and a new opacity or changes the opacity""" | |
| if opacity is None: | |
| return self._internal_value[3] | |
| tmp = self._internal_value.copy() | |
| tmp[3] = opacity | |
| return ManimColor.parse(tmp) | |
| def with_opacity(self, opacity: float) -> ManimColor: | |
| """Returns a new ManimColor with the same color and the given opacity. | |
| Parameters | |
| ---------- | |
| opacity | |
| The opacity for the new ManimColor. | |
| Returns | |
| ------- | |
| ManimColor | |
| The new ManimColor object with changed opacity. | |
| """ | |
| tmp = self._internal_value.copy() | |
| tmp[3] = opacity | |
| return ManimColor.parse(tmp) | |
| @property | |
| def opacity(self) -> float: | |
| """Returns the opacity of the current ManimColor, in a range from zero to one. | |
| Returns | |
| ------- | |
| float | |
| The opacity of the ManimColor. | |
| """ | |
| return self._internal_value[3] |
Co-authored-by: Aarush Deshpande <110117391+JasonGrace2282@users.noreply.github.com>
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.
fill_opacityandstroke_opacityand replacing them with properties