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
71
72
73
74
75
76
77
use crate::buffer::CellGrid;
#[derive(Debug, Clone, PartialEq, Copy)]
pub enum Direction {
TopLeft,
Top,
TopRight,
Left,
Right,
BottomLeft,
Bottom,
BottomRight,
}
impl Direction {
pub(crate) fn opposite(&self) -> Self {
match self {
Direction::TopLeft => Direction::BottomRight,
Direction::Top => Direction::Bottom,
Direction::TopRight => Direction::BottomLeft,
Direction::Left => Direction::Right,
Direction::Right => Direction::Left,
Direction::BottomLeft => Direction::TopRight,
Direction::Bottom => Direction::Top,
Direction::BottomRight => Direction::TopLeft,
}
}
pub(crate) fn threshold_length(&self) -> f32 {
match self {
Direction::TopLeft
| Direction::TopRight
| Direction::BottomLeft
| Direction::BottomRight => CellGrid::diagonal_length(),
Direction::Left | Direction::Right => CellGrid::width(),
Direction::Top | Direction::Bottom => CellGrid::height(),
}
}
}