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__(
53
53
self ,
54
54
* mobjects : Mobject ,
55
55
color : ParsableManimColor = YELLOW ,
56
- buff : float = SMALL_BUFF ,
56
+ buff : float | tuple [ float , float ] = SMALL_BUFF ,
57
57
corner_radius : float = 0.0 ,
58
58
** kwargs : Any ,
59
59
) -> None :
@@ -64,11 +64,17 @@ def __init__(
64
64
"Expected all inputs for parameter mobjects to be a Mobjects"
65
65
)
66
66
67
+ if isinstance (buff , tuple ):
68
+ buff_x = buff [0 ]
69
+ buff_y = buff [1 ]
70
+ else :
71
+ buff_x = buff_y = buff
72
+
67
73
group = Group (* mobjects )
68
74
super ().__init__ (
69
75
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 ,
72
78
corner_radius = corner_radius ,
73
79
** kwargs ,
74
80
)
@@ -108,7 +114,7 @@ def __init__(
108
114
stroke_width : float = 0 ,
109
115
stroke_opacity : float = 0 ,
110
116
fill_opacity : float = 0.75 ,
111
- buff : float = 0 ,
117
+ buff : float | tuple [ float , float ] = 0 ,
112
118
** kwargs : Any ,
113
119
) -> None :
114
120
if color is None :
Original file line number Diff line number Diff line change @@ -116,6 +116,17 @@ def test_SurroundingRectangle():
116
116
assert sr .get_fill_opacity () == 0.42
117
117
118
118
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
+
119
130
def test_BackgroundRectangle (manim_caplog ):
120
131
circle = Circle ()
121
132
square = Square ()
You can’t perform that action at this time.
0 commit comments