simple_ppm writer.
This commit is contained in:
parent
0c5c6381fc
commit
3dfd71282b
4
rtiow/Cargo.lock
generated
Normal file
4
rtiow/Cargo.lock
generated
Normal file
@ -0,0 +1,4 @@
|
||||
[[package]]
|
||||
name = "rtiow"
|
||||
version = "0.1.0"
|
||||
|
||||
6
rtiow/Cargo.toml
Normal file
6
rtiow/Cargo.toml
Normal 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
3
rtiow/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# What?
|
||||
Implementations of the concepts explored by Peter Shirley in "Ray Tracing in
|
||||
One Weekend"
|
||||
18
rtiow/src/bin/simple_ppm.rs
Normal file
18
rtiow/src/bin/simple_ppm.rs
Normal 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
7
rtiow/src/lib.rs
Normal file
@ -0,0 +1,7 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn it_works() {
|
||||
assert_eq!(2 + 2, 4);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user