diff options
-rw-r--r-- | gate/src/renderer/geom.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/gate/src/renderer/geom.rs b/gate/src/renderer/geom.rs index 0f0e478..619555f 100644 --- a/gate/src/renderer/geom.rs +++ b/gate/src/renderer/geom.rs @@ -215,13 +215,26 @@ impl Affine { } } - pub(crate) fn apply(&self, input: Vec2) -> Vec2 { self.mat * input + self.offset } + pub fn invert_translate(&self) -> Affine { + Affine { + mat: self.mat, + offset: -1. * self.offset + } + } + + pub fn apply(&self, input: Vec2) -> Vec2 { self.mat * input + self.offset } - pub(crate) fn apply_f32(&self, input: (f32, f32)) -> (f32, f32) { + pub fn apply_f32(&self, input: (f32, f32)) -> (f32, f32) { let input = Vec2::new(input.0 as f64, input.1 as f64); let result = self.apply(input); (result.x as f32, result.y as f32) } + pub fn apply_f64(&self, input: (f64, f64)) -> (f64, f64) { + let input = Vec2::new(input.0 as f64, input.1 as f64); + let result = self.apply(input); + (result.x, result.y) + } + pub(crate) fn mat(&self) -> &Mat2 { &self.mat } } |