mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 10:16:17 +03:00
Fixed connecting discontiguous corners
This commit is contained in:
parent
0e3f51dec6
commit
fb3d80e390
Binary file not shown.
Before Width: | Height: | Size: 486 B After Width: | Height: | Size: 533 B |
|
@ -1674,6 +1674,9 @@ def test_continuous_horizontal_edges_polygon() -> None:
|
||||||
def test_discontiguous_corners_polygon() -> None:
|
def test_discontiguous_corners_polygon() -> None:
|
||||||
img, draw = create_base_image_draw((84, 68))
|
img, draw = create_base_image_draw((84, 68))
|
||||||
draw.polygon(((1, 21), (34, 4), (71, 1), (38, 18)), BLACK)
|
draw.polygon(((1, 21), (34, 4), (71, 1), (38, 18)), BLACK)
|
||||||
|
draw.polygon(
|
||||||
|
((82, 29), (82, 26), (82, 24), (67, 22), (52, 29), (52, 15), (67, 22)), BLACK
|
||||||
|
)
|
||||||
draw.polygon(((71, 44), (38, 27), (1, 24)), BLACK)
|
draw.polygon(((71, 44), (38, 27), (1, 24)), BLACK)
|
||||||
draw.polygon(
|
draw.polygon(
|
||||||
((38, 66), (5, 49), (77, 49), (47, 66), (82, 63), (82, 47), (1, 47), (1, 63)),
|
((38, 66), (5, 49), (77, 49), (47, 66), (82, 63), (82, 47), (1, 47), (1, 63)),
|
||||||
|
|
|
@ -501,7 +501,8 @@ polygon_generic(
|
||||||
// Needed to draw consistent polygons
|
// Needed to draw consistent polygons
|
||||||
xx[j] = xx[j - 1];
|
xx[j] = xx[j - 1];
|
||||||
j++;
|
j++;
|
||||||
} else if (current->dx != 0 && roundf(xx[j - 1]) == xx[j - 1]) {
|
} else if (current->dx != 0 && j % 2 == 1 &&
|
||||||
|
roundf(xx[j - 1]) == xx[j - 1]) {
|
||||||
// Connect discontiguous corners
|
// Connect discontiguous corners
|
||||||
for (k = 0; k < i; k++) {
|
for (k = 0; k < i; k++) {
|
||||||
Edge *other_edge = edge_table[k];
|
Edge *other_edge = edge_table[k];
|
||||||
|
@ -510,10 +511,8 @@ polygon_generic(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Check if the two edges join to make a corner
|
// Check if the two edges join to make a corner
|
||||||
if (((ymin == current->ymin && ymin == other_edge->ymin) ||
|
if (xx[j - 1] ==
|
||||||
(ymin == current->ymax && ymin == other_edge->ymax)) &&
|
(ymin - other_edge->y0) * other_edge->dx + other_edge->x0) {
|
||||||
xx[j - 1] == (ymin - other_edge->y0) * other_edge->dx +
|
|
||||||
other_edge->x0) {
|
|
||||||
// Determine points from the edges on the next row
|
// Determine points from the edges on the next row
|
||||||
// Or if this is the last row, check the previous row
|
// Or if this is the last row, check the previous row
|
||||||
int offset = ymin == ymax ? -1 : 1;
|
int offset = ymin == ymax ? -1 : 1;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user