diff options
Diffstat (limited to 'core/src/pixels.rs')
-rw-r--r-- | core/src/pixels.rs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/core/src/pixels.rs b/core/src/pixels.rs index 425c0028..f5550a10 100644 --- a/core/src/pixels.rs +++ b/core/src/pixels.rs @@ -6,7 +6,7 @@ /// (e.g. `impl Into<Pixels>`) and, since `Pixels` implements `From` both for /// `f32` and `u16`, you should be able to provide both integers and float /// literals as needed. -#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)] +#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Default)] pub struct Pixels(pub f32); impl From<f32> for Pixels { @@ -27,6 +27,30 @@ impl From<Pixels> for f32 { } } +impl std::ops::Add for Pixels { + type Output = Pixels; + + fn add(self, rhs: Self) -> Self { + Pixels(self.0 + rhs.0) + } +} + +impl std::ops::Add<f32> for Pixels { + type Output = Pixels; + + fn add(self, rhs: f32) -> Self { + Pixels(self.0 + rhs) + } +} + +impl std::ops::Mul for Pixels { + type Output = Pixels; + + fn mul(self, rhs: Self) -> Self { + Pixels(self.0 * rhs.0) + } +} + impl std::ops::Mul<f32> for Pixels { type Output = Pixels; |