aboutsummaryrefslogtreecommitdiff
path: root/src/transform.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/transform.rs')
-rw-r--r--src/transform.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/transform.rs b/src/transform.rs
index 7c1adbf..147956c 100644
--- a/src/transform.rs
+++ b/src/transform.rs
@@ -9,6 +9,8 @@ const STANDARD_PIXELS_PER_M: f64 = 64.;
const MIN_PIXELS_PER_M: f64 = 5.;
const MAX_PIXELS_PER_M: f64 = 10_000.;
+/// A rigid 2D transformation. Since the translation must often be accessed directly and so far there
+/// was no huge need for fancy transformation, this currently does not use any matrix transformations.
pub struct Transform {
/// The (not necessarily natural) number of pixels per m, i.e. the current scale of the map
pixels_per_m: f64,
@@ -119,9 +121,15 @@ impl Transform {
self.translation_px += *by;
}
+ /// Get the current scale with the number of pixels (as a real number) that makes up a meter of
+ /// actual map space.
pub fn pixels_per_m(&self) -> f64 {
self.pixels_per_m
}
+ /// Get the current translation of the map on the screen. This is purely in pixels, rather than
+ /// meters, since a translation in meters does not make sense, because all map items have an
+ /// absolute position and the translation is merely used to see where on the screen anything
+ /// should be drawn.
pub fn translation_px(&self) -> &Vec2<f64> {
&self.translation_px
}