Skip to content
4 changes: 2 additions & 2 deletions manim/mobject/geometry/shape_matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,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, Color, Colors
from manim.utils.color import BLACK, RED, YELLOW, Color


class SurroundingRectangle(RoundedRectangle):
Expand Down Expand Up @@ -79,7 +79,7 @@ def construct(self):
def __init__(
self,
mobject,
color: Colors | None = None,
color: str | None = None,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
color: str | None = None,
color: Color | str | None = None,

Copy link
Member

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.

stroke_width: float = 0,
stroke_opacity: float = 0,
fill_opacity: float = 0.75,
Expand Down
11 changes: 2 additions & 9 deletions manim/mobject/mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,7 @@

from .. import config
from ..constants import *
from ..utils.color import (
BLACK,
WHITE,
YELLOW_C,
Colors,
color_gradient,
interpolate_color,
)
from ..utils.color import BLACK, WHITE, YELLOW_C, color_gradient, interpolate_color
from ..utils.exceptions import MultiAnimationOverrideException
from ..utils.iterables import list_update, remove_list_redundancies
from ..utils.paths import straight_path
Expand Down Expand Up @@ -1646,7 +1639,7 @@ def put_start_and_end_on(self, start, end):

# 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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
self, color: str = None, opacity: float = 0.75, **kwargs
self, color: Color | str | None = None, opacity: float = 0.75, **kwargs

):
"""Add a BackgroundRectangle as submobject.

Expand Down
3 changes: 1 addition & 2 deletions manim/mobject/opengl/opengl_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from manim.constants import *
from manim.utils.bezier import integer_interpolate, interpolate
from manim.utils.color import *
from manim.utils.color import Colors
from manim.utils.config_ops import _Data, _Uniforms

# from ..utils.iterables import batch_by_property
Expand Down Expand Up @@ -1983,7 +1982,7 @@ def set_shadow(self, shadow, recurse=True):
# Background rectangle

def add_background_rectangle(
self, color: Colors | None = None, opacity: float = 0.75, **kwargs
self, color: str | None = None, opacity: float = 0.75, **kwargs
):
# TODO, this does not behave well when the mobject has points,
# since it gets displayed on top
Expand Down
7 changes: 4 additions & 3 deletions manim/mobject/text/text_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def construct(self):
from manim.mobject.geometry.arc import Dot
from manim.mobject.svg.svg_mobject import SVGMobject
from manim.mobject.types.vectorized_mobject import VGroup, VMobject
from manim.utils.color import Colors, color_gradient
from manim.utils.color import ALL_COLORS, color_gradient
from manim.utils.deprecation import deprecated

TEXT_MOB_SCALE_FACTOR = 0.05
Expand Down Expand Up @@ -644,7 +644,7 @@ def _get_settings_from_t2xs(
t2xwords = set(chain(*([*t2x.keys()] for t2x, _ in t2xs)))
for word in t2xwords:
setting_args = {
arg: t2x[word] if word in t2x else default_args[arg]
arg: str(t2x[word]) if word in t2x else str(default_args[arg])
for t2x, arg in t2xs
}

Expand Down Expand Up @@ -1331,7 +1331,8 @@ def _parse_color(self, col):
if re.match("#[0-9a-f]{6}", col):
return col
else:
return Colors[col.lower()].value
# lookup in COLOR_VALUES
return ALL_COLORS[col]

def _extract_color_tags(self):
"""Used to determine which parts (if any) of the string should be formatted
Expand Down
Loading