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 % 2 == 0;
19 let is_top = value.1 % 2 == 0;
20 match (is_left, is_top) {
21 (true, true) => SiblingRelationship::UpperLeft,
22 (true, false) => SiblingRelationship::LowerLeft,
23 (false, true) => SiblingRelationship::UpperRight,
24 (false, false) => SiblingRelationship::LowerRight,
25 }
26 }
27}
28
29impl From<Tile> for SiblingRelationship {
30 fn from(value: Tile) -> Self {
31 let is_left = value.x % 2 == 0;
32 let is_top = value.y % 2 == 0;
33 match (is_left, is_top) {
34 (true, true) => SiblingRelationship::UpperLeft,
35 (true, false) => SiblingRelationship::LowerLeft,
36 (false, true) => SiblingRelationship::UpperRight,
37 (false, false) => SiblingRelationship::LowerRight,
38 }
39 }
40}