Skip to content

Commit

Permalink
Handle -scale to 0 correctly in Group
Browse files Browse the repository at this point in the history
  • Loading branch information
tannewt committed May 9, 2019
1 parent 9ce042a commit e64bbc4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions shared-module/displayio/Group.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ void displayio_group_construct(displayio_group_t* self, displayio_group_child_t*
bool displayio_group_get_pixel(displayio_group_t *self, int16_t x, int16_t y, uint16_t* pixel) {
x -= self->x;
y -= self->y;
// When we are scaled we need to substract all but one to ensure -scale to 0 divide down to -1.
// Normally -scale to scale both divide down to 0 because 0 is unsigned.
if (x < 0) {
x -= self->scale - 1;
}
if (y < 0) {
y -= self->scale - 1;
}
x /= self->scale;
y /= self->scale;
for (int32_t i = self->size - 1; i >= 0 ; i--) {
Expand Down

0 comments on commit e64bbc4

Please sign in to comment.