From d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Mon, 21 Dec 2020 01:22:15 +0100 Subject: Add previously missing docs where appropriate --- src/transform.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/transform.rs') 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 { &self.translation_px } -- cgit v1.2.3-70-g09d2