Skip to content

Commit e90a9d6

Browse files
committed
Fix render being stretched
1 parent 89a2bf5 commit e90a9d6

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/camera.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ impl Camera {
3939
eprintln!("\rDone. \n");
4040
}
4141
fn initialize(&mut self) {
42-
// Fix image stretcheness
4342
self.image_height = (self.image_width as f32/self.aspect_ratio) as i32;
4443
self.image_height = if self.image_height < 1 {1} else {self.image_height};
4544

@@ -48,7 +47,7 @@ impl Camera {
4847
self.center = Point3::from(0.0, 0.0, 0.0);
4948
let focal_length = 1.0f32;
5049
let viewport_height = 2.0f32;
51-
let viewport_width = viewport_height * ((self.image_width/self.image_height) as f32);
50+
let viewport_width = viewport_height * (self.image_width as f32/self.image_height as f32);
5251

5352
let viewport_u = Vec3::from(viewport_width, 0.0, 0.0);
5453
let viewport_v = Vec3::from(0.0, -viewport_height, 0.0);

0 commit comments

Comments
 (0)