#[non_exhaustive]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ScreenSize {
Physical {
width_cm: u8,
height_cm: u8,
},
Landscape(u8),
Portrait(u8),
}
impl ScreenSize {
pub fn landscape_ratio(&self) -> Option<f32> {
if let Self::Landscape(v) = self {
Some((*v as f32 + 99.0) / 100.0)
} else {
None
}
}
pub fn portrait_ratio(&self) -> Option<f32> {
if let Self::Portrait(v) = self {
Some(100.0 / (*v as f32 + 99.0))
} else {
None
}
}
}