simple_ppm writer.

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

4
rtiow/Cargo.lock generated Normal file
View File

@ -0,0 +1,4 @@
[[package]]
name = "rtiow"
version = "0.1.0"

6
rtiow/Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "rtiow"
version = "0.1.0"
authors = ["Bill Thiede <rust@xinu.tv>"]
[dependencies]

3
rtiow/README.md Normal file
View File

@ -0,0 +1,3 @@
# What?
Implementations of the concepts explored by Peter Shirley in "Ray Tracing in
One Weekend"

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);
}
}