Struct myelin_geometry::PolygonBuilder
source · pub struct PolygonBuilder { /* private fields */ }
Expand description
Implementations§
source§impl PolygonBuilder
impl PolygonBuilder
sourcepub fn vertex(self, x: f64, y: f64) -> Self
pub fn vertex(self, x: f64, y: f64) -> Self
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);
sourcepub fn build(self) -> Result<Polygon, ()>
pub fn build(self) -> Result<Polygon, ()>
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§
source§impl Debug for PolygonBuilder
impl Debug for PolygonBuilder
source§impl Default for PolygonBuilder
impl Default for PolygonBuilder
source§fn default() -> PolygonBuilder
fn default() -> PolygonBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PolygonBuilder
impl RefUnwindSafe for PolygonBuilder
impl Send for PolygonBuilder
impl Sync for PolygonBuilder
impl Unpin for PolygonBuilder
impl UnwindSafe for PolygonBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more