use crate::tile::Tile;
pub enum SiblingRelationship {
UpperLeft = 0,
UpperRight = 1,
LowerLeft = 2,
LowerRight = 3,
}
impl From<(u32, u32)> for SiblingRelationship {
fn from(value: (u32, u32)) -> Self {
let is_left = value.0.is_multiple_of(2);
let is_top = value.1.is_multiple_of(2);
match (is_left, is_top) {
(true, true) => Self::UpperLeft,
(true, false) => Self::LowerLeft,
(false, true) => Self::UpperRight,
(false, false) => Self::LowerRight,
}
}
}
impl From<Tile> for SiblingRelationship {
fn from(value: Tile) -> Self {
let is_left = value.x.is_multiple_of(2);
let is_top = value.y.is_multiple_of(2);
match (is_left, is_top) {
(true, true) => Self::UpperLeft,
(true, false) => Self::LowerLeft,
(false, true) => Self::UpperRight,
(false, false) => Self::LowerRight,
}
}
}