1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use crate::{DiagonalDirection, Direction, Hex};
use glam::{IVec2, IVec3, Vec2};

impl From<(i32, i32)> for Hex {
    #[inline]
    fn from((x, y): (i32, i32)) -> Self {
        Self::new(x, y)
    }
}

impl From<[i32; 2]> for Hex {
    #[inline]
    fn from(a: [i32; 2]) -> Self {
        Self::from_array(a)
    }
}

impl From<(f32, f32)> for Hex {
    #[inline]
    fn from(v: (f32, f32)) -> Self {
        Self::round(v.into())
    }
}

impl From<[f32; 2]> for Hex {
    #[inline]
    fn from(v: [f32; 2]) -> Self {
        Self::round(v)
    }
}

impl From<Hex> for IVec2 {
    #[inline]
    fn from(hex: Hex) -> Self {
        hex.as_ivec2()
    }
}

impl From<Vec2> for Hex {
    #[inline]
    fn from(value: Vec2) -> Self {
        Self::from(value.to_array())
    }
}

impl From<Hex> for IVec3 {
    #[inline]
    fn from(hex: Hex) -> Self {
        hex.as_ivec3()
    }
}

impl From<IVec2> for Hex {
    #[inline]
    fn from(v: IVec2) -> Self {
        Self::new(v.x, v.y)
    }
}

impl From<Direction> for Hex {
    fn from(value: Direction) -> Self {
        Self::neighbor_coord(value)
    }
}

impl From<DiagonalDirection> for Hex {
    fn from(value: DiagonalDirection) -> Self {
        Self::diagonal_neighbor_coord(value)
    }
}