1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
use bevy_property::Properties; use std::{ fmt, ops::{Deref, DerefMut}, }; #[derive(Debug, PartialEq, Clone, Copy, Properties)] pub struct Scale(pub f32); impl From<f32> for Scale { #[inline(always)] fn from(scale: f32) -> Self { Self(scale) } } impl Scale { #[inline(always)] pub fn identity() -> Self { Scale(1.0) } } impl Default for Scale { fn default() -> Self { Self::identity() } } impl fmt::Display for Scale { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Scale({})", self.0) } } impl Deref for Scale { type Target = f32; fn deref(&self) -> &Self::Target { &self.0 } } impl DerefMut for Scale { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } }