From 7e25fca93b7a3bc11f9b16a9d1d7ad64fab53c4b Mon Sep 17 00:00:00 2001 From: Tristan Schulz Date: Mon, 15 Jul 2024 02:56:26 +0200 Subject: [PATCH 1/5] fix(vectorized_mobject,mobject): Removing explicit opacity attributes and remapping to ManimColor --- manim/animation/rotation.py | 5 +- manim/mobject/geometry/arc.py | 3 +- manim/mobject/mobject.py | 8 +- manim/mobject/types/vectorized_mobject.py | 97 ++++++++++++----------- manim/utils/color/core.py | 35 +++++++- 5 files changed, 94 insertions(+), 54 deletions(-) diff --git a/manim/animation/rotation.py b/manim/animation/rotation.py index 7bdd42238a..116bc4800e 100644 --- a/manim/animation/rotation.py +++ b/manim/animation/rotation.py @@ -16,6 +16,7 @@ if TYPE_CHECKING: from ..mobject.mobject import Mobject + from ..typing import Vector3D class Rotating(Animation): @@ -87,8 +88,8 @@ def __init__( mobject: Mobject, angle: float = PI, axis: np.ndarray = OUT, - about_point: Sequence[float] | None = None, - about_edge: Sequence[float] | None = None, + about_point: Vector3D | None = None, + about_edge: Vector3D | None = None, **kwargs, ) -> None: if "path_arc" not in kwargs: diff --git a/manim/mobject/geometry/arc.py b/manim/mobject/geometry/arc.py index dd532b07b6..c3909b60ea 100644 --- a/manim/mobject/geometry/arc.py +++ b/manim/mobject/geometry/arc.py @@ -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, color: ParsableManimColor = WHITE, **kwargs, ) -> None: + self.submobjects = [] super().__init__( arc_center=point, radius=radius, diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py index ee487a7fc5..8080cb195a 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -96,7 +96,7 @@ def __init_subclass__(cls, **kwargs) -> None: def __init__( self, - color: ParsableManimColor | list[ParsableManimColor] = WHITE, + color: ParsableManimColor | list[ParsableManimColor] | None = WHITE, name: str | None = None, dim: int = 3, target=None, @@ -400,13 +400,15 @@ def __deepcopy__(self, clone_from_id) -> Self: return result def __repr__(self) -> str: - return str(self.name) + if hasattr(self, "name"): + return str(self.name) + return str(self.__class__.__name__) def reset_points(self) -> None: """Sets :attr:`points` to be an empty array.""" self.points = np.zeros((0, self.dim)) - def init_colors(self) -> None: + def init_colors(self) -> Self: """Initializes the colors. Gets called upon creation. This is an empty method that can be implemented by diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.py index 86b5cd1386..03d165e877 100644 --- a/manim/mobject/types/vectorized_mobject.py +++ b/manim/mobject/types/vectorized_mobject.py @@ -1,6 +1,7 @@ """Mobjects that use vector graphics.""" from __future__ import annotations +from typing_extensions import deprecated __all__ = [ "VMobject", @@ -46,6 +47,8 @@ ) from manim.utils.space_ops import rotate_vector, shoelace_direction +from typing import cast + if TYPE_CHECKING: import numpy.typing as npt from typing_extensions import Self @@ -112,13 +115,14 @@ class VMobject(Mobject): def __init__( self, + color: ParsableManimColor | list[ParsableManimColor] | None = None, fill_color: ParsableManimColor | None = None, - fill_opacity: float = 0.0, + fill_opacity: float | None = None, stroke_color: ParsableManimColor | None = None, - stroke_opacity: float = 1.0, + stroke_opacity: float | None = None, stroke_width: float = DEFAULT_STROKE_WIDTH, background_stroke_color: ParsableManimColor | None = BLACK, - background_stroke_opacity: float = 1.0, + background_stroke_opacity: float | None = None, background_stroke_width: float = 0, sheen_factor: float = 0.0, joint_type: LineJointType | None = None, @@ -134,14 +138,7 @@ def __init__( cap_style: CapStyleType = CapStyleType.AUTO, **kwargs, ): - self.fill_opacity = fill_opacity - self.stroke_opacity = stroke_opacity self.stroke_width = stroke_width - if background_stroke_color is not None: - self.background_stroke_color: ManimColor = ManimColor( - background_stroke_color - ) - self.background_stroke_opacity: float = background_stroke_opacity self.background_stroke_width: float = background_stroke_width self.sheen_factor: float = sheen_factor self.joint_type: LineJointType = ( @@ -163,17 +160,33 @@ def __init__( 0, 1, n_points_per_cubic_curve ) self.cap_style: CapStyleType = cap_style - super().__init__(**kwargs) + + # TODO: Refactor color initialization + # This must be after init + self.submobjects: list[VMobject] + if fill_color is not None or stroke_color is not None: + color = None + + if background_stroke_color is not None: + self.background_stroke_color: ManimColor = ManimColor( + background_stroke_color + ) + if background_stroke_opacity is not None: + self.background_stroke_color = self.background_stroke_color.opacity( + background_stroke_opacity + ) + + super().__init__(color=color, **kwargs) - # TODO: Find where color overwrites are happening and remove the color doubling - # if "color" in kwargs: - # fill_color = kwargs["color"] - # stroke_color = kwargs["color"] if fill_color is not None: self.fill_color = ManimColor.parse(fill_color) + # if fill_opacity is not None: + # self.fill_color = self.fill_color.opacity(fill_opacity) if stroke_color is not None: self.stroke_color = ManimColor.parse(stroke_color) + # if stroke_opacity is not None: + # self.stroke_color = self.stroke_color.opacity(stroke_opacity) def _assert_valid_submobjects(self, submobjects: Iterable[VMobject]) -> Self: return self._assert_valid_submobjects_internal(submobjects, VMobject) @@ -191,22 +204,11 @@ def get_mobject_type_class() -> type[VMobject]: return VMobject # Colors + @deprecated("Sorry") def init_colors(self, propagate_colors: bool = True) -> Self: - self.set_fill( - color=self.fill_color, - opacity=self.fill_opacity, - family=propagate_colors, - ) - self.set_stroke( - color=self.stroke_color, - width=self.stroke_width, - opacity=self.stroke_opacity, - family=propagate_colors, - ) self.set_background_stroke( color=self.background_stroke_color, width=self.background_stroke_width, - opacity=self.background_stroke_opacity, family=propagate_colors, ) self.set_sheen( @@ -222,7 +224,7 @@ def init_colors(self, propagate_colors: bool = True) -> Self: return self def generate_rgbas_array( - self, color: ManimColor | list[ManimColor], opacity: float | Iterable[float] + self, color: ManimColor | list[ManimColor] ) -> RGBA_Array_Float: """ First arg can be either a color, or a tuple/list of colors. @@ -232,14 +234,10 @@ def generate_rgbas_array( will automatically be added for the gradient """ colors: list[ManimColor] = [ - ManimColor(c) if (c is not None) else BLACK for c in tuplify(color) - ] - opacities: list[float] = [ - o if (o is not None) else 0.0 for o in tuplify(opacity) + ManimColor(c) if (c is not None) else BLACK + for c in cast(tuple[ManimColor], tuplify(color)) ] - rgbas: npt.NDArray[RGBA_Array_Float] = np.array( - [c.to_rgba_with_alpha(o) for c, o in zip(*make_even(colors, opacities))], - ) + rgbas = np.array([c.to_rgba() for c in colors]) sheen_factor = self.get_sheen_factor() if sheen_factor != 0 and len(rgbas) == 1: @@ -252,10 +250,11 @@ def generate_rgbas_array( def update_rgbas_array( self, array_name: str, - color: ManimColor | None = None, - opacity: float | None = None, + color: ManimColor | None, ) -> Self: - rgbas = self.generate_rgbas_array(color, opacity) + if color is None: + return self + rgbas = self.generate_rgbas_array(color) if not hasattr(self, array_name): setattr(self, array_name, rgbas) return self @@ -269,10 +268,7 @@ def update_rgbas_array( rgbas = stretch_array_to_length(rgbas, len(curr_rgbas)) # Only update rgb if color was not None, and only # update alpha channel if opacity was passed in - if color is not None: - curr_rgbas[:, :3] = rgbas[:, :3] - if opacity is not None: - curr_rgbas[:, 3] = rgbas[:, 3] + curr_rgbas[:, :4] = rgbas[:, :4] return self def set_fill( @@ -316,23 +312,30 @@ def construct(self): -------- :meth:`~.VMobject.set_style` """ + if color is not None: + color = ManimColor.parse(color) + if opacity is not None: + color = color.opacity(opacity) + if family: for submobject in self.submobjects: submobject.set_fill(color, opacity, family) - self.update_rgbas_array("fill_rgbas", color, opacity) + self.update_rgbas_array("fill_rgbas", color) self.fill_rgbas: RGBA_Array_Float - if opacity is not None: - self.fill_opacity = opacity return self def set_stroke( self, - color: ParsableManimColor = None, + color: ParsableManimColor | None = None, width: float | None = None, opacity: float | None = None, background=False, family: bool = True, ) -> Self: + if color is not None: + color = ManimColor.parse(color) + if opacity is not None: + color = color.opacity(opacity) if family: for submobject in self.submobjects: submobject.set_stroke(color, width, opacity, background, family) @@ -344,7 +347,7 @@ def set_stroke( array_name = "stroke_rgbas" width_name = "stroke_width" opacity_name = "stroke_opacity" - self.update_rgbas_array(array_name, color, opacity) + self.update_rgbas_array(array_name, color) if width is not None: setattr(self, width_name, width) if opacity is not None: diff --git a/manim/utils/color/core.py b/manim/utils/color/core.py index 32c895d100..9e6f1a039e 100644 --- a/manim/utils/color/core.py +++ b/manim/utils/color/core.py @@ -519,6 +519,39 @@ def invert(self, with_alpha=False) -> ManimColor: """ return ManimColor(1.0 - self._internal_value, with_alpha) + @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 interpolate(self, other: ManimColor, alpha: float) -> ManimColor: """Interpolates between the current and the given ManimColor an returns the interpolated color @@ -676,7 +709,7 @@ def gradient(colors: list[ManimColor], length: int): raise NotImplementedError def __repr__(self) -> str: - return f"{self.__class__.__name__}('{self.to_hex()}')" + return f"{self.__class__.__name__}('{self.to_hex(True)}')" def __str__(self) -> str: return f"{self.to_hex()}" From 2861b42ab054483e96b3019b43ce02e13067c2e9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 01:00:14 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- manim/animation/rotation.py | 1 - manim/mobject/types/vectorized_mobject.py | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/manim/animation/rotation.py b/manim/animation/rotation.py index 116bc4800e..1057a0945c 100644 --- a/manim/animation/rotation.py +++ b/manim/animation/rotation.py @@ -4,7 +4,6 @@ __all__ = ["Rotating", "Rotate"] -from collections.abc import Sequence from typing import TYPE_CHECKING, Callable import numpy as np diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.py index 03d165e877..568399ee44 100644 --- a/manim/mobject/types/vectorized_mobject.py +++ b/manim/mobject/types/vectorized_mobject.py @@ -1,6 +1,7 @@ """Mobjects that use vector graphics.""" from __future__ import annotations + from typing_extensions import deprecated __all__ = [ @@ -16,7 +17,7 @@ import itertools as it import sys from collections.abc import Generator, Hashable, Iterable, Mapping, Sequence -from typing import TYPE_CHECKING, Callable, Literal +from typing import TYPE_CHECKING, Callable, Literal, cast import numpy as np from PIL.Image import Image @@ -47,8 +48,6 @@ ) from manim.utils.space_ops import rotate_vector, shoelace_direction -from typing import cast - if TYPE_CHECKING: import numpy.typing as npt from typing_extensions import Self From 8ac1d38bfa91514e0d92cb12f349036785c9a5ac Mon Sep 17 00:00:00 2001 From: Tristan Schulz Date: Tue, 16 Jul 2024 13:08:26 +0200 Subject: [PATCH 3/5] Fix some typing issues with colors and parsing --- manim/mobject/geometry/shape_matchers.py | 2 +- manim/mobject/types/vectorized_mobject.py | 42 +++++++++++++---------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/manim/mobject/geometry/shape_matchers.py b/manim/mobject/geometry/shape_matchers.py index 296d9b9d9f..72bcc74970 100644 --- a/manim/mobject/geometry/shape_matchers.py +++ b/manim/mobject/geometry/shape_matchers.py @@ -107,7 +107,7 @@ def __init__( buff=buff, **kwargs, ) - self.original_fill_opacity: float = self.fill_opacity + self.original_fill_opacity: float = self.get_fill_opacities() def pointwise_become_partial(self, mobject: Mobject, a: Any, b: float) -> Self: self.set_fill(opacity=b * self.original_fill_opacity) diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.py index 03d165e877..12db7e7e97 100644 --- a/manim/mobject/types/vectorized_mobject.py +++ b/manim/mobject/types/vectorized_mobject.py @@ -1,6 +1,7 @@ """Mobjects that use vector graphics.""" from __future__ import annotations + from typing_extensions import deprecated __all__ = [ @@ -16,7 +17,7 @@ import itertools as it import sys from collections.abc import Generator, Hashable, Iterable, Mapping, Sequence -from typing import TYPE_CHECKING, Callable, Literal +from typing import TYPE_CHECKING, Callable, Literal, cast import numpy as np from PIL.Image import Image @@ -40,6 +41,7 @@ ) from manim.utils.color import BLACK, WHITE, ManimColor, ParsableManimColor from manim.utils.iterables import ( + listify, make_even, resize_array, stretch_array_to_length, @@ -47,8 +49,6 @@ ) from manim.utils.space_ops import rotate_vector, shoelace_direction -from typing import cast - if TYPE_CHECKING: import numpy.typing as npt from typing_extensions import Self @@ -169,8 +169,8 @@ def __init__( color = None if background_stroke_color is not None: - self.background_stroke_color: ManimColor = ManimColor( - background_stroke_color + self.background_stroke_color: ManimColor | list[ManimColor] = ( + ManimColor.parse(background_stroke_color) ) if background_stroke_opacity is not None: self.background_stroke_color = self.background_stroke_color.opacity( @@ -250,7 +250,7 @@ def generate_rgbas_array( def update_rgbas_array( self, array_name: str, - color: ManimColor | None, + color: ManimColor | list[ManimColor] | None, ) -> Self: if color is None: return self @@ -273,7 +273,7 @@ def update_rgbas_array( def set_fill( self, - color: ParsableManimColor | None = None, + color: ParsableManimColor | list[ParsableManimColor] | None = None, opacity: float | None = None, family: bool = True, ) -> Self: @@ -312,30 +312,33 @@ def construct(self): -------- :meth:`~.VMobject.set_style` """ + new_color: list[ManimColor] = [WHITE] if color is not None: - color = ManimColor.parse(color) + new_color: list[ManimColor] = listify(ManimColor.parse(color)) if opacity is not None: - color = color.opacity(opacity) + new_color = [c.opacity(opacity) for c in new_color] if family: for submobject in self.submobjects: submobject.set_fill(color, opacity, family) - self.update_rgbas_array("fill_rgbas", color) + self.update_rgbas_array("fill_rgbas", new_color) self.fill_rgbas: RGBA_Array_Float return self def set_stroke( self, - color: ParsableManimColor | None = None, + color: ParsableManimColor | list[ParsableManimColor] | None = None, width: float | None = None, opacity: float | None = None, background=False, family: bool = True, ) -> Self: + new_color: list[ManimColor] = [WHITE] if color is not None: - color = ManimColor.parse(color) + new_color: list[ManimColor] = listify(ManimColor.parse(color)) if opacity is not None: - color = color.opacity(opacity) + new_color = [c.opacity(opacity) for c in new_color] + if family: for submobject in self.submobjects: submobject.set_stroke(color, width, opacity, background, family) @@ -347,16 +350,13 @@ def set_stroke( array_name = "stroke_rgbas" width_name = "stroke_width" opacity_name = "stroke_opacity" - self.update_rgbas_array(array_name, color) + self.update_rgbas_array(array_name, new_color) if width is not None: setattr(self, width_name, width) if opacity is not None: setattr(self, opacity_name, opacity) if color is not None and background: - if isinstance(color, (list, tuple)): - self.background_stroke_color = ManimColor.parse(color) - else: - self.background_stroke_color = ManimColor(color) + self.background_stroke_color = ManimColor.parse(color) return self def set_cap_style(self, cap_style: CapStyleType) -> Self: @@ -513,6 +513,10 @@ def get_fill_opacity(self) -> ManimFloat: """ return self.get_fill_opacities()[0] + def set_fill_opacity(self, opacity: float): + self.fill_color = [x.opacity(opacity) for x in tuplify(self.fill_color)] + return self + # 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]: @@ -530,8 +534,8 @@ def get_stroke_rgbas(self, background: bool = False) -> RGBA_Array_float | Zeros self.background_stroke_rgbas: RGBA_Array_Float rgbas = self.background_stroke_rgbas else: - self.stroke_rgbas: RGBA_Array_Float rgbas = self.stroke_rgbas + self.stroke_rgbas: RGBA_Array_Float return rgbas except AttributeError: return np.zeros((1, 4)) From c2425e0d320274fac6eb54135b04a3d78e5ad384 Mon Sep 17 00:00:00 2001 From: Tristan Schulz Date: Thu, 25 Jul 2024 16:57:30 +0200 Subject: [PATCH 4/5] probably breaking a lot of things and initialization process needs to be rewritten --- manim/mobject/geometry/shape_matchers.py | 3 --- manim/mobject/graphing/probability.py | 1 + manim/mobject/text/numbers.py | 5 ++-- manim/mobject/types/vectorized_mobject.py | 30 +++++++++++++---------- manim/utils/color/core.py | 4 ++- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/manim/mobject/geometry/shape_matchers.py b/manim/mobject/geometry/shape_matchers.py index 72bcc74970..ae33758519 100644 --- a/manim/mobject/geometry/shape_matchers.py +++ b/manim/mobject/geometry/shape_matchers.py @@ -129,9 +129,6 @@ def set_style(self, fill_opacity: float, **kwargs) -> Self: ) return self - def get_fill_color(self) -> ManimColor: - return self.color - class Cross(VGroup): """Creates a cross. diff --git a/manim/mobject/graphing/probability.py b/manim/mobject/graphing/probability.py index 0f98620dc3..73a1fb9e63 100644 --- a/manim/mobject/graphing/probability.py +++ b/manim/mobject/graphing/probability.py @@ -197,6 +197,7 @@ class BarChart(Axes): bar_names A sequence of names for each bar. Does not have to match the length of ``values``. y_range + Takes the form (min, max, stepsize) The y_axis range of values. If ``None``, the range will be calculated based on the min/max of ``values`` and the step will be calculated based on ``y_length``. x_length diff --git a/manim/mobject/text/numbers.py b/manim/mobject/text/numbers.py index 6a0eb45a82..1ef9e3d1f3 100644 --- a/manim/mobject/text/numbers.py +++ b/manim/mobject/text/numbers.py @@ -99,7 +99,7 @@ def __init__( fill_opacity: float = 1.0, **kwargs, ): - super().__init__(**kwargs, stroke_width=stroke_width) + super().__init__(**kwargs, stroke_width=stroke_width, fill_opacity=fill_opacity) self.number = number self.num_decimal_places = num_decimal_places self.include_sign = include_sign @@ -112,7 +112,7 @@ def __init__( self.include_background_rectangle = include_background_rectangle self.edge_to_fix = edge_to_fix self._font_size = font_size - self.fill_opacity = fill_opacity + self.set_fill_opacity(fill_opacity) self.initial_config = kwargs.copy() self.initial_config.update( @@ -133,7 +133,6 @@ def __init__( ) self._set_submobjects_from_number(number) - self.init_colors() @property def font_size(self): diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.py index 12db7e7e97..58d34d8bdd 100644 --- a/manim/mobject/types/vectorized_mobject.py +++ b/manim/mobject/types/vectorized_mobject.py @@ -165,8 +165,8 @@ def __init__( # This must be after init self.submobjects: list[VMobject] - if fill_color is not None or stroke_color is not None: - color = None + # if fill_color is not None or stroke_color is not None: + # color = None if background_stroke_color is not None: self.background_stroke_color: ManimColor | list[ManimColor] = ( @@ -177,16 +177,18 @@ def __init__( background_stroke_opacity ) + print("Before", color, fill_color, stroke_color) super().__init__(color=color, **kwargs) + print("After", self.color, self.fill_color, self.stroke_color) if fill_color is not None: self.fill_color = ManimColor.parse(fill_color) - # if fill_opacity is not None: - # self.fill_color = self.fill_color.opacity(fill_opacity) + if fill_opacity is not None: + self.fill_color = self.fill_color.opacity(fill_opacity) if stroke_color is not None: self.stroke_color = ManimColor.parse(stroke_color) - # if stroke_opacity is not None: - # self.stroke_color = self.stroke_color.opacity(stroke_opacity) + if stroke_opacity is not None: + self.stroke_color = self.stroke_color.opacity(stroke_opacity) def _assert_valid_submobjects(self, submobjects: Iterable[VMobject]) -> Self: return self._assert_valid_submobjects_internal(submobjects, VMobject) @@ -204,7 +206,6 @@ def get_mobject_type_class() -> type[VMobject]: return VMobject # Colors - @deprecated("Sorry") def init_colors(self, propagate_colors: bool = True) -> Self: self.set_background_stroke( color=self.background_stroke_color, @@ -269,6 +270,8 @@ def update_rgbas_array( # Only update rgb if color was not None, and only # update alpha channel if opacity was passed in curr_rgbas[:, :4] = rgbas[:, :4] + print(array_name, curr_rgbas) + setattr(self, array_name, curr_rgbas) return self def set_fill( @@ -312,11 +315,11 @@ def construct(self): -------- :meth:`~.VMobject.set_style` """ - new_color: list[ManimColor] = [WHITE] + new_color: list[ManimColor] = listify(self.get_fill_color()) if color is not None: new_color: list[ManimColor] = listify(ManimColor.parse(color)) - if opacity is not None: - new_color = [c.opacity(opacity) for c in new_color] + if opacity is not None: + new_color = [c.opacity(opacity) for c in new_color] if family: for submobject in self.submobjects: @@ -333,11 +336,11 @@ def set_stroke( background=False, family: bool = True, ) -> Self: - new_color: list[ManimColor] = [WHITE] + new_color: list[ManimColor] = listify(self.get_fill_color()) if color is not None: new_color: list[ManimColor] = listify(ManimColor.parse(color)) - if opacity is not None: - new_color = [c.opacity(opacity) for c in new_color] + if opacity is not None: + new_color = [c.opacity(opacity) for c in new_color] if family: for submobject in self.submobjects: @@ -350,6 +353,7 @@ def set_stroke( array_name = "stroke_rgbas" width_name = "stroke_width" opacity_name = "stroke_opacity" + self.update_rgbas_array(array_name, new_color) if width is not None: setattr(self, width_name, width) diff --git a/manim/utils/color/core.py b/manim/utils/color/core.py index 9e6f1a039e..e1508d1225 100644 --- a/manim/utils/color/core.py +++ b/manim/utils/color/core.py @@ -113,7 +113,9 @@ def __init__( alpha: float = 1.0, ) -> None: if value is None: - self._internal_value = np.array((0, 0, 0, alpha), dtype=ManimColorDType) + self._internal_value = np.array( + (1.0, 1.0, 1.0, alpha), dtype=ManimColorDType + ) elif isinstance(value, ManimColor): # logger.info( # "ManimColor was passed another ManimColor. This is probably not what " From e15186533957e78a0396f6e6d10ee6e3f03748bf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:58:12 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- manim/mobject/geometry/shape_matchers.py | 2 +- manim/mobject/types/vectorized_mobject.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/manim/mobject/geometry/shape_matchers.py b/manim/mobject/geometry/shape_matchers.py index ae33758519..2780f9d2c5 100644 --- a/manim/mobject/geometry/shape_matchers.py +++ b/manim/mobject/geometry/shape_matchers.py @@ -14,7 +14,7 @@ from manim.mobject.geometry.polygram import RoundedRectangle from manim.mobject.mobject import Mobject from manim.mobject.types.vectorized_mobject import VGroup -from manim.utils.color import BLACK, RED, YELLOW, ManimColor, ParsableManimColor +from manim.utils.color import BLACK, RED, YELLOW, ParsableManimColor class SurroundingRectangle(RoundedRectangle): diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.py index 58d34d8bdd..9897c48ac9 100644 --- a/manim/mobject/types/vectorized_mobject.py +++ b/manim/mobject/types/vectorized_mobject.py @@ -2,8 +2,6 @@ from __future__ import annotations -from typing_extensions import deprecated - __all__ = [ "VMobject", "VGroup",