diff --git a/Tests/images/imagedraw_arc_high.png b/Tests/images/imagedraw_arc_high.png new file mode 100644 index 000000000..e3fb66cd0 Binary files /dev/null and b/Tests/images/imagedraw_arc_high.png differ diff --git a/Tests/images/imagedraw_chord_too_fat.png b/Tests/images/imagedraw_chord_too_fat.png new file mode 100644 index 000000000..2021202fe Binary files /dev/null and b/Tests/images/imagedraw_chord_too_fat.png differ diff --git a/Tests/images/imagedraw_outline_chord_RGB.png b/Tests/images/imagedraw_outline_chord_RGB.png index 9e9cb5af0..3c71312c7 100644 Binary files a/Tests/images/imagedraw_outline_chord_RGB.png and b/Tests/images/imagedraw_outline_chord_RGB.png differ diff --git a/Tests/images/imagedraw_pieslice_wide.png b/Tests/images/imagedraw_pieslice_wide.png new file mode 100644 index 000000000..446874788 Binary files /dev/null and b/Tests/images/imagedraw_pieslice_wide.png differ diff --git a/Tests/test_imagechops.py b/Tests/test_imagechops.py index 7d042cb9f..a19fbf239 100644 --- a/Tests/test_imagechops.py +++ b/Tests/test_imagechops.py @@ -311,8 +311,8 @@ def test_subtract(): # Assert assert new.getbbox() == (25, 50, 76, 76) - assert new.getpixel((50, 50)) == GREEN - assert new.getpixel((50, 51)) == BLACK + assert new.getpixel((50, 51)) == GREEN + assert new.getpixel((50, 52)) == BLACK def test_subtract_scale_offset(): @@ -350,8 +350,8 @@ def test_subtract_modulo(): # Assert assert new.getbbox() == (25, 50, 76, 76) - assert new.getpixel((50, 50)) == GREEN - assert new.getpixel((50, 51)) == BLACK + assert new.getpixel((50, 51)) == GREEN + assert new.getpixel((50, 52)) == BLACK def test_subtract_modulo_no_clip(): diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index a3bac6c3c..2742e6080 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -166,6 +166,19 @@ def test_arc_width_non_whole_angle(): assert_image_similar(im, Image.open(expected), 1) +def test_arc_high(): + # Arrange + im = Image.new("RGB", (200, 200)); + draw = ImageDraw.Draw(im) + + # Act + draw.arc([10, 10, 89, 189], 20, 330, width=20, fill="white") + draw.arc([110, 10, 189, 189], 20, 150, width=20, fill="white") + + # Assert + assert_image_equal(im, Image.open("Tests/images/imagedraw_arc_high.png")) + + def test_bitmap(): # Arrange im = Image.new("RGB", (W, H)) @@ -242,6 +255,18 @@ def test_chord_zero_width(): assert_image_equal(im, expected) +def test_chord_too_fat(): + # Arrange + im = Image.new("RGB", (100, 100)); + draw = ImageDraw.Draw(im) + + # Act + draw.chord([-150, -150, 99, 99], 15, 60, width=10, fill="white", outline="red") + + # Assert + assert_image_equal(im, Image.open("Tests/images/imagedraw_chord_too_fat.png")) + + def helper_ellipse(mode, bbox): # Arrange im = Image.new(mode, (W, H)) @@ -511,6 +536,18 @@ def test_pieslice_zero_width(): assert_image_equal(im, expected) +def test_pieslice_wide(): + # Arrange + im = Image.new("RGB", (200, 100)); + draw = ImageDraw.Draw(im) + + # Act + draw.pieslice([0, 0, 199, 99], 190, 170, width=10, fill="white", outline="red") + + # Assert + assert_image_equal(im, Image.open("Tests/images/imagedraw_pieslice_wide.png")) + + def helper_point(points): # Arrange im = Image.new("RGB", (W, H)) diff --git a/src/libImaging/Draw.c b/src/libImaging/Draw.c index 7cfc49bb5..aacbc7d23 100644 --- a/src/libImaging/Draw.c +++ b/src/libImaging/Draw.c @@ -1198,6 +1198,7 @@ void arc_init(clip_ellipse_state* s, int32_t a, int32_t b, int32_t w, float al, s->head = NULL; s->node_count = 0; + normalize_angles(&al, &ar); // building clipping tree, a lot of different cases if (ar == al + 360) { @@ -1494,7 +1495,6 @@ int ImagingDrawEllipse(Imaging im, int x0, int y0, int x1, int y1, const void* ink, int fill, int width, int op) { - //fprintf(stderr, "E (%d %d) (%d %d) --- %08X f%d w%d o%d\n", x0, y0, x1, y1, *(int*)ink, fill, width, op); return ellipseNew(im, x0, y0, x1, y1, ink, fill, width, op); } @@ -1502,7 +1502,6 @@ int ImagingDrawArc(Imaging im, int x0, int y0, int x1, int y1, float start, float end, const void* ink, int width, int op) { - //fprintf(stderr, "A (%d %d) (%d %d) %f-%f %08X f- w%d o%d\n", x0, y0, x1, y1, start, end, *(int*)ink, width, op); normalize_angles(&start, &end); if (start + 360 == end) { return ImagingDrawEllipse(im, x0, y0, x1, y1, ink, 0, width, op); @@ -1519,7 +1518,6 @@ ImagingDrawChord(Imaging im, int x0, int y0, int x1, int y1, float start, float end, const void* ink, int fill, int width, int op) { - //fprintf(stderr, "C (%d %d) (%d %d) %f-%f %08X f%d w%d o%d\n", x0, y0, x1, y1, start, end, *(int*)ink, fill, width, op); normalize_angles(&start, &end); if (start + 360 == end) { return ImagingDrawEllipse(im, x0, y0, x1, y1, ink, fill, width, op); @@ -1543,7 +1541,6 @@ ImagingDrawPieslice(Imaging im, int x0, int y0, int x1, int y1, float start, float end, const void* ink, int fill, int width, int op) { - // fprintf(stderr, "P (%d %d) (%d %d) %f-%f %08X f%d w%d o%d\n", x0, y0, x1, y1, start, end, *(int*)ink, fill, width, op); normalize_angles(&start, &end); if (start + 360 == end) { return ellipseNew(im, x0, y0, x1, y1, ink, fill, width, op);