diff --git a/src/lib.rs b/src/lib.rs index 979abad..fdd39d5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -39,10 +39,8 @@ pub fn add_tiles(game_data: String, image: String, prefix: String) -> String { let height = image.height(); assert_eq!(width % 8, 0); assert_eq!(height % 8, 0); - let columns = (width as f64 / 8 as f64).floor() as u32; - let rows = (height as f64 / 8 as f64).floor() as u32; - - // todo iterate over 8x8 tiles in image + let columns = (width as f64 / 8.).floor() as u32; + let rows = (height as f64 / 8.).floor() as u32; let mut tile_index = 1; @@ -53,7 +51,7 @@ pub fn add_tiles(game_data: String, image: String, prefix: String) -> String { for y in (row * SD)..((row + 1) * SD) { for x in (column * SD)..((column + 1) * SD) { let pixel = image.get_pixel(x, y).to_rgb(); - let total: u32 = (pixel[0] as u32 + pixel[1] as u32 + pixel[2] as u32) as u32; + let total = pixel[0] as u32 + pixel[1] as u32 + pixel[2] as u32; // is each channel brighter than 128/255 on average? pixels.push(if total >= 384 {1} else {0}); }