Have background rectangle match background color by default

This commit is contained in:
Grant Sanderson 2021-01-15 10:20:50 -10:00
parent b423a423b5
commit 4e4a7b9886
2 changed files with 6 additions and 4 deletions

View file

@ -911,7 +911,7 @@ class Mobject(object):
# Background rectangle
def add_background_rectangle(self, color=BLACK, opacity=0.75, **kwargs):
def add_background_rectangle(self, color=None, opacity=0.75, **kwargs):
# TODO, this does not behave well when the mobject has points,
# since it gets displayed on top
from manimlib.mobject.shape_matchers import BackgroundRectangle

View file

@ -4,6 +4,7 @@ from manimlib.mobject.geometry import Rectangle
from manimlib.mobject.types.vectorized_mobject import VGroup
from manimlib.mobject.types.vectorized_mobject import VMobject
from manimlib.utils.color import Color
from manimlib.utils.customization import get_customization
from manimlib.utils.config_ops import digest_config
@ -23,15 +24,16 @@ class SurroundingRectangle(Rectangle):
class BackgroundRectangle(SurroundingRectangle):
CONFIG = {
"color": BLACK,
"stroke_width": 0,
"stroke_opacity": 0,
"fill_opacity": 0.75,
"buff": 0
}
def __init__(self, mobject, **kwargs):
SurroundingRectangle.__init__(self, mobject, **kwargs)
def __init__(self, mobject, color=None, **kwargs):
if color is None:
color = get_customization()['style']['background_color']
SurroundingRectangle.__init__(self, mobject, color=color, **kwargs)
self.original_fill_opacity = self.fill_opacity
def pointwise_become_partial(self, mobject, a, b):