use super::Empty;
#[doc(hidden)]
pub trait Scale: Sized {
fn inner_scale(self, scale: (f32, f32)) -> Scaling;
}
#[doc(hidden)]
#[derive(Copy, Clone)]
pub struct Scaling {
pub(crate) scale_x: f32,
pub(crate) scale_y: f32,
}
impl Scaling {
pub(crate) const fn new((scale_x, scale_y): (f32, f32)) -> Self {
Self { scale_x, scale_y }
}
}
impl Scale for Scaling {
#[inline]
fn inner_scale(mut self, (scale_x, scale_y): (f32, f32)) -> Scaling {
self.scale_x *= scale_x;
self.scale_y *= scale_y;
self
}
}
impl Default for Scaling {
fn default() -> Self {
Self {
scale_x: 1.0,
scale_y: 1.0,
}
}
}
impl Scale for Empty {
fn inner_scale(self, scale: (f32, f32)) -> Scaling {
Scaling::new(scale)
}
}