2022-05-05 13:19:56 +02:00
|
|
|
use super::{Color, Rgb, RgbImage};
|
2022-04-20 18:59:29 +02:00
|
|
|
use std::io::Write;
|
2022-04-20 18:58:58 +02:00
|
|
|
|
2022-05-05 13:19:56 +02:00
|
|
|
pub fn write_color(out: &mut impl Write, pixel_color: &Color) {
|
2022-04-20 18:59:29 +02:00
|
|
|
write!(
|
|
|
|
out,
|
|
|
|
"{} {} {}\n",
|
|
|
|
(255.999 * pixel_color.x()) as u32,
|
|
|
|
(255.999 * pixel_color.y()) as u32,
|
|
|
|
(255.999 * pixel_color.z()) as u32
|
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
}
|
2022-05-05 13:19:56 +02:00
|
|
|
|
|
|
|
pub fn put_color(img: &mut RgbImage, pixel_color: &Color, x: u32, y: u32) {
|
|
|
|
img.put_pixel(x, y, Rgb(
|
|
|
|
[(255.999 * pixel_color.x()) as u8,
|
|
|
|
(255.999 * pixel_color.y()) as u8,
|
|
|
|
(255.999 * pixel_color.z()) as u8]));
|
|
|
|
}
|