From: Melissa LeBlanc-Williams Date: Wed, 8 Jul 2020 16:31:48 +0000 (-0700) Subject: Merge branch 'master' of https://github.com/adafruit/Adafruit_Blinka_Displayio into... X-Git-Tag: 0.5.2^2 X-Git-Url: https://git.ayoreis.com/hackapet/Adafruit_Blinka_Displayio.git/commitdiff_plain/db7b91d8910aa536357e99718e92cbae0243cde8?hp=fdc8abad54ee594f0275ed45b923ea6b4f1f3bd2 Merge branch 'master' of https://github.com/adafruit/Adafruit_Blinka_Displayio into optimization --- diff --git a/displayio/tilegrid.py b/displayio/tilegrid.py index 2b2f8c7..2c815a4 100644 --- a/displayio/tilegrid.py +++ b/displayio/tilegrid.py @@ -279,15 +279,22 @@ class TileGrid: source_x = source_y = 0 if x < 0: - source_x = 0 - x + source_x = round(0 - x) x = 0 if y < 0: - source_y = 0 - y + source_y = round(0 - y) y = 0 - buffer.alpha_composite( - image, (round(x), round(y)), source=(round(source_x), round(source_y)) - ) + x = round(x) + y = round(y) + + if ( + x <= buffer.width + and y <= buffer.height + and source_x <= image.width + and source_y <= image.height + ): + buffer.alpha_composite(image, (x, y), source=(source_x, source_y)) # pylint: enable=too-many-locals,too-many-branches