diff options
author | 2023-08-15 17:05:46 +0800 | |
---|---|---|
committer | 2024-01-31 19:21:10 +0100 | |
commit | c077e107f2eea618ea644652707254a402527de3 (patch) | |
tree | dff9d70f26d834c2cc4f4b886bc81bc3d84a8e4d /core/src/angle.rs | |
parent | 8ed3490280a4dd8a1d4e3cd421b1785725f65865 (diff) | |
download | iced-c077e107f2eea618ea644652707254a402527de3.tar.gz iced-c077e107f2eea618ea644652707254a402527de3.tar.bz2 iced-c077e107f2eea618ea644652707254a402527de3.zip |
Use `Radians` in arc and ellipse types
Diffstat (limited to 'core/src/angle.rs')
-rw-r--r-- | core/src/angle.rs | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/core/src/angle.rs b/core/src/angle.rs index 102b69cf..e63df726 100644 --- a/core/src/angle.rs +++ b/core/src/angle.rs @@ -1,7 +1,7 @@ use crate::{Point, Rectangle, Vector}; use std::f32::consts::{FRAC_PI_2, PI}; -use std::ops::RangeInclusive; +use std::ops::{Add, AddAssign, Div, Mul, RangeInclusive, Sub, SubAssign}; /// Degrees #[derive(Debug, Copy, Clone, PartialEq, PartialOrd)] @@ -71,3 +71,47 @@ impl Radians { (start, end) } } + +impl SubAssign<Radians> for Radians { + fn sub_assign(&mut self, rhs: Radians) { + self.0 = self.0 - rhs.0; + } +} + +impl AddAssign<Radians> for Radians { + fn add_assign(&mut self, rhs: Radians) { + self.0 = self.0 + rhs.0; + } +} + +impl Add<Radians> for Radians { + type Output = Radians; + + fn add(self, rhs: Radians) -> Self::Output { + Radians(self.0 + rhs.0) + } +} + +impl Sub<Radians> for Radians { + type Output = Radians; + + fn sub(self, rhs: Radians) -> Self::Output { + Radians(self.0 - rhs.0) + } +} + +impl Mul<f32> for Radians { + type Output = Radians; + + fn mul(self, rhs: f32) -> Self::Output { + Radians(self.0 * rhs) + } +} + +impl Div<f32> for Radians { + type Output = Radians; + + fn div(self, rhs: f32) -> Self::Output { + Radians(self.0 / rhs) + } +} |