Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

fix - corrections for setting stroke related attributes on VMobject (#1051)

Kapil Sachdeva57a24e3d414d
diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.py
index 2c54a985b..7baa03862 100644
--- a/manim/mobject/types/vectorized_mobject.py
+++ b/manim/mobject/types/vectorized_mobject.py
@@ -186,14 +186,20 @@ class VMobject(Mobject):
if background:
array_name = "background_stroke_rgbas"
width_name = "background_stroke_width"
+ opacity_name = "background_stroke_opacity"
+ color_name = "background_stroke_color"
else:
array_name = "stroke_rgbas"
width_name = "stroke_width"
+ opacity_name = "stroke_opacity"
+ color_name = "stroke_color"
self.update_rgbas_array(array_name, color, opacity)
if width is not None:
setattr(self, width_name, width)
if opacity is not None:
- self.stroke_opacity = opacity
+ setattr(self, opacity_name, opacity)
+ if color is not None:
+ setattr(self, color_name, color)
return self
def set_background_stroke(self, **kwargs):
diff --git a/tests/test_stroke.py b/tests/test_stroke.py
new file mode 100644
index 000000000..2fb7337ed
--- /dev/null
+++ b/tests/test_stroke.py
@@ -0,0 +1,24 @@
+from manim import VMobject
+import manim.utils.color as C
+
+
+def test_stroke_props_in_ctor():
+ m = VMobject(stroke_color=C.ORANGE, stroke_width=10)
+ assert m.stroke_color == C.ORANGE
+ assert m.stroke_width == 10
+
+
+def test_set_stroke():
+ m = VMobject()
+ m.set_stroke(color=C.ORANGE, width=2, opacity=0.8)
+ assert m.stroke_width == 2
+ assert m.stroke_opacity == 0.8
+ assert m.stroke_color == C.ORANGE
+
+
+def test_set_background_stroke():
+ m = VMobject()
+ m.set_stroke(color=C.ORANGE, width=2, opacity=0.8, background=True)
+ assert m.background_stroke_width == 2
+ assert m.background_stroke_opacity == 0.8
+ assert m.background_stroke_color == C.ORANGE