Use Vec3 in main program.

This commit is contained in:
Bill Thiede 2018-09-08 19:50:13 -07:00
parent 7f7b1d6d34
commit 577fa32b2d

20
rtiow/src/bin/vec3_ppm.rs Normal file
View File

@ -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(())
}