mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Added test for horizontal lines
Notice that the expansion of the line width depends on the order of the points: * If the bigger axis value is provided as the *second* point the line expand first to the *positive* side of the axis. * If the bigger axis value is provided as the *first* point the line expand first to the *negative* side of the axis. * If the line's width is odd this doesn't matter, as the line will expand the same amount to both sides. This behavior should be consistent in both horizontal and vertical lines.
This commit is contained in:
parent
e2cb2195eb
commit
fee2faa8dc
BIN
Tests/images/imagedraw/line_horizontal_w2px_inverted.png
Normal file
BIN
Tests/images/imagedraw/line_horizontal_w2px_inverted.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 143 B |
BIN
Tests/images/imagedraw/line_horizontal_w2px_normal.png
Normal file
BIN
Tests/images/imagedraw/line_horizontal_w2px_normal.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 141 B |
BIN
Tests/images/imagedraw/line_horizontal_w3px.png
Normal file
BIN
Tests/images/imagedraw/line_horizontal_w3px.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 145 B |
|
@ -70,3 +70,28 @@ def test_triangle_right():
|
|||
img, draw = create_base_image_draw((20, 20))
|
||||
draw.polygon([(3, 5), (17, 5), (10, 12)], BLACK)
|
||||
assert_image_equal(img, expected)
|
||||
|
||||
|
||||
def test_line_horizontal():
|
||||
# Normal 2px line
|
||||
expected = Image.open(os.path.join(IMAGES_PATH, 'line_horizontal_w2px_normal.png'))
|
||||
expected.load()
|
||||
img, draw = create_base_image_draw((20, 20))
|
||||
draw.line((5, 5, 14, 5), BLACK, 2)
|
||||
assert_image_equal(img, expected)
|
||||
# Inverted 2px line
|
||||
expected = Image.open(os.path.join(IMAGES_PATH, 'line_horizontal_w2px_inverted.png'))
|
||||
expected.load()
|
||||
img, draw = create_base_image_draw((20, 20))
|
||||
draw.line((14, 5, 5, 5), BLACK, 2)
|
||||
assert_image_equal(img, expected)
|
||||
# Normal 3px line
|
||||
expected = Image.open(os.path.join(IMAGES_PATH, 'line_horizontal_w3px.png'))
|
||||
expected.load()
|
||||
img, draw = create_base_image_draw((20, 20))
|
||||
draw.line((5, 5, 14, 5), BLACK, 3)
|
||||
assert_image_equal(img, expected)
|
||||
# Inverted 3px line
|
||||
img, draw = create_base_image_draw((20, 20))
|
||||
draw.line((14, 5, 5, 5), BLACK, 3)
|
||||
assert_image_equal(img, expected)
|
||||
|
|
Loading…
Reference in New Issue
Block a user