pub trait Grid<T: Clone + Copy> {
Show 14 methods fn new(width: usize, height: usize, default_value: T) -> Self; fn get(&self, x: usize, y: usize) -> T; fn set(&mut self, x: usize, y: usize, value: T); fn width(&self) -> usize; fn height(&self) -> usize; fn get_point(&self, point: Point) -> T { ... } fn set_point(&mut self, point: Point, value: T) { ... } fn get_ix(&self, x: usize, y: usize) -> usize { ... } fn get_ix_point(&self, point: &Point) -> usize { ... } fn point_in_bounds(&self, point: Point) -> bool { ... } fn index_in_bounds(&self, x: usize, y: usize) -> bool { ... } fn set_rectangle(&mut self, rect: &Rect, value: T) { ... } fn rect(&self) -> Rect { ... } fn get_rect(&self, rect: Rect) -> Vec<T> { ... }
}
Expand description

The Grid trait abstracts over containers of Clone and Copy items laid out in a rectangle with a certain width and height.

Required Methods

Provided Methods

Gets the index corresponding to a coordinate, which is row-wise.

Tests whether a point is in bounds.

Tests whether an index is in bounds.

Sets a given rectangle on the grid to the value.

Retrieves the rectangle corresponding to the grid dimensions at the origin.

Retrieves a column-wise vector of grid values in the given rectangle.

Implementors