diff options
| author | Dan Halbert <halbert@adafruit.com> | 2019-05-09 22:21:40 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-09 22:21:40 -0400 |
| commit | 23145137be92cd08283b020c2c9d260b6835adb0 (patch) | |
| tree | 59feee581271e9530b73bc6a693815a4cb0efb60 | |
| parent | 7bfee580b1e8a03789e96fd0f84926929dbcb880 (diff) | |
| parent | e64bbc41ec0c66f6c6125401ed7a14e1bf303935 (diff) | |
Merge pull request #1872 from tannewt/fix_1839
Handle -scale to 0 correctly in Group
| -rw-r--r-- | shared-module/displayio/Group.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/shared-module/displayio/Group.c b/shared-module/displayio/Group.c index 12f80cac4..097edf33b 100644 --- a/shared-module/displayio/Group.c +++ b/shared-module/displayio/Group.c @@ -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--) { |
