File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed
tests/module/mobject/geometry Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ def __init__(
5353 self ,
5454 * mobjects : Mobject ,
5555 color : ParsableManimColor = YELLOW ,
56- buff : float = SMALL_BUFF ,
56+ buff : float | tuple [ float , float ] = SMALL_BUFF ,
5757 corner_radius : float = 0.0 ,
5858 ** kwargs : Any ,
5959 ) -> None :
@@ -64,11 +64,17 @@ def __init__(
6464 "Expected all inputs for parameter mobjects to be a Mobjects"
6565 )
6666
67+ if isinstance (buff , tuple ):
68+ buff_x = buff [0 ]
69+ buff_y = buff [1 ]
70+ else :
71+ buff_x = buff_y = buff
72+
6773 group = Group (* mobjects )
6874 super ().__init__ (
6975 color = color ,
70- width = group .width + 2 * buff ,
71- height = group .height + 2 * buff ,
76+ width = group .width + 2 * buff_x ,
77+ height = group .height + 2 * buff_y ,
7278 corner_radius = corner_radius ,
7379 ** kwargs ,
7480 )
@@ -108,7 +114,7 @@ def __init__(
108114 stroke_width : float = 0 ,
109115 stroke_opacity : float = 0 ,
110116 fill_opacity : float = 0.75 ,
111- buff : float = 0 ,
117+ buff : float | tuple [ float , float ] = 0 ,
112118 ** kwargs : Any ,
113119 ) -> None :
114120 if color is None :
Original file line number Diff line number Diff line change @@ -116,6 +116,17 @@ def test_SurroundingRectangle():
116116 assert sr .get_fill_opacity () == 0.42
117117
118118
119+ def test_SurroundingRectangle_buff ():
120+ sq = Square ()
121+ rect1 = SurroundingRectangle (sq , buff = 1 )
122+ assert rect1 .width == sq .width + 2
123+ assert rect1 .height == sq .height + 2
124+
125+ rect2 = SurroundingRectangle (sq , buff = (1 , 2 ))
126+ assert rect2 .width == sq .width + 2
127+ assert rect2 .height == sq .height + 4
128+
129+
119130def test_BackgroundRectangle (manim_caplog ):
120131 circle = Circle ()
121132 square = Square ()
You can’t perform that action at this time.
0 commit comments