summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2018-08-09 18:07:24 +0200
committerJustin Worthe <justin@worthe-it.co.za>2018-08-09 18:07:24 +0200
commitef403a5baa0c5a5d850c19f14e67f1b9f1186705 (patch)
treecf3b3c007a2e4df4e102613d7a15f5a210b7e186
parent83f9d8d2098cff980323403fafd1ba1aca5b41d0 (diff)
Added functions required for working with a camera and a cursorHEADmaster
-rw-r--r--gate/src/renderer/geom.rs17
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 }
}