RoundedPolygon

Struct RoundedPolygon 

Source
pub struct RoundedPolygon {
    pub features: Vec<Feature>,
    pub center: Point,
    pub cubics: Vec<Cubic>,
}
Expand description

RoundedPolygon allows simple construction of polygonal shapes with optional rounding at the vertices.

Polygons can be constructed with either the number of vertices desired or an ordered list of vertices.

Fields§

§features: Vec<Feature>§center: Point§cubics: Vec<Cubic>

A flattened version of the Features.

Implementations§

Source§

impl RoundedPolygon

Source

pub fn new(features: Vec<Feature>, center: Point) -> Self

Source

pub fn from_features(features: Vec<Feature>, center: Option<Point>) -> Self

Source

pub fn circle() -> RoundedPolygonBuilder<Circle>

Returns a RoundedPolygonBuilder for creating a circle.

Source

pub fn rectangle() -> RoundedPolygonBuilder<Rectangle>

Returns a RoundedPolygonBuilder for creating a rectangle.

Source

pub fn star(vertices_per_radius: usize) -> RoundedPolygonBuilder<Star>

Returns a RoundedPolygonBuilder for creating a star.

Source

pub fn pill() -> RoundedPolygonBuilder<Pill>

Returns a RoundedPolygonBuilder for creating a pill.

Source

pub fn pill_star() -> RoundedPolygonBuilder<PillStar>

Returns a RoundedPolygonBuilder for creating a pill star.

Source

pub fn from_points( points: &[RoundedPoint], repeats: usize, mirroring: bool, ) -> Self

Creates a rounded polygon from a set of points that are connected to each other and optionally rounded. The repeats argument specifies the number of vertices generated by each point. If mirroring is true, a mirrored version is also added for each point.

Source

pub fn from_points_at( points: &[RoundedPoint], repeats: usize, center: Point, mirroring: bool, ) -> Self

Creates a rounded polygon from a set of points that are connected to each other at center and optionally rounded. The repeats argument specifies the number of vertices generated by each point. If mirroring is true, a mirrored version is also added for each point.

Source

pub fn from_vertices_count( vertices: usize, radius: f32, rounding: Option<CornerRounding>, per_vertex_rounding: &[CornerRounding], ) -> Self

Source

pub fn from_vertices_count_at( vertices: usize, radius: f32, center: Point, rounding: Option<CornerRounding>, per_vertex_rounding: &[CornerRounding], ) -> Self

Source

pub fn from_vertices( vertices: &[Point], rounding: CornerRounding, per_vertex_rounding: &[CornerRounding], center: Point, ) -> Self

§Panics

May panic if:

  • The polygon contains fewer than 3 vertices
  • The per_vertex_rounding is not empty, but its size does not correspond to the number of vertices in the polygon
Source

pub fn transformed<T: PointTransformer>(self, f: T) -> Self

Returns a RoundedPolygon with features transformed using the provided reference to type that implements PointTransformer trait.

Source

pub fn aabb(&self, approximate: bool) -> Aabb

Returns an axis-aligned bounding box describing bounds of the polygon.

If approximate is true, a fast but sometimes inaccurate algorithm is used to calculate AABB of cubics. Otherwise, it finds the derivative, which is a quadratic Bézier curve, and then solves the equation for t using the quadratic formula.

Source

pub fn normalized(self) -> Self

Moves and resizes RoundedPolygon, so it’s completely inside the 0x0 -> 1x1 square, centered if there extra space in one direction.

Source

pub fn as_path<T: PathBuilder + Default>( &self, repeat_path: bool, close_path: bool, ) -> T::Path

Returns a path with a drawn rounded polygon. Path is created using the provided T, which should implement PathBuilder and Default traits.

Source

pub fn add_to<T: PathBuilder>( &self, builder: &mut T, repeat_path: bool, close_path: bool, )

Adds a rounded polygon to the builder.

Trait Implementations§

Source§

impl Clone for RoundedPolygon

Source§

fn clone(&self) -> RoundedPolygon

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RoundedPolygon

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for RoundedPolygon

Source§

fn eq(&self, other: &RoundedPolygon) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for RoundedPolygon

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.