diff --git a/rtiow/src/bin/vec3_ppm.rs b/rtiow/src/bin/vec3_ppm.rs new file mode 100644 index 0000000..627eb35 --- /dev/null +++ b/rtiow/src/bin/vec3_ppm.rs @@ -0,0 +1,20 @@ +extern crate rtiow; + +use rtiow::vec3::Vec3; + +fn main() -> Result<(), std::io::Error> { + let nx = 200; + let ny = 100; + println!("P3\n{} {}\n255", nx, ny); + for j in (0..ny).rev() { + for i in 0..nx { + let col = Vec3::new(i as f32 / nx as f32, j as f32 / ny as f32, 0.2); + + let ir = (255.99 * col[0]) as u8; + let ig = (255.99 * col[1]) as u8; + let ib = (255.99 * col[2]) as u8; + println!("{} {} {}", ir, ig, ib); + } + } + Ok(()) +}