A community-maintained Python framework for creating mathematical animations.
fixed the stroke width issue with single color in streamlines (#3436)
Yash Mundada98a7f42ed271
diff --git a/manim/mobject/vector_field.py b/manim/mobject/vector_field.pyindex 67bdd5e6a..44432bbd2 100644--- a/manim/mobject/vector_field.py+++ b/manim/mobject/vector_field.py@@ -829,7 +829,9 @@ class StreamLines(VectorField):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 cairodiff --git a/tests/module/mobject/types/vectorized_mobject/test_stroke.py b/tests/module/mobject/types/vectorized_mobject/test_stroke.pyindex 7935caa6d..1110db14b 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 @@ from __future__ import annotationsimport manim.utils.color as Cfrom manim import VMobject+from manim.mobject.vector_field import StreamLinesdef test_stroke_props_in_ctor():@@ -24,3 +25,17 @@ def test_set_background_stroke():assert m.background_stroke_width == 2assert m.background_stroke_opacity == 0.8assert 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,+ opacity=0.2,+ color=C.BLUE_D,+ )+ assert vector_field[0].stroke_width == 1.0+ assert vector_field[0].stroke_opacity == 0.2