summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/pixels.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/core/src/pixels.rs b/core/src/pixels.rs
index f5550a10..a1ea0f15 100644
--- a/core/src/pixels.rs
+++ b/core/src/pixels.rs
@@ -9,6 +9,11 @@
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Default)]
pub struct Pixels(pub f32);
+impl Pixels {
+ /// Zero pixels.
+ pub const ZERO: Self = Self(0.0);
+}
+
impl From<f32> for Pixels {
fn from(amount: f32) -> Self {
Self(amount)
@@ -58,3 +63,19 @@ impl std::ops::Mul<f32> for Pixels {
Pixels(self.0 * rhs)
}
}
+
+impl std::ops::Div for Pixels {
+ type Output = Pixels;
+
+ fn div(self, rhs: Self) -> Self {
+ Pixels(self.0 / rhs.0)
+ }
+}
+
+impl std::ops::Div<f32> for Pixels {
+ type Output = Pixels;
+
+ fn div(self, rhs: f32) -> Self {
+ Pixels(self.0 / rhs)
+ }
+}