From 57f5b3758edfd2657f018d2be189eb0613d9aabc Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Wed, 1 Jul 2020 08:29:25 -0700 Subject: [PATCH] Fixed negative positioning --- displayio/tilegrid.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/displayio/tilegrid.py b/displayio/tilegrid.py index 04ceb08..2b2f8c7 100644 --- a/displayio/tilegrid.py +++ b/displayio/tilegrid.py @@ -215,7 +215,7 @@ class TileGrid: ) image.putalpha(alpha.convert("L")) - # pylint: disable=too-many-locals + # pylint: disable=too-many-locals,too-many-branches def _fill_area(self, buffer): """Draw onto the image""" if self._hidden: @@ -276,9 +276,20 @@ class TileGrid: y *= self._absolute_transform.dy x += self._absolute_transform.x y += self._absolute_transform.y - buffer.alpha_composite(image, (int(x), int(y))) - # pylint: enable=too-many-locals + source_x = source_y = 0 + if x < 0: + source_x = 0 - x + x = 0 + if y < 0: + source_y = 0 - y + y = 0 + + buffer.alpha_composite( + image, (round(x), round(y)), source=(round(source_x), round(source_y)) + ) + + # pylint: enable=too-many-locals,too-many-branches @property def hidden(self): -- 2.49.0