use super::{utility, Color, Rgb, RgbImage};

pub fn put_color(img: &mut RgbImage, pixel_color: &Color, x: u32, y: u32, samples_per_pixel: u32) {
    /*let mut r = pixel_color.x();
    let mut g = pixel_color.y();
    let mut b = pixel_color.z();

    let scale = 1.0 / samples_per_pixel as f64;
    r = (scale * r).sqrt();
    g = (scale * g).sqrt();
    b = (scale * b).sqrt();*/

    img.put_pixel(
        x,
        y,
        Rgb([
            (256.0 * utility::clamp(pixel_color.x(), 0.0, 0.999)) as u8,
            (256.0 * utility::clamp(pixel_color.y(), 0.0, 0.999)) as u8,
            (256.0 * utility::clamp(pixel_color.z(), 0.0, 0.999)) as u8,
        ]),
    );
}
