[−][src]Struct pathfinder::Group
Holds a set of nodes and applies properties to all child nodes when drawn.
The group itself has no displayed output and is not visible.
It contains a Node used for Group meta data.
Fields
nodes: Vec<Node>
Methods
impl Group
[src]
pub fn new(name: &str, coordinates: Coordinate) -> Self
[src]
Constructs a new Group.
name is converted internally as a hash.
pub fn new_node(&mut self)
[src]
Adds a Node dynamically to the Group.
Examples
let a = cluster!(); let mut group = cluster!(); group.new_node();
pub fn radius(&mut self, radius: u32)
[src]
Set the radius for the group's meta-data.
Examples
let a = cluster!(); let mut group = cluster!(); group.radius(100);
pub fn nodes(&self) -> &Vec<Node>
[src]
Retrieves the nodes drawing in the group. Positions are relative to the group.
Examples
let group = cluster!(); let mut group = cluster!(); group.add(50); assert_eq!(group.nodes().len(), 50);
pub fn set(&mut self) -> &mut Node
[src]
Retrieves the group meta data, used for setting properties such as hash and color.
Examples
let group = cluster!(); let mut group = cluster!(); group.set().hash = 105; assert_eq!(group.hash(), 105);
pub fn add(&mut self, nr: u32)
[src]
Adds a set of nodes randomly located inside the group's radius.
Examples
let group = cluster!(); let mut group = cluster!(); group.add(500); assert_eq!(group.nodes().len(), 500);
pub fn each(&mut self, func: &dyn Fn(&mut Node))
[src]
Applies the closure over each mutable child node.
Examples
Prints all the nodes positions.
let mut group = cluster!(); group.add(10); group.each(&|node: &mut Node| println!("{}", node.position()));
Since it returns a mutable reference, It is more adapted for modifying the nodes.
group.each(&|node: &mut Node| node.geo = coordinate!());
pub fn color(&mut self, rgba: Rgba<u8>)
[src]
Sets the color of the Group.
pub fn node_plot(&mut self, calc: &dyn Fn(usize) -> Coordinate)
[src]
Plots node according to the fn provided.
The closure parameter is the number of children the group has.
Examples
let mut group = cluster!(); group.node_plot(&|u| coordinate!(u));
pub fn new_node_min_max(&mut self, min: u32, max: u32)
[src]
Adds a Node with a specific minimum and maximum distance from the center of the Group.
Examples
let mut group = cluster!(); group.new_node_min_max(50, 60); assert!(group.nodes()[0].geo.lt(61));
pub fn new_simple(x: i16, y: i16) -> Self
[src]
Removes all non-essentials from the standard implementation.
Examples
The cluster macro allows for this exact invocation.
let mut group = cluster!(10, 10); let group2 = Group::new_simple(10, 10); assert_eq!(group.position(), group2.position());
pub fn push(&mut self, node: Node)
[src]
Pushes a Node to the Group.
Examples
let mut group = cluster!(); let node = node!(); group.push(node); assert_eq!(group.nodes().len(), 1);
pub fn dynamic_radius(&self) -> u32
[src]
Returns a dynamic radius based on the number of Nodes in the Group.
It returns a larger number if it has more nodes.
pub fn rotate(&mut self, rad: f64)
[src]
Rotates all the nodes inside the group.
pub fn gen_color(&self, coordinates: Coordinate) -> Rgba<u8>
[src]
Generate a image::Rgba based on the color of the Group and the distance from center.
This is useful to make nodes places in groups, but outside it's radius or close to it's radius appear as darker.
Examples
let mut cluster = cluster!(); cluster.radius(10); cluster.color(image::Rgba {data: [100, 100, 100, 255]}); let rgba = cluster.gen_color(coordinate!(10, 10)); assert!(rgba.data[0] < 50);
pub fn from_list(list: &[(i16, i16)]) -> Vec<Self>
[src]
Converts a list of tuples (x,y) to a Vector of Groups. Names are assigned from "A" and upwards automatically.
Examples
let list = [(0, 0), (10, 10), (15, 15)]; let groups = Group::from_list(&list); assert_eq!(groups.len(), 3);
pub fn link(&mut self, other: &Group)
[src]
Link together groups.
Examples
let b: Group = Group::new("B", Coordinate::new(100, 100)); let mut a: Group = Group::new("A", Coordinate::new(0, 0)); a.link(&b);
Trait Implementations
impl Draw for Group
[src]
fn draw(&self, image: IW, offset: Coordinate, shape: &Shape) -> IW
[src]
Draws the Nodes inside that Group.
If none the Group is draw as blank.
fn size(&self) -> u32
[src]
fn links(&self) -> &[HL]
[src]
impl Location for Group
[src]
fn position(&self) -> Coordinate
[src]
fn eq<L: Location>(&self, other: &L) -> bool
[src]
Returns if the positions are equal or not.
fn x(&self) -> i16
[src]
Retrieves the X coordinate.
fn y(&self) -> i16
[src]
Retrieves the Y coordinate.
fn sum(&self) -> i16
[src]
Returns the sum of the x and y value.
impl MinMax for Group
[src]
fn min_max(&self) -> (Coordinate, Coordinate)
[src]
Returns the the largest and smallest x and y position found in the group.
Examples
let mut group = Group::new_simple(0, 0); group.push(node!(100, 100)); let (min, max) = group.min_max(); assert_eq!(min.x, 0); assert_eq!(max.x, 104);
impl Find for Group
[src]
fn find<H: Hash>(&self, hash: H) -> Option<Coordinate>
[src]
Recursively calls find as the group contains sets of Nodes.
impl Hash for Group
[src]
impl Clone for Group
[src]
fn clone(&self) -> Group
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'a> PartialEq<Group> for Group
[src]
fn eq(&self, other: &Group) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl From<Group> for Node
[src]
impl From<Coordinate> for Group
[src]
fn from(c: Coordinate) -> Self
[src]
impl From<Node> for Group
[src]
impl From<Group> for Coordinate
[src]
impl Debug for Group
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,