simple_ppm writer.

This commit is contained in:
2018-09-08 17:32:12 -07:00
parent 0c5c6381fc
commit 3dfd71282b
5 changed files with 38 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
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 r = i as f32 / nx as f32;
let g = j as f32 / ny as f32;
let b = 0.2;
let ir = (255.99 * r) as u8;
let ig = (255.99 * g) as u8;
let ib = (255.99 * b) as u8;
println!("{} {} {}", ir, ig, ib);
}
}
Ok(())
}

7
rtiow/src/lib.rs Normal file
View File

@@ -0,0 +1,7 @@
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}