pub enum Shape {
Rect {
position: Vec2,
size: Vec2,
},
RoundedRect {
position: Vec2,
size: Vec2,
radii: [f32; 4],
},
Circle {
center: Vec2,
radius: f32,
},
Ellipse {
center: Vec2,
radii: Vec2,
},
Line {
start: Vec2,
end: Vec2,
},
Polyline {
points: Vec<Vec2>,
closed: bool,
},
Polygon {
points: Vec<Vec2>,
},
RegularPolygon {
center: Vec2,
radius: f32,
sides: u32,
rotation: f32,
},
Star {
center: Vec2,
outer_radius: f32,
inner_radius: f32,
points: u32,
rotation: f32,
},
Arc {
center: Vec2,
radius: f32,
start_angle: f32,
end_angle: f32,
},
Pie {
center: Vec2,
radius: f32,
start_angle: f32,
end_angle: f32,
},
Path(Path),
}Expand description
A high-level shape that can be converted to a path.
Variants§
Rect
A rectangle.
RoundedRect
A rounded rectangle.
Fields
Circle
A circle.
Ellipse
An ellipse.
Line
A line segment.
Polyline
A polyline (connected line segments).
Fields
Polygon
A polygon (closed polyline).
RegularPolygon
A regular polygon with n sides.
Fields
Star
A star shape.
Fields
Arc
An arc (partial circle).
Fields
Pie
A pie/sector (arc with lines to center).
Fields
Path(Path)
A custom path.
Implementations§
Source§impl Shape
impl Shape
Sourcepub fn rect_centered(center: Vec2, size: Vec2) -> Self
pub fn rect_centered(center: Vec2, size: Vec2) -> Self
Create a rectangle from center and size.
Sourcepub fn rounded_rect(position: Vec2, size: Vec2, radius: f32) -> Self
pub fn rounded_rect(position: Vec2, size: Vec2, radius: f32) -> Self
Create a rounded rectangle with uniform corner radius.
Sourcepub fn rounded_rect_varying(position: Vec2, size: Vec2, radii: [f32; 4]) -> Self
pub fn rounded_rect_varying(position: Vec2, size: Vec2, radii: [f32; 4]) -> Self
Create a rounded rectangle with individual corner radii.
Sourcepub fn regular_polygon(center: Vec2, radius: f32, sides: u32) -> Self
pub fn regular_polygon(center: Vec2, radius: f32, sides: u32) -> Self
Create a regular polygon.
Sourcepub fn regular_polygon_rotated(
center: Vec2,
radius: f32,
sides: u32,
rotation: f32,
) -> Self
pub fn regular_polygon_rotated( center: Vec2, radius: f32, sides: u32, rotation: f32, ) -> Self
Create a regular polygon with rotation.
Sourcepub fn star(
center: Vec2,
outer_radius: f32,
inner_radius: f32,
points: u32,
) -> Self
pub fn star( center: Vec2, outer_radius: f32, inner_radius: f32, points: u32, ) -> Self
Create a star.
Sourcepub fn star_rotated(
center: Vec2,
outer_radius: f32,
inner_radius: f32,
points: u32,
rotation: f32,
) -> Self
pub fn star_rotated( center: Vec2, outer_radius: f32, inner_radius: f32, points: u32, rotation: f32, ) -> Self
Create a star with rotation.
Trait Implementations§
impl StructuralPartialEq for Shape
Auto Trait Implementations§
impl Freeze for Shape
impl RefUnwindSafe for Shape
impl Send for Shape
impl Sync for Shape
impl Unpin for Shape
impl UnwindSafe for Shape
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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