Преглед на файлове

Only snap to pixel grid if zoom has integral value

Johannes Hofmann преди 7 години
родител
ревизия
d2da35fd1c
променени са 1 файла, в които са добавени 6 реда и са изтрити 1 реда
  1. 6
    1
      src/map_view.rs

+ 6
- 1
src/map_view.rs Целия файл

@@ -91,7 +91,12 @@ impl MapView {
91 91
         let tile_screen_size = f64::powf(2.0, self.zoom - f64::from(uzoom)) * f64::from(self.tile_size);
92 92
 
93 93
         if snap_to_pixel {
94
-            top_left_tile_screen_coord.snap_to_pixel();
94
+            // only snap to pixel if apparent zoom is integer
95
+            let apparent_zoom = self.zoom + self.tile_zoom_offset;
96
+            let apparent_zoom_int = (apparent_zoom + 0.5).floor();
97
+            if (apparent_zoom - apparent_zoom_int).abs() < 1e-10 {
98
+                top_left_tile_screen_coord.snap_to_pixel();
99
+            }
95 100
         }
96 101
 
97 102
         let start_tile_x = top_left_tile.x;