diff options
Diffstat (limited to 'src/grid.rs')
| -rw-r--r-- | src/grid.rs | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/grid.rs b/src/grid.rs index ec27fa7..d1c4b15 100644 --- a/src/grid.rs +++ b/src/grid.rs @@ -1,18 +1,13 @@ +//! The grid used to divide the map into evenly sized chunks. + +use crate::colours::DEFAULT_COLOURS; use crate::math::{self, Vec2}; use crate::transform::Transform; use raylib::drawing::RaylibDraw; -use raylib::ffi::Color; /// The internal grid length which will be used to snap things to it. pub const SNAP_SIZE: f64 = 0.5; -pub const LINE_COLOUR: Color = Color { - r: 255, - g: 255, - b: 255, - a: 75, -}; - /// 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> { @@ -38,7 +33,13 @@ where let mut draw_y = transform.point_m_to_px(&cell).y; loop { draw_y = math::round(draw_y, 1.); - rld.draw_line(0, draw_y as i32, screen_width, draw_y as i32, LINE_COLOUR); + rld.draw_line( + 0, + draw_y as i32, + screen_width, + draw_y as i32, + DEFAULT_COLOURS.grid_lines, + ); cell.y += 1.; draw_y = transform.point_m_to_px(&cell).y; @@ -50,7 +51,13 @@ where let mut draw_x = transform.point_m_to_px(&cell).x; loop { draw_x = math::round(draw_x, 1.); - rld.draw_line(draw_x as i32, 0, draw_x as i32, screen_height, LINE_COLOUR); + rld.draw_line( + draw_x as i32, + 0, + draw_x as i32, + screen_height, + DEFAULT_COLOURS.grid_lines, + ); cell.x += 1.; draw_x = transform.point_m_to_px(&cell).x; |
