Skip to content

use top-left heuristic for vectorio.Polygon #3221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions shared-module/vectorio/Polygon.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ uint32_t common_hal_vectorio_polygon_get_pixel(void *obj, int16_t x, int16_t y)
int y2 = self->points_list[i % self->len];
VECTORIO_POLYGON_DEBUG(" (%3d, %3d)}\n", x2, y2);
if ( y1 <= y ) {
if ( y2 > y && line_side(x1, y1, x2, y2, x, y) > 0 ) {
// Wind up, point is to the right of the edge vector
if ( y2 > y && line_side(x1, y1, x2, y2, x, y) < 0 ) {
// Wind up, point is to the left of the edge vector
++winding_number;
VECTORIO_POLYGON_DEBUG(" wind:%2d winding_number:%2d\n", 1, winding_number);
}
} else if ( y2 <= y && line_side(x1, y1, x2, y2, x, y) < 0 ) {
// Wind down, point is to the left of the edge vector
} else if ( y2 <= y && line_side(x1, y1, x2, y2, x, y) > 0 ) {
// Wind down, point is to the right of the edge vector
--winding_number;
VECTORIO_POLYGON_DEBUG(" wind:%2d winding_number:%2d\n", -1, winding_number);
}
Expand Down