Skip to main content

freya_core/style/
scale.rs

1/// A scale factor applied to an element on each axis, where `1.0` is the original size.
2///
3/// Implements `From<f32>` (uniform) and `From<(f32, f32)>` (`x`, `y`).
4#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5#[derive(Debug, Default, Clone, PartialEq, Copy)]
6pub struct Scale {
7    pub x: f32,
8    pub y: f32,
9}
10
11impl From<(f32, f32)> for Scale {
12    fn from((x, y): (f32, f32)) -> Self {
13        Scale { x, y }
14    }
15}
16
17impl From<f32> for Scale {
18    fn from(x_y: f32) -> Self {
19        Scale { x: x_y, y: x_y }
20    }
21}