pub struct Grid { /* private fields */ }
Expand description
§the point of this crate!
used to represent and draw a grid to the screen heres the repo: https://github.com/TheDinner22/macroquad_grid
§construction
use the new method or the default method
§notes
only has private feilds so you interface with it via methods (mainly getters and setters)
§stuff you can do
- creating a grid
- selecting a cell
- changing selected cells color
- changing default cell bg color
- changing gap color
- changing grids postion with Position enum
- setting color of a specific cell
- writing text to a specific cell
- writing text to the selected cell
- getting the selected cell’s index
- drawing the grid
Implementations§
Source§impl Grid
impl Grid
Sourcepub fn set_x_offset(&mut self, x_offset: Position)
pub fn set_x_offset(&mut self, x_offset: Position)
position the grid somewhere on the screen
Sourcepub fn set_y_offset(&mut self, y_offset: Position)
pub fn set_y_offset(&mut self, y_offset: Position)
position the grid somewhere on the screen
Sourcepub fn draw(&self)
pub fn draw(&self)
§draw it!
this does not change any state your gonna want to put this in the main loop or something like that
Sourcepub fn select_cell(&mut self, cell_index: Option<(usize, usize)>)
pub fn select_cell(&mut self, cell_index: Option<(usize, usize)>)
Sourcepub fn get_selected_cell_index(&self) -> Option<(usize, usize)>
pub fn get_selected_cell_index(&self) -> Option<(usize, usize)>
returns the (row, col) index of the selected cell
Sourcepub fn color_cell(&mut self, row: usize, col: usize, color: Color)
pub fn color_cell(&mut self, row: usize, col: usize, color: Color)
changes the default bg color of the given cell
§panics
if the row or col is out of bounds indexing into the 2D vector which represents the grid (its private u can’t see it)
Sourcepub fn set_cell_bg_color(&mut self, color: Color)
pub fn set_cell_bg_color(&mut self, color: Color)
§sets default bg color for all cells
different from color_cell becuase this one applies to all uncolored and unselected cells this function panics
Sourcepub fn set_gap_color(&mut self, color: Color)
pub fn set_gap_color(&mut self, color: Color)
color the gap between cells
Sourcepub fn set_selected_cell_color(&mut self, color: Color)
pub fn set_selected_cell_color(&mut self, color: Color)
when selected, a cell will have this color