fn apply_ambient(&self, color: image::Rgb<u8>) -> image::Rgb<u8> {
        let red = {
            let c = f64::from(color[0]) * self.ambient_light;
            if c > 255.0 {
                255 as u8
            } else {
                c as u8
            }
        };
        let green = {
            let c = f64::from(color[1]) * self.ambient_light;
            if c > 255.0 {
                255 as u8
            } else {
                c as u8
            }
        };
        let blue = {
            let c = f64::from(color[2]) * self.ambient_light;
            if c > 255.0 {
                255 as u8
            } else {
                c as u8
            }
        };
        image::Rgb([red, green, blue])
    }
/// Safe application of ambient lighting to a color while avoiding overflow.
Safe application of ambient lighting to a color while avoiding overflow.
Safe application of ambient lighting to a color while avoiding overflow .
fn apply_ambient(&self, color: image::Rgb<u8>) -> image::Rgb<u8> {
        let red = {
            let c = f64::from(color[0]) * self.ambient_light;
            if c > 255.0 {
                255 as u8
            } else {
                c as u8
            }
        };
        let green = {
            let c = f64::from(color[1]) * self.ambient_light;
            if c > 255.0 {
                255 as u8
            } else {
                c as u8
            }
        };
        let blue = {
            let c = f64::from(color[2]) * self.ambient_light;
            if c > 255.0 {
                255 as u8
            } else {
                c as u8
            }
        };
        image::Rgb([red, green, blue])
    }
fn apply_ambient ( & self , color : image :: Rgb < u8 > ) -> image :: Rgb < u8 > { let red = { let c = f64 :: from ( color [ 0 ] ) * self . ambient_light ; if c > 255.0 { 255 as u8 } else { c as u8 } } ; let green = { let c = f64 :: from ( color [ 1 ] ) * self . ambient_light ; if c > 255.0 { 255 as u8 } else { c as u8 } } ; let blue = { let c = f64 :: from ( color [ 2 ] ) * self . ambient_light ; if c > 255.0 { 255 as u8 } else { c as u8 } } ; image :: Rgb ( [ red , green , blue ] ) }
Safe application of ambient lighting to a color while avoiding overflow.
Safe application of ambient lighting to a color while avoiding overflow .
&self
color
image::Rgb<u8>