From 6aabd0123961d90095df3cefefeb0718f94aa6fc Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Tue, 10 Nov 2020 23:31:58 +0100 Subject: Add constant for the grid accuracy 0.5 was used as a magical number throughout the code for that until now, which I now changed. --- src/tool/icon_tool.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/tool/icon_tool.rs') diff --git a/src/tool/icon_tool.rs b/src/tool/icon_tool.rs index 702c30e..bd16de8 100644 --- a/src/tool/icon_tool.rs +++ b/src/tool/icon_tool.rs @@ -1,6 +1,6 @@ use crate::button::Button; use crate::config::{IconToolKeybindings, ToolKeybindings}; -use crate::grid::snap_to_grid; +use crate::grid::{snap_to_grid, SNAP_SIZE}; use crate::map_data::MapData; use crate::math::Vec2; use crate::tool::Tool; @@ -125,8 +125,10 @@ impl Tool for IconTool { fn active_update(&mut self, map: &mut MapData, rl: &RaylibHandle, transform: &Transform) { // Update the position of the icon that should be drawn to the current mouse position. - let snapped_mouse_pos_m = - snap_to_grid(transform.point_px_to_m(rl.get_mouse_position().into()), 0.5); + let snapped_mouse_pos_m = snap_to_grid( + transform.point_px_to_m(rl.get_mouse_position().into()), + SNAP_SIZE, + ); self.current_icon.position = snapped_mouse_pos_m; // Unwrap the current icon, since it is now definitely set, as we are in the active update. -- cgit v1.2.3-70-g09d2