#[derive(Debug, PartialEq, Clone, Copy, Eq, Hash)]
pub enum Balance {
TopLeft,
Top,
TopRight,
Left,
Center,
Right,
BottomLeft,
Bottom,
BottomRight,
}
impl Balance {
pub const fn x(self) -> i8 {
if self.has_left() {
-1
} else if self.has_right() {
1
} else {
0
}
}
pub const fn y(self) -> i8 {
if self.has_top() {
-1
} else if self.has_bottom() {
1
} else {
0
}
}
pub const fn has_top(self) -> bool {
matches!(self, Balance::Top | Balance::TopLeft | Balance::TopRight)
}
pub const fn has_bottom(self) -> bool {
matches!(
self,
Balance::Bottom | Balance::BottomLeft | Balance::BottomRight
)
}
pub const fn has_left(self) -> bool {
matches!(self, Balance::Left | Balance::TopLeft | Balance::BottomLeft)
}
pub const fn has_right(self) -> bool {
matches!(
self,
Balance::Right | Balance::TopRight | Balance::BottomRight
)
}
pub const fn is_orthogonal(self) -> bool {
matches!(
self,
Balance::Center | Balance::Top | Balance::Bottom | Balance::Left | Balance::Right
)
}
pub const fn is_diagonal(self) -> bool {
matches!(
self,
Balance::Center
| Balance::TopLeft
| Balance::TopRight
| Balance::BottomLeft
| Balance::BottomRight
)
}
pub const fn is_edge(self) -> bool {
matches!(
self,
Balance::Top | Balance::Bottom | Balance::Left | Balance::Right
)
}
pub const fn is_corner(self) -> bool {
matches!(
self,
Balance::TopLeft | Balance::TopRight | Balance::BottomLeft | Balance::BottomRight
)
}
pub const fn to_symbol(self) -> &'static str {
match self {
Balance::TopLeft => "↖️",
Balance::Top => "⬆️",
Balance::TopRight => "↗️",
Balance::Left => "⬅️",
Balance::Center => "⏺️",
Balance::Right => "➡️",
Balance::BottomLeft => "↙️",
Balance::Bottom => "⬇️",
Balance::BottomRight => "↘️",
}
}
}