diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-06-14 15:07:13 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-06-14 17:17:54 +0200 |
| commit | 7a6c2cce7747f7632f0be012f49b548db3e62a2d (patch) | |
| tree | 30103d743fcf22c6838e5ce3b6c632abe15e78b9 /src/geom/sides.rs | |
| parent | 6832ca2a26df5a9407bd2b0266cc0bab328ebeba (diff) | |
Make radius configuration unconfusing
Diffstat (limited to 'src/geom/sides.rs')
| -rw-r--r-- | src/geom/sides.rs | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/geom/sides.rs b/src/geom/sides.rs index 938539fe..72748916 100644 --- a/src/geom/sides.rs +++ b/src/geom/sides.rs @@ -48,17 +48,17 @@ impl<T> Sides<T> { /// Zip two instances into an instance. pub fn zip<F, V, W>(self, other: Sides<V>, mut f: F) -> Sides<W> where - F: FnMut(T, V, Side) -> W, + F: FnMut(T, V) -> W, { Sides { - left: f(self.left, other.left, Side::Left), - top: f(self.top, other.top, Side::Top), - right: f(self.right, other.right, Side::Right), - bottom: f(self.bottom, other.bottom, Side::Bottom), + left: f(self.left, other.left), + top: f(self.top, other.top), + right: f(self.right, other.right), + bottom: f(self.bottom, other.bottom), } } - /// An iterator over the sides. + /// An iterator over the sides, starting with the left side, clockwise. pub fn iter(&self) -> impl Iterator<Item = &T> { [&self.left, &self.top, &self.right, &self.bottom].into_iter() } @@ -157,6 +157,21 @@ impl Side { } } + /// The first corner of the side in clockwise order. + pub fn start_corner(self) -> Corner { + match self { + Self::Left => Corner::BottomLeft, + Self::Top => Corner::TopLeft, + Self::Right => Corner::TopRight, + Self::Bottom => Corner::BottomRight, + } + } + + /// The second corner of the side in clockwise order. + pub fn end_corner(self) -> Corner { + self.next_cw().start_corner() + } + /// Return the corresponding axis. pub fn axis(self) -> SpecAxis { match self { |
