Skip to content

Commit 84ea500

Browse files
committed
smarter sizing
1 parent e952a82 commit 84ea500

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

rust_core/src/main.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,21 @@ fn get_interaction(camera: &Camera2D) -> Interaction {
113113
}
114114

115115
fn get_camera() -> Camera2D {
116-
let aspect = screen_width() / screen_height();
116+
let width = screen_width();
117+
let height = screen_height();
118+
let aspect = width / height;
119+
120+
let target_radius = 200.0;
121+
122+
let (zoom_x, zoom_y) = if width < height {
123+
(1.0 / target_radius, aspect / target_radius)
124+
} else {
125+
(1.0 / (target_radius * aspect), 1.0 / target_radius)
126+
};
127+
117128
Camera2D {
118129
target: vec2(0.0, 0.0),
119-
zoom: vec2(1.0 / 300.0, aspect / 300.0),
130+
zoom: vec2(zoom_x, zoom_y),
120131
..Default::default()
121132
}
122133
}

0 commit comments

Comments
 (0)