-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix(vectorized_mobject,mobject): Removing explicit opacity attributes… #3862
base: main
Are you sure you want to change the base?
Conversation
… and remapping to ManimColor
for more information, see https://pre-commit.ci
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.
Quick stuff I noticed ;)
@@ -679,10 +679,11 @@ def __init__( | |||
point: Point3D = ORIGIN, | |||
radius: float = DEFAULT_DOT_RADIUS, | |||
stroke_width: float = 0, | |||
fill_opacity: float = 1.0, | |||
fill_opacity: float = 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.
fill_opacity: float = None, | |
fill_opacity: float | None = None, |
@@ -2,6 +2,8 @@ | |||
|
|||
from __future__ import annotations | |||
|
|||
from typing_extensions import deprecated |
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.
Maybe use manim.utils.deprecation.deprecated
?
The opacity of the ManimColor | ||
""" | ||
|
||
def opacity(self, opacity=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.
def opacity(self, opacity=None): | |
def opacity(self, opacity: float | None = None) -> ManimColor | float: |
@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) |
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.
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?
@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] |
fill_opacity
andstroke_opacity
and replacing them with properties