Skip to main content

gizmo_core/
window.rs

1#[derive(Debug, Clone, Copy, PartialEq)]
2pub struct WindowInfo {
3    pub width: f32,
4    pub height: f32,
5}
6
7impl WindowInfo {
8    pub fn new(width: f32, height: f32) -> Self {
9        Self { width, height }
10    }
11
12    pub fn size(&self) -> (f32, f32) {
13        (self.width, self.height)
14    }
15
16    pub fn aspect_ratio(&self) -> f32 {
17        if self.height > 0.0 {
18            self.width / self.height
19        } else {
20            1.0
21        }
22    }
23}
24
25impl Default for WindowInfo {
26    fn default() -> Self {
27        Self {
28            width: 1280.0,
29            height: 720.0,
30        }
31    }
32}