aboutsummaryrefslogtreecommitdiff
path: root/src/transform.rs
diff options
context:
space:
mode:
authorArne Dußin2020-12-21 01:22:15 +0100
committerArne Dußin2020-12-21 21:15:55 +0100
commitd7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4 (patch)
treee5633f4d3b18472922c943d759e9f58722ba4405 /src/transform.rs
parent48f321a80970ebeb8374072b1d2e0a4d297aa348 (diff)
downloadgraf_karto-d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4.tar.gz
graf_karto-d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4.zip
Add previously missing docs where appropriate
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
}