Trait bracket_lib::algorithm_traits::Algorithm2D
source · [−]pub trait Algorithm2D: BaseMap {
fn point2d_to_index(&self, pt: Point) -> usize { ... }
fn index_to_point2d(&self, idx: usize) -> Point { ... }
fn dimensions(&self) -> Point { ... }
fn in_bounds(&self, pos: Point) -> bool { ... }
}
Expand description
Implement these for handling conversion to/from 2D coordinates (they are separate, because you might want Dwarf Fortress style 3D!)
Provided Methods
sourcefn point2d_to_index(&self, pt: Point) -> usize
fn point2d_to_index(&self, pt: Point) -> usize
Convert a Point (x/y) to an array index. Defaults to an index based on an array strided X first.
sourcefn index_to_point2d(&self, idx: usize) -> Point
fn index_to_point2d(&self, idx: usize) -> Point
Convert an array index to a point. Defaults to an index based on an array strided X first.
sourcefn dimensions(&self) -> Point
fn dimensions(&self) -> Point
Retrieve the map’s dimensions. Made optional to reduce API breakage.