Skip to content

Commit 4c2d0c3

Browse files
committed
use top-left heuristic for vectorio.Polygon
this flips the bottom-right style to top-left which is at least kind of normal. A 2x2 square at (0,0) would be defined like (0,0), (3,0), (3,3), (0,3) Which seems kind of surprising but at least less bonkers than that square being defined at (1,1), which is the current behavior.
1 parent a6e0486 commit 4c2d0c3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

shared-module/vectorio/Polygon.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ uint32_t common_hal_vectorio_polygon_get_pixel(void *obj, int16_t x, int16_t y)
143143
int y2 = self->points_list[i % self->len];
144144
VECTORIO_POLYGON_DEBUG(" (%3d, %3d)}\n", x2, y2);
145145
if ( y1 <= y ) {
146-
if ( y2 > y && line_side(x1, y1, x2, y2, x, y) > 0 ) {
147-
// Wind up, point is to the right of the edge vector
146+
if ( y2 > y && line_side(x1, y1, x2, y2, x, y) < 0 ) {
147+
// Wind up, point is to the left of the edge vector
148148
++winding_number;
149149
VECTORIO_POLYGON_DEBUG(" wind:%2d winding_number:%2d\n", 1, winding_number);
150150
}
151-
} else if ( y2 <= y && line_side(x1, y1, x2, y2, x, y) < 0 ) {
152-
// Wind down, point is to the left of the edge vector
151+
} else if ( y2 <= y && line_side(x1, y1, x2, y2, x, y) > 0 ) {
152+
// Wind down, point is to the right of the edge vector
153153
--winding_number;
154154
VECTORIO_POLYGON_DEBUG(" wind:%2d winding_number:%2d\n", -1, winding_number);
155155
}

0 commit comments

Comments
 (0)