From a2185f17c2e8d668726492f15fb9efb1fccba988 Mon Sep 17 00:00:00 2001 From: yashm277 Date: Sat, 4 Nov 2023 03:56:47 +0530 Subject: [PATCH 1/4] fixed the stroke width issue with single color in streamlines --- manim/mobject/vector_field.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manim/mobject/vector_field.py b/manim/mobject/vector_field.py index 67bdd5e6a2..68dd957aaa 100644 --- a/manim/mobject/vector_field.py +++ b/manim/mobject/vector_field.py @@ -829,7 +829,7 @@ def outside_box(p): step = max(1, int(len(points) / self.max_anchors_per_line)) line.set_points_smoothly(points[::step]) if self.single_color: - line.set_stroke(self.color) + line.set_stroke(color=self.color, width=self.stroke_width, opacity=opacity) else: if config.renderer == RendererType.OPENGL: # scaled for compatibility with cairo From f314360df707d50decb50c8f2fb55d5af5bc54de Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 3 Nov 2023 22:36:51 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- manim/mobject/vector_field.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/manim/mobject/vector_field.py b/manim/mobject/vector_field.py index 68dd957aaa..44432bbd23 100644 --- a/manim/mobject/vector_field.py +++ b/manim/mobject/vector_field.py @@ -829,7 +829,9 @@ def outside_box(p): step = max(1, int(len(points) / self.max_anchors_per_line)) line.set_points_smoothly(points[::step]) if self.single_color: - line.set_stroke(color=self.color, width=self.stroke_width, opacity=opacity) + line.set_stroke( + color=self.color, width=self.stroke_width, opacity=opacity + ) else: if config.renderer == RendererType.OPENGL: # scaled for compatibility with cairo From 6f3e53a753e8ee4dfe484be03a48be36b9bad7b6 Mon Sep 17 00:00:00 2001 From: MrDiver Date: Sun, 10 Dec 2023 17:19:49 +0100 Subject: [PATCH 3/4] Added test for streamlines --- .../types/vectorized_mobject/test_stroke.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/module/mobject/types/vectorized_mobject/test_stroke.py b/tests/module/mobject/types/vectorized_mobject/test_stroke.py index 7935caa6da..e64893d049 100644 --- a/tests/module/mobject/types/vectorized_mobject/test_stroke.py +++ b/tests/module/mobject/types/vectorized_mobject/test_stroke.py @@ -2,6 +2,7 @@ import manim.utils.color as C from manim import VMobject +from manim.mobject.vector_field import StreamLines def test_stroke_props_in_ctor(): @@ -24,3 +25,17 @@ def test_set_background_stroke(): assert m.background_stroke_width == 2 assert m.background_stroke_opacity == 0.8 assert m.background_stroke_color.to_hex() == C.ORANGE.to_hex() + + +def test_streamline_attributes_for_single_color(): + vector_field = StreamLines( + lambda x: x, # It is not important what this function is. + x_range=[-1, 1, 0.1], + y_range=[-1, 1, 0.1], + padding=0.1, + stroke_width=1.0, # Default is 4.0, hence I would expect them thinner. + opacity=0.2, + color=C.BLUE_D, + ) + assert vector_field[0].stroke_width == 1.0 + assert vector_field[0].stroke_opacity == 0.2 From e2dce17e2139a2fbf87b7e1603750774cf06d2a7 Mon Sep 17 00:00:00 2001 From: MrDiver Date: Sun, 10 Dec 2023 17:20:50 +0100 Subject: [PATCH 4/4] Added test for streamlines --- tests/module/mobject/types/vectorized_mobject/test_stroke.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/module/mobject/types/vectorized_mobject/test_stroke.py b/tests/module/mobject/types/vectorized_mobject/test_stroke.py index e64893d049..1110db14b8 100644 --- a/tests/module/mobject/types/vectorized_mobject/test_stroke.py +++ b/tests/module/mobject/types/vectorized_mobject/test_stroke.py @@ -33,7 +33,7 @@ def test_streamline_attributes_for_single_color(): x_range=[-1, 1, 0.1], y_range=[-1, 1, 0.1], padding=0.1, - stroke_width=1.0, # Default is 4.0, hence I would expect them thinner. + stroke_width=1.0, opacity=0.2, color=C.BLUE_D, )