ft: 2.1+2.2: image output

This commit is contained in:
2026-04-14 22:56:11 +02:00
commit 6787bb5cfd
5 changed files with 1029 additions and 0 deletions

23
src/main.rs Normal file
View File

@@ -0,0 +1,23 @@
fn main() {
let image_width = 256;
let image_height = 256;
let mut imgbuf = image::ImageBuffer::new(image_width, image_height);
for j in 0..image_height {
for i in 0..image_width {
let r = i as f32 / (image_width - 1) as f32;
let g = j as f32 / (image_height - 1) as f32;
let b = 0.0;
let ir = (255.599 * r) as u8;
let ig = (255.599 * g) as u8;
let ib = (255.599 * b) as u8;
let pixel = imgbuf.get_pixel_mut(i, j);
*pixel = image::Rgb([ir, ig, ib]);
}
}
imgbuf.save("output.png").unwrap();
}