From 202364bfca3b5ab84c07d1cdd76bb1e7d3cb6784 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 4 Mar 2023 18:08:20 +0100 Subject: [PATCH] main: factor out overlay_chunk() function to build region images --- src/main.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 054b659..899e772 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,6 +59,19 @@ impl Config { } } +fn overlay_chunk(image: &mut I, chunk: &J, coords: ChunkCoords) +where + I: image::GenericImage, + J: image::GenericImageView, +{ + image::imageops::overlay( + image, + chunk, + coords.x.0 as i64 * BLOCKS_PER_CHUNK as i64, + coords.z.0 as i64 * BLOCKS_PER_CHUNK as i64, + ); +} + /// Type with methods for processing the regions of a Minecraft save directory struct RegionProcessor<'a> { block_types: resource::BlockTypes, @@ -209,12 +222,7 @@ impl<'a> TileRenderer<'a> { }, ) }); - image::imageops::overlay( - image, - &chunk_image, - coords.x.0 as i64 * BLOCKS_PER_CHUNK as i64, - coords.z.0 as i64 * BLOCKS_PER_CHUNK as i64, - ); + overlay_chunk(image, &chunk_image, coords); } fn render_region(image: &mut image::RgbaImage, region: &ProcessedRegion) {