Skip to content

Unable to pass list of stroke_color for opengl #2897

Open
@k4pran

Description

@k4pran

Description of bug / unexpected behavior

It used to be the case you could pass a list of colors to create a stroke gradient, but from what I can tell it was broken from #2332 as I get the error AttributeError: 'list' object has no attribute 'startswith'

Expected behavior

Passing a list of stroke_color creates a gradient

How to reproduce the issue

Run the below scene with the opengl renderer

Code for reproducing the problem
class Sample(Scene):

    def construct(self):
        self.add(Rectangle(stroke_color=[BLUE, GREEN]))

Additional media files

Images/GIFs

Logs

Terminal output
/home/k4pran/.cache/pypoetry/virtualenvs/manim-HpVtdmRp-py3.10/bin/python -m manim /home/k4pran/PycharmProjects/manim/sample.py --renderer opengl -pql
Manim Community v0.16.0.post0

╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /home/k4pran/PycharmProjects/manim/manim/cli/render/commands.py:110 in       │
│ render                                                                       │
│                                                                              │
│   107 │   │   │   while keep_running:                                        │
│   108 │   │   │   │   for SceneClass in scene_classes_from_file(file):       │
│   109 │   │   │   │   │   scene = SceneClass(renderer)                       │
│ ❱ 110 │   │   │   │   │   rerun = scene.render()                             │
│   111 │   │   │   │   │   if rerun or config["write_all"]:                   │
│   112 │   │   │   │   │   │   renderer.num_plays = 0                         │
│   113 │   │   │   │   │   │   continue                                       │
│                                                                              │
│ /home/k4pran/PycharmProjects/manim/manim/scene/scene.py:221 in render        │
│                                                                              │
│    218 │   │   """                                                           │
│    219 │   │   self.setup()                                                  │
│    220 │   │   try:                                                          │
│ ❱  221 │   │   │   self.construct()                                          │
│    222 │   │   except EndSceneEarlyException:                                │
│    223 │   │   │   pass                                                      │
│    224 │   │   except RerunSceneException as e:                              │
│                                                                              │
│ /home/k4pran/PycharmProjects/manim/sample.py:9 in construct                  │
│                                                                              │
│   6 │   def construct(self):                                                 │
│   7 │   │   # self.add(Arc(angle=TAU, stroke_color=[PURE_BLUE, PURE_RED]))   │
│   8 │   │   # self.wait(duration=10)                                         │
│ ❱ 9 │   │   self.add(Rectangle(stroke_color=[BLUE, GREEN]))                  │
│                                                                              │
│ /home/k4pran/PycharmProjects/manim/manim/mobject/geometry.py:2472 in         │
│ __init__                                                                     │
│                                                                              │
│   2469 │   │   close_new_points=True,                                        │
│   2470 │   │   **kwargs,                                                     │
│   2471 │   ):                                                                │
│ ❱ 2472 │   │   super().__init__(UR, UL, DL, DR, color=color, **kwargs)       │
│   2473 │   │   self.stretch_to_fit_width(width)                              │
│   2474 │   │   self.stretch_to_fit_height(height)                            │
│   2475 │   │   v = self.get_vertices()                                       │
│                                                                              │
│ /home/k4pran/PycharmProjects/manim/manim/mobject/geometry.py:1930 in         │
│ __init__                                                                     │
│                                                                              │
│   1927 │   """                                                               │
│   1928 │                                                                     │
│   1929 │   def __init__(self, *vertices: Sequence[float], **kwargs):         │
│ ❱ 1930 │   │   super().__init__(vertices, **kwargs)                          │
│   1931                                                                       │
│   1932                                                                       │
│   1933 class RegularPolygram(Polygram):                                      │
│                                                                              │
│ /home/k4pran/PycharmProjects/manim/manim/mobject/geometry.py:1751 in         │
│ __init__                                                                     │
│                                                                              │
│   1748 │   """                                                               │
│   1749 │                                                                     │
│   1750 │   def __init__(self, *vertex_groups: Iterable[Sequence[float]], col │
│ ❱ 1751 │   │   super().__init__(color=color, **kwargs)                       │
│   1752 │   │                                                                 │
│   1753 │   │   for vertices in vertex_groups:                                │
│   1754 │   │   │   first_vertex, *vertices = vertices                        │
│                                                                              │
│ /home/k4pran/PycharmProjects/manim/manim/mobject/types/opengl_vectorized_mob │
│ ject.py:133 in __init__                                                      │
│                                                                              │
│    130 │   │   if fill_color:                                                │
│    131 │   │   │   self.fill_color = Color(fill_color)                       │
│    132 │   │   if stroke_color:                                              │
│ ❱  133 │   │   │   self.stroke_color = Color(stroke_color)                   │
│    134 │                                                                     │
│    135 │   def get_group_class(self):                                        │
│    136 │   │   return OpenGLVGroup                                           │
│                                                                              │
│ /home/k4pran/.cache/pypoetry/virtualenvs/manim-HpVtdmRp-py3.10/lib/python3.1 │
│ 0/site-packages/colour.py:988 in __init__                                    │
│                                                                              │
│    985 │   │   if isinstance(color, Color):                                  │
│    986 │   │   │   self.web = color.web                                      │
│    987 │   │   else:                                                         │
│ ❱  988 │   │   │   self.web = color if color else 'black'                    │
│    989 │   │                                                                 │
│    990 │   │   self.equality = RGB_equivalence                               │
│    991                                                                       │
│                                                                              │
│ /home/k4pran/.cache/pypoetry/virtualenvs/manim-HpVtdmRp-py3.10/lib/python3.1 │
│ 0/site-packages/colour.py:1006 in __setattr__                                │
│                                                                              │
│   1003 │   def __setattr__(self, label, value):                              │
│   1004 │   │   if label not in ["_hsl", "equality"]:                         │
│   1005 │   │   │   fc = getattr(self, 'set_' + label)                        │
│ ❱ 1006 │   │   │   fc(value)                                                 │
│   1007 │   │   else:                                                         │
│   1008 │   │   │   self.__dict__[label] = value                              │
│   1009                                                                       │
│                                                                              │
│ /home/k4pran/.cache/pypoetry/virtualenvs/manim-HpVtdmRp-py3.10/lib/python3.1 │
│ 0/site-packages/colour.py:1084 in set_web                                    │
│                                                                              │
│   1081 │   set_hex_l = set_hex                                               │
│   1082 │                                                                     │
│   1083 │   def set_web(self, value):                                         │
│ ❱ 1084 │   │   self.hex = web2hex(value)                                     │
│   1085 │                                                                     │
│   1086 │   ## range of color generation                                      │
│   1087                                                                       │
│                                                                              │
│ /home/k4pran/.cache/pypoetry/virtualenvs/manim-HpVtdmRp-py3.10/lib/python3.1 │
│ 0/site-packages/colour.py:664 in web2hex                                     │
│                                                                              │
│    661 │   <Color red>                                                       │
│    662 │                                                                     │
│    663 │   """                                                               │
│ ❱  664 │   if web.startswith('#'):                                           │
│    665 │   │   if (LONG_HEX_COLOR.match(web) or                              │
│    666 │   │   │   (not force_long and SHORT_HEX_COLOR.match(web))):         │
│    667 │   │   │   return web.lower()                                        │
╰──────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'list' object has no attribute 'startswith'

Process finished with exit code 1

System specifications

System Details
  • OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)):
  • RAM:
  • Python version (python/py/python3 --version):
  • Installed modules (provide output from pip list):
PASTE HERE
LaTeX details
  • LaTeX distribution (e.g. TeX Live 2020):
  • Installed LaTeX packages:
FFMPEG

Output of ffmpeg -version:

PASTE HERE

Additional comments

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue:bugSomething isn't working... For use in issuesopenglConcerning the OpenGL renderer.

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions