Skip to content

Commit 13c3d06

Browse files
authored
Merge pull request adafruit#1952 from tannewt/fixup_tilegrid_dirty
Fix TileGrid's dirty tracking when changing top left
2 parents e6ded8d + 7490adf commit 13c3d06

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

shared-module/displayio/TileGrid.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,19 @@ void common_hal_displayio_tilegrid_set_tile(displayio_tilegrid_t *self, uint16_t
219219
} else {
220220
tile_area = &temp_area;
221221
}
222-
tile_area->x1 = x * self->tile_width;
222+
int16_t tx = (x - self->top_left_x) % self->width_in_tiles;
223+
if (tx < 0) {
224+
tx += self->width_in_tiles;
225+
}
226+
tile_area->x1 = tx * self->tile_width;
223227
tile_area->x2 = tile_area->x1 + self->tile_width;
224-
tile_area->y1 = y * self->tile_height;
228+
int16_t ty = (y - self->top_left_y) % self->height_in_tiles;
229+
if (ty < 0) {
230+
ty += self->height_in_tiles;
231+
}
232+
tile_area->y1 = ty * self->tile_height;
225233
tile_area->y2 = tile_area->y1 + self->tile_height;
234+
226235
if (self->partial_change) {
227236
displayio_area_expand(&self->dirty_area, &temp_area);
228237
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy