mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Use hypot function
This commit is contained in:
parent
b667fd83cf
commit
c1fe0b4e0c
BIN
Tests/images/imagedraw_wide_line_larger_than_int.png
Normal file
BIN
Tests/images/imagedraw_wide_line_larger_than_int.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 557 B |
|
@ -887,6 +887,19 @@ def test_wide_line_dot():
|
|||
assert_image_similar(im, Image.open(expected), 1)
|
||||
|
||||
|
||||
def test_wide_line_larger_than_int():
|
||||
# Arrange
|
||||
im = Image.new("RGB", (W, H))
|
||||
draw = ImageDraw.Draw(im)
|
||||
expected = "Tests/images/imagedraw_wide_line_larger_than_int.png"
|
||||
|
||||
# Act
|
||||
draw.line([(0, 0), (32768, 32768)], width=3)
|
||||
|
||||
# Assert
|
||||
assert_image_similar(im, Image.open(expected), 1)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"xy",
|
||||
[
|
||||
|
|
|
@ -683,7 +683,7 @@ ImagingDrawWideLine(Imaging im, int x0, int y0, int x1, int y1,
|
|||
return 0;
|
||||
}
|
||||
|
||||
big_hypotenuse = sqrt((double) (dx*dx + dy*dy));
|
||||
big_hypotenuse = hypot(dx, dy);
|
||||
small_hypotenuse = (width - 1) / 2.0;
|
||||
ratio_max = ROUND_UP(small_hypotenuse) / big_hypotenuse;
|
||||
ratio_min = ROUND_DOWN(small_hypotenuse) / big_hypotenuse;
|
||||
|
|
Loading…
Reference in New Issue
Block a user