[][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();

Implementations

impl PolygonBuilder[src]

pub fn vertex(mut self: 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 Debug for PolygonBuilder[src]

impl Default for PolygonBuilder[src]

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.