aboutsummaryrefslogtreecommitdiff
path: root/src/grid.rs
diff options
context:
space:
mode:
authorArne Dußin2020-12-21 01:22:15 +0100
committerArne Dußin2020-12-21 21:15:55 +0100
commitd7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4 (patch)
treee5633f4d3b18472922c943d759e9f58722ba4405 /src/grid.rs
parent48f321a80970ebeb8374072b1d2e0a4d297aa348 (diff)
downloadgraf_karto-d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4.tar.gz
graf_karto-d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4.zip
Add previously missing docs where appropriate
Diffstat (limited to 'src/grid.rs')
-rw-r--r--src/grid.rs27
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;