Struct pathfinder::Map
source · pub struct Map {
pub image: Option<ImageBuffer<Rgba<u8>, Vec<u8>>>,
pub add: (i16, i16),
pub size: u32,
}
Fields§
§image: Option<ImageBuffer<Rgba<u8>, Vec<u8>>>
§add: (i16, i16)
§size: u32
Implementations§
source§impl Map
impl Map
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new map, no parameters are intially required and are generated automatically when calling Map::map.
sourcepub fn save(self, path: &Path) -> Result<(), Error>
pub fn save(self, path: &Path) -> Result<(), Error>
Saves the image to disk. Can be absolute or relative path.
Examples
let nodes = Node::from_list(&[(0, 0), (10, 10)]);
Map::new()
.map(&nodes)
.save(Path::new("/tmp/example.png"))
.unwrap();
sourcepub fn map<T: Draw + Location + Hash>(self, element: &[T]) -> Self
pub fn map<T: Draw + Location + Hash>(self, element: &[T]) -> Self
Maps any struct that has implemented Draw, on to an ImageBuffer.
Examples
let nodes: Vec<Node> = vec![
Node::new("1", Coordinate::new(0, 0)),
Node::new("2", Coordinate::new(100, 100)),
];
// Add content to vectors.
let mut map = Map::new();
map = map.map(&nodes);