utiles_core/
sibling_relationship.rs1use crate::tile::Tile;
3
4pub enum SiblingRelationship {
6 UpperLeft = 0,
8 UpperRight = 1,
10 LowerLeft = 2,
12 LowerRight = 3,
14}
15
16impl From<(u32, u32)> for SiblingRelationship {
17 fn from(value: (u32, u32)) -> Self {
18 let is_left = value.0.is_multiple_of(2);
19 let is_top = value.1.is_multiple_of(2);
20 match (is_left, is_top) {
21 (true, true) => Self::UpperLeft,
22 (true, false) => Self::LowerLeft,
23 (false, true) => Self::UpperRight,
24 (false, false) => Self::LowerRight,
25 }
26 }
27}
28
29impl From<Tile> for SiblingRelationship {
30 fn from(value: Tile) -> Self {
31 let is_left = value.x.is_multiple_of(2);
32 let is_top = value.y.is_multiple_of(2);
33 match (is_left, is_top) {
34 (true, true) => Self::UpperLeft,
35 (true, false) => Self::LowerLeft,
36 (false, true) => Self::UpperRight,
37 (false, false) => Self::LowerRight,
38 }
39 }
40}