mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Merge pull request #4580 from radarhere/curve
Fixed drawing a jointed line with a sequence of numeric values
This commit is contained in:
commit
52c66bbcfb
|
@ -873,28 +873,93 @@ def test_wide_line_dot():
|
|||
assert_image_similar(im, Image.open(expected), 1)
|
||||
|
||||
|
||||
def test_line_joint():
|
||||
@pytest.mark.parametrize(
|
||||
"xy",
|
||||
[
|
||||
[
|
||||
(400, 280),
|
||||
(380, 280),
|
||||
(450, 280),
|
||||
(440, 120),
|
||||
(350, 200),
|
||||
(310, 280),
|
||||
(300, 280),
|
||||
(250, 280),
|
||||
(250, 200),
|
||||
(150, 200),
|
||||
(150, 260),
|
||||
(50, 200),
|
||||
(150, 50),
|
||||
(250, 100),
|
||||
],
|
||||
(
|
||||
400,
|
||||
280,
|
||||
380,
|
||||
280,
|
||||
450,
|
||||
280,
|
||||
440,
|
||||
120,
|
||||
350,
|
||||
200,
|
||||
310,
|
||||
280,
|
||||
300,
|
||||
280,
|
||||
250,
|
||||
280,
|
||||
250,
|
||||
200,
|
||||
150,
|
||||
200,
|
||||
150,
|
||||
260,
|
||||
50,
|
||||
200,
|
||||
150,
|
||||
50,
|
||||
250,
|
||||
100,
|
||||
),
|
||||
[
|
||||
400,
|
||||
280,
|
||||
380,
|
||||
280,
|
||||
450,
|
||||
280,
|
||||
440,
|
||||
120,
|
||||
350,
|
||||
200,
|
||||
310,
|
||||
280,
|
||||
300,
|
||||
280,
|
||||
250,
|
||||
280,
|
||||
250,
|
||||
200,
|
||||
150,
|
||||
200,
|
||||
150,
|
||||
260,
|
||||
50,
|
||||
200,
|
||||
150,
|
||||
50,
|
||||
250,
|
||||
100,
|
||||
],
|
||||
],
|
||||
)
|
||||
def test_line_joint(xy):
|
||||
im = Image.new("RGB", (500, 325))
|
||||
draw = ImageDraw.Draw(im)
|
||||
expected = "Tests/images/imagedraw_line_joint_curve.png"
|
||||
|
||||
# Act
|
||||
xy = [
|
||||
(400, 280),
|
||||
(380, 280),
|
||||
(450, 280),
|
||||
(440, 120),
|
||||
(350, 200),
|
||||
(310, 280),
|
||||
(300, 280),
|
||||
(250, 280),
|
||||
(250, 200),
|
||||
(150, 200),
|
||||
(150, 260),
|
||||
(50, 200),
|
||||
(150, 50),
|
||||
(250, 100),
|
||||
]
|
||||
draw.line(xy, GRAY, 50, "curve")
|
||||
|
||||
# Assert
|
||||
|
|
|
@ -156,6 +156,8 @@ class ImageDraw:
|
|||
if ink is not None:
|
||||
self.draw.draw_lines(xy, ink, width)
|
||||
if joint == "curve" and width > 4:
|
||||
if not isinstance(xy[0], (list, tuple)):
|
||||
xy = [tuple(xy[i : i + 2]) for i in range(0, len(xy), 2)]
|
||||
for i in range(1, len(xy) - 1):
|
||||
point = xy[i]
|
||||
angles = [
|
||||
|
|
Loading…
Reference in New Issue
Block a user