[][src]Struct myelin_geometry::PolygonBuilder

pub struct PolygonBuilder { /* fields omitted */ }

Polygon factory, which can be used in order to configure the properties of a new polygon. Methods can be chained on it in order to configure it.

Examples

use myelin_geometry::PolygonBuilder;
let builder = PolygonBuilder::default();

Methods

impl PolygonBuilder[src]

pub fn vertex(self, x: f64, y: f64) -> Self[src]

Adds a vertex to the polygon

Examples

use myelin_geometry::PolygonBuilder;
let unfinished_builder = PolygonBuilder::default()
    .vertex(-50.0, -50.0)
    .vertex(50.0, -50.0)
    .vertex(50.0, 50.0)
    .vertex(-50.0, 50.0);

pub fn build(self) -> Result<Polygon, ()>[src]

Finishes building the Polygon with all vertices that have been configured up to this point

Errors

This method will return an error if the number of configured vertices is less than three, as the resulting Polygon would not be two-dimensional.

Examples

use myelin_geometry::PolygonBuilder;

let square = PolygonBuilder::default()
    .vertex(-50.0, -50.0)
    .vertex(50.0, -50.0)
    .vertex(50.0, 50.0)
    .vertex(-50.0, 50.0)
    .build()
    .unwrap();

Trait Implementations

impl Default for PolygonBuilder[src]

impl Debug for PolygonBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From for T[src]

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

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.