Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed the stroke width issue with single color in streamlines #3436

Merged
merged 7 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion manim/mobject/vector_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(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
Expand Down
15 changes: 15 additions & 0 deletions tests/module/mobject/types/vectorized_mobject/test_stroke.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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,
opacity=0.2,
color=C.BLUE_D,
)
assert vector_field[0].stroke_width == 1.0
assert vector_field[0].stroke_opacity == 0.2
Loading