diff options
| -rw-r--r-- | hittekaart/src/layer.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/hittekaart/src/layer.rs b/hittekaart/src/layer.rs index 0ab1975..1c860ad 100644 --- a/hittekaart/src/layer.rs +++ b/hittekaart/src/layer.rs @@ -102,7 +102,7 @@ impl<P: Pixel> TileLayer<P> { let source_height = u64::from(source.height()); for tx in x / TILE_WIDTH..=(x + source_width) / TILE_WIDTH { for ty in y / TILE_HEIGHT..=(y + source_height) / TILE_HEIGHT { - let tile = self.tile_mut(tx, ty); + let mut tile = None; let offset_x = (tx * TILE_WIDTH).saturating_sub(x); let offset_y = (ty * TILE_HEIGHT).saturating_sub(y); let local_min_x = x.saturating_sub(tx * TILE_WIDTH); @@ -115,8 +115,13 @@ impl<P: Pixel> TileLayer<P> { let pixel = source .get_pixel(source_x.try_into().unwrap(), source_y.try_into().unwrap()); if pixel.channels() != zero.channels() { - *tile.get_pixel_mut(x.try_into().unwrap(), y.try_into().unwrap()) = - *pixel; + if tile.is_none() { + tile = Some(self.tile_mut(tx, ty)); + } + tile.iter_mut().for_each(|t| { + *t.get_pixel_mut(x.try_into().unwrap(), y.try_into().unwrap()) = + *pixel; + }); } } } |
