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
pub mod grid;
pub mod sparse_grid;
pub mod world_grid;
pub use grid::Grid;
pub use sparse_grid::SparseGrid;
pub use world_grid::WorldGrid;
use glam::{IVec2, Vec2};
#[derive(Clone, Copy)]
pub enum Pivot {
TopLeft,
TopRight,
Center,
BottomLeft,
BottomRight,
}
impl Pivot {
pub fn normalized(&self) -> Vec2 {
match self {
Pivot::TopLeft => Vec2::new(0.0, 1.0),
Pivot::TopRight => Vec2::new(1.0, 1.0),
Pivot::Center => Vec2::new(0.5, 0.5),
Pivot::BottomLeft => Vec2::new(0.0, 0.0),
Pivot::BottomRight => Vec2::new(1.0, 0.0),
}
}
pub fn axis(&self) -> IVec2 {
match self {
Pivot::TopLeft => IVec2::new(1, -1),
Pivot::TopRight => IVec2::new(-1, -1),
Pivot::Center => IVec2::new(1, 1),
Pivot::BottomLeft => IVec2::new(1, 1),
Pivot::BottomRight => IVec2::new(-1, 1),
}
}
}