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
impl RoundedPolygon
pub fn new(features: Vec<Feature>, center: Point) -> Self
pub fn from_features(features: Vec<Feature>, center: Option<Point>) -> Self
Sourcepub fn circle() -> RoundedPolygonBuilder<Circle>
pub fn circle() -> RoundedPolygonBuilder<Circle>
Returns a RoundedPolygonBuilder for creating a circle.
Sourcepub fn rectangle() -> RoundedPolygonBuilder<Rectangle>
pub fn rectangle() -> RoundedPolygonBuilder<Rectangle>
Returns a RoundedPolygonBuilder for creating a rectangle.
Sourcepub fn star(vertices_per_radius: usize) -> RoundedPolygonBuilder<Star>
pub fn star(vertices_per_radius: usize) -> RoundedPolygonBuilder<Star>
Returns a RoundedPolygonBuilder for creating a star.
Sourcepub fn pill() -> RoundedPolygonBuilder<Pill>
pub fn pill() -> RoundedPolygonBuilder<Pill>
Returns a RoundedPolygonBuilder for creating a pill.
Sourcepub fn pill_star() -> RoundedPolygonBuilder<PillStar>
pub fn pill_star() -> RoundedPolygonBuilder<PillStar>
Returns a RoundedPolygonBuilder for creating a pill star.
Sourcepub fn from_points(
points: &[RoundedPoint],
repeats: usize,
mirroring: bool,
) -> Self
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.
Sourcepub fn from_points_at(
points: &[RoundedPoint],
repeats: usize,
center: Point,
mirroring: bool,
) -> Self
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.
pub fn from_vertices_count( vertices: usize, radius: f32, rounding: Option<CornerRounding>, per_vertex_rounding: &[CornerRounding], ) -> Self
pub fn from_vertices_count_at( vertices: usize, radius: f32, center: Point, rounding: Option<CornerRounding>, per_vertex_rounding: &[CornerRounding], ) -> Self
Sourcepub fn from_vertices(
vertices: &[Point],
rounding: CornerRounding,
per_vertex_rounding: &[CornerRounding],
center: Point,
) -> Self
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_roundingis not empty, but its size does not correspond to the number of vertices in the polygon
Sourcepub fn transformed<T: PointTransformer>(self, f: T) -> Self
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.
Sourcepub fn aabb(&self, approximate: bool) -> Aabb
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.
Sourcepub fn normalized(self) -> Self
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.
Trait Implementations§
Source§impl Clone for RoundedPolygon
impl Clone for RoundedPolygon
Source§fn clone(&self) -> RoundedPolygon
fn clone(&self) -> RoundedPolygon
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more