mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-28 02:04:36 +03:00
Merge pull request #4675 from radarhere/polygon
Fixed drawing a 1px high polygon
This commit is contained in:
commit
b6d6f77262
BIN
Tests/images/imagedraw_polygon_1px_high.png
Normal file
BIN
Tests/images/imagedraw_polygon_1px_high.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 73 B |
|
@ -531,6 +531,20 @@ def test_polygon_kite():
|
||||||
assert_image_equal(im, Image.open(expected))
|
assert_image_equal(im, Image.open(expected))
|
||||||
|
|
||||||
|
|
||||||
|
def test_polygon_1px_high():
|
||||||
|
# Test drawing a 1px high polygon
|
||||||
|
# Arrange
|
||||||
|
im = Image.new("RGB", (3, 3))
|
||||||
|
draw = ImageDraw.Draw(im)
|
||||||
|
expected = "Tests/images/imagedraw_polygon_1px_high.png"
|
||||||
|
|
||||||
|
# Act
|
||||||
|
draw.polygon([(0, 1), (0, 1), (2, 1), (2, 1)], "#f00")
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
assert_image_equal(im, Image.open(expected))
|
||||||
|
|
||||||
|
|
||||||
def helper_rectangle(bbox):
|
def helper_rectangle(bbox):
|
||||||
# Arrange
|
# Arrange
|
||||||
im = Image.new("RGB", (W, H))
|
im = Image.new("RGB", (W, H))
|
||||||
|
|
|
@ -489,15 +489,15 @@ polygon_generic(Imaging im, int n, Edge *e, int ink, int eofill,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
if (e[i].ymin == e[i].ymax) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (ymin > e[i].ymin) {
|
if (ymin > e[i].ymin) {
|
||||||
ymin = e[i].ymin;
|
ymin = e[i].ymin;
|
||||||
}
|
}
|
||||||
if (ymax < e[i].ymax) {
|
if (ymax < e[i].ymax) {
|
||||||
ymax = e[i].ymax;
|
ymax = e[i].ymax;
|
||||||
}
|
}
|
||||||
|
if (e[i].ymin == e[i].ymax) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
edge_table[edge_count++] = (e + i);
|
edge_table[edge_count++] = (e + i);
|
||||||
}
|
}
|
||||||
if (ymin < 0) {
|
if (ymin < 0) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user