Repository: ManimCommunity/manim

Issue:
OpenGL: BackgroundRectangle.color causes infinite loop
## Description of bug / unexpected behavior
Manim is getting stuck in a recursion loop, to do with retrieving color.


## Expected behavior
Should just render items.


## How to reproduce the issue
This code is causing the issue for me, but only when rendered with OpenGL.



```py
class BugTest(ThreeDScene):
    def construct(self):
        mve = MathTex(r"Text").add_background_rectangle()
        self.play(Write(mve))
```

If I remove `add_background_rectangle` OR change `Write` to `Create` the problem goes away, so it seems to be at the intersection of these.



## Logs
Logs look similar to this (collapsed):
<details><summary>Terminal output</summary>

```
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:397 in get_color                                       |
|                                                                             |
|    394     def get_color(self):                                             |
|    395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
| >  397         return self.get_fill_color()                                 |
|    398                                                                      |
|    399     def get_colors(self):                                            |
|    400         if self.has_stroke():                                        |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\geometry\shape_ |
| matchers.py:133 in get_fill_color                                           |
|                                                                             |
|   130         return self                                                   |
|   131                                                                       |
|   132     def get_fill_color(self) -> ManimColor:                           |
| > 133         return self.color                                             |
|   134                                                                       |
|   135                                                                       |
|   136 class Cross(VGroup):                                                  |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:395 in get_color                                       |
|                                                                             |
|    392         return self.get_stroke_opacities()[0]                        |
|    393                                                                      |
|    394     def get_color(self):                                             |
| >  395         if self.has_stroke():                                        |
|    396             return self.get_stroke_color()                           |
|    397         return self.get_fill_color()                                 |
|    398                                                                      |
|                                                                             |
| C:\Users\Sam                                                                |
| Levey\.conda\envs\for_manim\lib\site-packages\manim\mobject\opengl\opengl_v |
| ectorized_mobject.py:409 in has_stroke                                      |
|                                                                             |
|    406     fill_color = property(get_fill_color, set_fill)                  |
|    407                                                                      |
|    408     def has_stroke(self):                                            |
| >  409         stroke_widths = self.get_stroke_widths()                     |
|    410         stroke_opacities = self.get_stroke_opacities()               |
|    411         return (                                                     |
|    412             stroke_widths is not None                                |
+-----------------------------------------------------------------------------+
RecursionError: maximum recursion depth exceeded
```

<!-- Insert screenshots here (only when absolutely necessary, we prefer copy/pasted output!) -->

</details>




Discussion:
I think I found a fix for this, I will try to submit a PR by the end of the week.

Resolving patch:
diff --git a/manim/mobject/opengl/opengl_vectorized_mobject.py b/manim/mobject/opengl/opengl_vectorized_mobject.py
--- a/manim/mobject/opengl/opengl_vectorized_mobject.py
+++ b/manim/mobject/opengl/opengl_vectorized_mobject.py
@@ -324,6 +324,7 @@ def match_style(self, vmobject, recurse=True):
         vmobject_style = vmobject.get_style()
         if config.renderer == RendererType.OPENGL:
             vmobject_style["stroke_width"] = vmobject_style["stroke_width"][0][0]
+            vmobject_style["fill_opacity"] = self.get_fill_opacity()
         self.set_style(**vmobject_style, recurse=False)
         if recurse:
             # Does its best to match up submobject lists, and
@@ -405,7 +406,7 @@ def get_stroke_opacity(self):
         return self.get_stroke_opacities()[0]
 
     def get_color(self):
-        if self.has_stroke():
+        if not self.has_fill():
             return self.get_stroke_color()
         return self.get_fill_color()
 


Test patch: