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
|
#[derive(Debug, Clone, Copy)]
pub struct Transformation([f32; 16]);
impl Transformation {
#[rustfmt::skip]
pub fn identity() -> Self {
Transformation([
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0,
])
}
#[rustfmt::skip]
pub fn orthographic(width: u16, height: u16) -> Self {
Transformation([
2.0 / width as f32, 0.0, 0.0, 0.0,
0.0, 2.0 / height as f32, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
-1.0, -1.0, 0.0, 1.0,
])
}
}
impl From<Transformation> for [f32; 16] {
fn from(transformation: Transformation) -> [f32; 16] {
transformation.0
}
}
|