aboutsummaryrefslogtreecommitdiff
path: root/src/grid.rs
diff options
context:
space:
mode:
authorArne Dußin2020-12-29 11:12:11 +0100
committerArne Dußin2020-12-31 14:04:15 +0100
commitb42ddaa4bf86b782bdbc619f7d66ded41c909465 (patch)
tree709e481bb6d1e620b0e01bb02c7335ea474658ec /src/grid.rs
parent2d2f45df9d47db25ac5a91c8f926a025c3a5dc7a (diff)
downloadgraf_karto-b42ddaa4bf86b782bdbc619f7d66ded41c909465.tar.gz
graf_karto-b42ddaa4bf86b782bdbc619f7d66ded41c909465.zip
Add snapping module to replace the rigid grid snapping
Diffstat (limited to 'src/grid.rs')
-rw-r--r--src/grid.rs14
1 files changed, 1 insertions, 13 deletions
diff --git a/src/grid.rs b/src/grid.rs
index d1c4b15..9134a49 100644
--- a/src/grid.rs
+++ b/src/grid.rs
@@ -1,22 +1,10 @@
//! The grid used to divide the map into evenly sized chunks.
use crate::colours::DEFAULT_COLOURS;
-use crate::math::{self, Vec2};
+use crate::math;
use crate::transform::Transform;
use raylib::drawing::RaylibDraw;
-/// The internal grid length which will be used to snap things to it.
-pub const SNAP_SIZE: f64 = 0.5;
-
-/// Snap a vector to the grid with the factor being the sub-grid accuracy. For instance, 0.5 will
-/// snap to half a grid cell, while 2.0 would snap to every second grid cell
-pub fn snap_to_grid(mut vec: Vec2<f64>, snap_fraction: f64) -> Vec2<f64> {
- vec.x = math::round(vec.x, snap_fraction);
- vec.y = math::round(vec.y, snap_fraction);
-
- vec
-}
-
/// Draw an infinite grid that can be moved around on the screen and zoomed in and out of.
pub fn draw_grid<D>(rld: &mut D, screen_width: i32, screen_height: i32, transform: &Transform)
where