Repository: ManimCommunity/manim
File: manim/mobject/shape_matchers.py (Python)

Code before:
__all__ = ["SurroundingRectangle", "BackgroundRectangle", "Cross", "Underline"]


from ..constants import *
from ..mobject.geometry import Line, Rectangle
from ..mobject.types.vectorized_mobject import VGroup, VMobject
from ..utils.color import BLACK, RED, YELLOW, Color


class SurroundingRectangle(Rectangle):
    """A rectangle surrounding a :class:`~.Mobject`

    Examples
    --------

    .. manim:: SurroundingRectExample
    :save_last_frame:

        class SurroundingRectExample(Scene):
            def construct(self):
                title = Title("A Quote from Newton", scale_factor=1.5)
                line1 = "If I have seen further than others,\n"
                line2 = "it is by standing upon the shoulders of giants."
                quote = Text(line1 + line2, color=BLUE, size=0.8)
                box = SurroundingRectangle(quote, color=YELLOW, buff=MED_SMALL_BUFF)
                self.add(title, box, quote)

    """

    def __init__(self, mobject, color=YELLOW, buff=SMALL_BUFF, **kwargs):
        self.color = color
        self.buff = buff
        Rectangle.__init__(
            self,
            color=color,
            width=mobject.width + 2 * self.buff,
            height=mobject.height + 2 * self.buff,
            **kwargs
        )
        self.move_to(mobject)


class BackgroundRectangle(SurroundingRectangle):
    """A background rectangle

    Examples
    --------

    .. manim:: ExampleBackgroundRectangle
        :save_last_frame:


Review comment (suggestion):
```suggestion
        class SurroundingRectExample(Scene):
            def construct(self):
                title = Title("A Quote from Newton")
                quote = Text(
                    "If I have seen further than others, \n"
                    "it is by standing upon the shoulders of giants.",
                    color=BLUE
                ).scale(0.75)
                box = SurroundingRectangle(quote, color=YELLOW, buff=MED_LARGE_BUFF)
                self.add(title, box, quote)
```

Code after:
__all__ = ["SurroundingRectangle", "BackgroundRectangle", "Cross", "Underline"]


from ..constants import *
from ..mobject.geometry import Line, Rectangle
from ..mobject.types.vectorized_mobject import VGroup, VMobject
from ..utils.color import BLACK, RED, YELLOW, Color


class SurroundingRectangle(Rectangle):
    r"""A rectangle surrounding a :class:`~.Mobject`

    Examples
    --------

    .. manim:: SurroundingRectExample
        :save_last_frame:

        class SurroundingRectExample(Scene):
            def construct(self):
                title = Title("A Quote from Newton")
                quote = Text(
                    "If I have seen further than others, \n"
                    "it is by standing upon the shoulders of giants.",
                    color=BLUE
                ).scale(0.75)
                box = SurroundingRectangle(quote, color=YELLOW, buff=MED_LARGE_BUFF)
                self.add(title, box, quote)

    """

    def __init__(self, mobject, color=YELLOW, buff=SMALL_BUFF, **kwargs):
        self.color = color
        self.buff = buff
        Rectangle.__init__(
            self,
            color=color,
            width=mobject.width + 2 * self.buff,
            height=mobject.height + 2 * self.buff,
            **kwargs
        )
        self.move_to(mobject)


class BackgroundRectangle(SurroundingRectangle):
    """A background rectangle

    Examples
    --------

    .. manim:: ExampleBackgroundRectangle