From 577fa32b2d3a072bf64820160c76fc7064249858 Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Sat, 8 Sep 2018 19:50:13 -0700 Subject: [PATCH] Use Vec3 in main program. --- rtiow/src/bin/vec3_ppm.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 rtiow/src/bin/vec3_ppm.rs 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(()) +}