From df5b57cc3924db52abbcff2485fcfc4999c6491a Mon Sep 17 00:00:00 2001 From: Louis Capitanchik <contact@louiscap.co> Date: Wed, 8 Feb 2023 01:25:59 +0000 Subject: [PATCH] Remove redundant utils --- src/utils.rs | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index d29ee7c..6dcebea 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -27,22 +27,6 @@ pub type TypedOutputFormat<T: GenericImage> = image::ImageBuffer<T::Pixel, Vec<<T::Pixel as image::Pixel>::Subpixel>>; pub type RgbaOutputFormat = TypedOutputFormat<RgbaImage>; -pub fn max_f32(a: f32, b: f32) -> f32 { - if a > b { - a - } else { - b - } -} - -pub fn min_f32(a: f32, b: f32) -> f32 { - if a < b { - a - } else { - b - } -} - pub fn new_image(new_width: u32, new_height: u32) -> OutputFormat { let mut new_image = RgbaImage::new(new_width, new_height); let (new_image_x, new_image_y, new_image_width, new_image_height) = new_image.bounds(); @@ -68,8 +52,8 @@ impl BasicRgba { let green = self.g as f32 / u8::MAX as f32; let blue = self.b as f32 / u8::MAX as f32; - let minimum = min_f32(red, min_f32(green, blue)); - let maximum = max_f32(red, max_f32(green, blue)); + let minimum = red.min(green).min(blue); + let maximum = red.max(green).max(blue); let mut hue = if red >= green && red >= blue { (green - blue) / (maximum - minimum) -- GitLab