Struct pathfinder::Node
source · pub struct Node {
pub hash: u64,
pub geo: Coordinate,
pub color: Rgba<u8>,
pub radius: Option<u32>,
/* private fields */
}
Expand description
A positioned object that can be drawn on an image::ImageBuffer.
Fields§
§hash: u64
§geo: Coordinate
§color: Rgba<u8>
§radius: Option<u32>
Implementations§
source§impl Node
impl Node
sourcepub fn new(name: &str, geo: Coordinate) -> Self
pub fn new(name: &str, geo: Coordinate) -> Self
Constructs a Node struct.
sourcepub fn from_list(list: &[(i16, i16)]) -> Vec<Self>
pub fn from_list(list: &[(i16, i16)]) -> Vec<Self>
Converts a list of tuples (x,y) to a Vector of Nodes. Names are assigned from “A” and upwards automatically.
use pathfinder::Node;
let list = [(0, 0), (10, 10), (15, 15)];
let nodes = Node::from_list(&list);
assert_eq!(nodes.len(), 3);
sourcepub fn is_directly_connected(&self, other: &Node) -> bool
pub fn is_directly_connected(&self, other: &Node) -> bool
Looks through all connected Nodes and returns if they are connected.
sourcepub fn linked_list(list: Vec<Node>) -> Vec<Self>
pub fn linked_list(list: Vec<Node>) -> Vec<Self>
Links a list of nodes together in the order they are indexed. A list of A, B, C. Will result in them being linked as: A -> B -> C.
use pathfinder::Node;
let nodes = Node::from_list(&[(0, 0), (20, 20)]);
let linked_list = Node::linked_list(nodes);
sourcepub fn link(&mut self, other: &Node)
pub fn link(&mut self, other: &Node)
Links Node self to the provided node’s coordinate.
use pathfinder::{Coordinate, Location, Node};
let b: Node = Node::new("B", Coordinate::new(100, 100));
let mut a: Node = Node::new("A", Coordinate::new(0, 0));
a.link(&b);
assert!(a.is_directly_connected(&b));