Skip to content

Commit 57a24e3

Browse files
authored
fix - corrections for setting stroke related attributes on VMobject (#1051)
1 parent 7bfabe3 commit 57a24e3

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

manim/mobject/types/vectorized_mobject.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,20 @@ def set_stroke(
186186
if background:
187187
array_name = "background_stroke_rgbas"
188188
width_name = "background_stroke_width"
189+
opacity_name = "background_stroke_opacity"
190+
color_name = "background_stroke_color"
189191
else:
190192
array_name = "stroke_rgbas"
191193
width_name = "stroke_width"
194+
opacity_name = "stroke_opacity"
195+
color_name = "stroke_color"
192196
self.update_rgbas_array(array_name, color, opacity)
193197
if width is not None:
194198
setattr(self, width_name, width)
195199
if opacity is not None:
196-
self.stroke_opacity = opacity
200+
setattr(self, opacity_name, opacity)
201+
if color is not None:
202+
setattr(self, color_name, color)
197203
return self
198204

199205
def set_background_stroke(self, **kwargs):

tests/test_stroke.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from manim import VMobject
2+
import manim.utils.color as C
3+
4+
5+
def test_stroke_props_in_ctor():
6+
m = VMobject(stroke_color=C.ORANGE, stroke_width=10)
7+
assert m.stroke_color == C.ORANGE
8+
assert m.stroke_width == 10
9+
10+
11+
def test_set_stroke():
12+
m = VMobject()
13+
m.set_stroke(color=C.ORANGE, width=2, opacity=0.8)
14+
assert m.stroke_width == 2
15+
assert m.stroke_opacity == 0.8
16+
assert m.stroke_color == C.ORANGE
17+
18+
19+
def test_set_background_stroke():
20+
m = VMobject()
21+
m.set_stroke(color=C.ORANGE, width=2, opacity=0.8, background=True)
22+
assert m.background_stroke_width == 2
23+
assert m.background_stroke_opacity == 0.8
24+
assert m.background_stroke_color == C.ORANGE

0 commit comments

Comments
 (0)