Skip to content

Commit 98a7f42

Browse files
yashm277pre-commit-ci[bot]MrDiver
authored
fixed the stroke width issue with single color in streamlines (#3436)
* fixed the stroke width issue with single color in streamlines * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Added test for streamlines * Added test for streamlines --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: MrDiver <[email protected]>
1 parent 1704374 commit 98a7f42

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

manim/mobject/vector_field.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,9 @@ def outside_box(p):
829829
step = max(1, int(len(points) / self.max_anchors_per_line))
830830
line.set_points_smoothly(points[::step])
831831
if self.single_color:
832-
line.set_stroke(self.color)
832+
line.set_stroke(
833+
color=self.color, width=self.stroke_width, opacity=opacity
834+
)
833835
else:
834836
if config.renderer == RendererType.OPENGL:
835837
# scaled for compatibility with cairo

tests/module/mobject/types/vectorized_mobject/test_stroke.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import manim.utils.color as C
44
from manim import VMobject
5+
from manim.mobject.vector_field import StreamLines
56

67

78
def test_stroke_props_in_ctor():
@@ -24,3 +25,17 @@ def test_set_background_stroke():
2425
assert m.background_stroke_width == 2
2526
assert m.background_stroke_opacity == 0.8
2627
assert m.background_stroke_color.to_hex() == C.ORANGE.to_hex()
28+
29+
30+
def test_streamline_attributes_for_single_color():
31+
vector_field = StreamLines(
32+
lambda x: x, # It is not important what this function is.
33+
x_range=[-1, 1, 0.1],
34+
y_range=[-1, 1, 0.1],
35+
padding=0.1,
36+
stroke_width=1.0,
37+
opacity=0.2,
38+
color=C.BLUE_D,
39+
)
40+
assert vector_field[0].stroke_width == 1.0
41+
assert vector_field[0].stroke_opacity == 0.2

0 commit comments

Comments
 (0)