mirror of
https://github.com/3b1b/manim.git
synced 2025-09-19 04:41:56 +00:00
Have background rectangle match background color by default
This commit is contained in:
parent
b423a423b5
commit
4e4a7b9886
2 changed files with 6 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Add table
Reference in a new issue