Skip to content

Commit 311cc48

Browse files
committed
🙋 render example ppm
1 parent a096780 commit 311cc48

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ Cargo.lock
1111

1212
/target
1313
**/*.rs.bk
14+
15+
result.ppm

src/main.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
fn main() {
2-
println!("Hello, world!");
2+
let max_i = 200;
3+
let max_j = 200;
4+
5+
println!("P3\n{} {} 255", max_i, max_j);
6+
for i in 0..max_i {
7+
for j in 0..max_j {
8+
let r: f32 = i as f32 / max_i as f32;
9+
let g: f32 = j as f32 / max_j as f32;
10+
let b: f32 = 0.2;
11+
12+
let ir = (255.00 * r).round();
13+
let ig = (255.00 * g).round();
14+
let ib = (255.00 * b).round();
15+
println!("{} {} {}", ir, ig, ib);
16+
}
17+
}
318
}

0 commit comments

Comments
 (0)