[][src]Struct voronoice::VoronoiBuilder

pub struct VoronoiBuilder { /* fields omitted */ }

Provides a convenient way to construct a Voronoi diagram.

Implementations

impl VoronoiBuilder[src]

pub fn set_bounding_box(mut self: Self, bounding_box: BoundingBox) -> Self[src]

Sets the BoundingBox that will be used to enclose the graph.

Default value is BoundingBox::default().

pub fn set_clip_behavior(mut self: Self, clip_behavior: ClipBehavior) -> Self[src]

Sets the ClipBehavior to be used when building the graph.

Default value is ClipBehavior::default().

pub fn set_sites(mut self: Self, sites: Vec<Point>) -> Self[src]

Sets a vector of Points representing the sites of each Voronoi cell that should be constructed.

pub fn set_lloyd_relaxation_iterations(
    mut self: Self,
    iterations: usize
) -> Self
[src]

Sets the number of LLoyd relaxation iterations that should be run as part of the graph generation.

Default is 0.

pub fn build(mut self: Self) -> Option<Voronoi>[src]

Consumes this builder and generates a Voronoi diagram/graph. An Option<Voronoi> is returned. None may be a valid return value if the set of sites do not generate a valid graph.

Examples

 use voronoice::*;
 // creates a voronoi graph from generated square sites, within a square bounding box of side 5.0
 // and runs 4 lloyd relaxation iterations to spread sites in the region
 let v: Voronoi = VoronoiBuilder::default()
     .generate_square_sites(10)
     .set_bounding_box(BoundingBox::new_centered_square(5.0))
     .set_lloyd_relaxation_iterations(4)
     .build()
     .unwrap();

Panics

Panics if no sites have been provided through Self::set_sites or one of the generate_*_sites methods.

pub fn generate_circle_sites(self, size: usize, radius: f64) -> Self[src]

Generates sites in the format of a circle centered at the origin with size points and radius radius. Internally calls Self::set_sites with the generated value.

pub fn generate_rect_sites(self, width: usize, height: usize) -> Self[src]

Generates sites in the format of a rectangle centered at the origin with width and height and width times height points. Internally calls Self::set_sites with the generated value.

pub fn generate_square_sites(self, width: usize) -> Self[src]

Generates sites in the format of a square centered at the origin with width and width square points. Internally calls Self::set_sites with the generated value.

Trait Implementations

impl Default for VoronoiBuilder[src]

impl From<&'_ Voronoi> for VoronoiBuilder[src]

pub fn from(v: &Voronoi) -> Self[src]

Creates a builder with same configurations that produced the original voronoi. Useful for performing Lloyd relaxation or storing the configuration to generate a identical diagram.

impl From<Voronoi> for VoronoiBuilder[src]

pub fn from(v: Voronoi) -> Self[src]

Creates a builder with same configurations that produced the original voronoi, consuming it. Useful for performing Lloyd relaxation or storing the configuration to generate a identical diagram.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.