Skip to content

Commit 2314513

Browse files
authored
Merge pull request adafruit#1872 from tannewt/fix_1839
Handle -scale to 0 correctly in Group
2 parents 7bfee58 + e64bbc4 commit 2314513

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

shared-module/displayio/Group.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ void displayio_group_construct(displayio_group_t* self, displayio_group_child_t*
128128
bool displayio_group_get_pixel(displayio_group_t *self, int16_t x, int16_t y, uint16_t* pixel) {
129129
x -= self->x;
130130
y -= self->y;
131+
// When we are scaled we need to substract all but one to ensure -scale to 0 divide down to -1.
132+
// Normally -scale to scale both divide down to 0 because 0 is unsigned.
133+
if (x < 0) {
134+
x -= self->scale - 1;
135+
}
136+
if (y < 0) {
137+
y -= self->scale - 1;
138+
}
131139
x /= self->scale;
132140
y /= self->scale;
133141
for (int32_t i = self->size - 1; i >= 0 ; i--) {

0 commit comments

Comments
 (0)