From e64bbc41ec0c66f6c6125401ed7a14e1bf303935 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 9 May 2019 11:38:30 -0700 Subject: [PATCH] Handle -scale to 0 correctly in Group Fixes #1839 --- shared-module/displayio/Group.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/shared-module/displayio/Group.c b/shared-module/displayio/Group.c index 12f80cac43..097edf33bd 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--) {