mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Added more tests
This commit is contained in:
parent
9a9d3a050a
commit
5830a641cc
BIN
Tests/images/imagedraw_arc_high.png
Normal file
BIN
Tests/images/imagedraw_arc_high.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
Tests/images/imagedraw_chord_too_fat.png
Normal file
BIN
Tests/images/imagedraw_chord_too_fat.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 519 B |
Binary file not shown.
Before Width: | Height: | Size: 259 B After Width: | Height: | Size: 267 B |
BIN
Tests/images/imagedraw_pieslice_wide.png
Normal file
BIN
Tests/images/imagedraw_pieslice_wide.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -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():
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user