pub struct Shape<'a> { /* private fields */ }Expand description
The shape builder
Implementations§
Source§impl<'a> Shape<'a>
impl<'a> Shape<'a>
Sourcepub fn fill_color(self, color: Color) -> Self
pub fn fill_color(self, color: Color) -> Self
Set the fill color of the shape.
Sourcepub fn fill_paint(self, texture: &'a Paint<'_>) -> Self
pub fn fill_paint(self, texture: &'a Paint<'_>) -> Self
Set the fill paint of the shape. This allows for more complex fills such as gradients and patterns.
Sourcepub fn no_fill(self) -> Self
pub fn no_fill(self) -> Self
Don’t fill the shape. If this is not called the shape will not be closed.
Sourcepub fn stroke_color(self, color: Color) -> Self
pub fn stroke_color(self, color: Color) -> Self
Set the stroke color of the shape.
Sourcepub fn stroke_paint(self, paint: &'a Paint<'_>) -> Self
pub fn stroke_paint(self, paint: &'a Paint<'_>) -> Self
Set the stroke paint of the shape. This allows for more complex fills such as gradients and patterns.
Sourcepub fn stroke_weight(self, weight: f32) -> Self
pub fn stroke_weight(self, weight: f32) -> Self
Set the stroke width of the shape.
pub fn miter_limit(self, limit: f32) -> Self
Sourcepub fn stroke_dash(self, dash: StrokeDash) -> Self
pub fn stroke_dash(self, dash: StrokeDash) -> Self
Set the stroke dash of the shape.
Sourcepub fn get_points(&self) -> &[Point]
pub fn get_points(&self) -> &[Point]
Get points.
Sourcepub fn rect_ltrb(self, lt: Point, rb: Point) -> Self
pub fn rect_ltrb(self, lt: Point, rb: Point) -> Self
Interpret the points as a rectangle. The first point is the top left corner and the second point is the bottom right corner.
Sourcepub fn rect_xywh(self, xy: Point, wh: Point) -> Self
pub fn rect_xywh(self, xy: Point, wh: Point) -> Self
Inerpret the points as a rectangle. The first point is the top left corner and the second point is the size of the rectangle.
Sourcepub fn rect_cwh(self, c: Point, wh: Point) -> Self
pub fn rect_cwh(self, c: Point, wh: Point) -> Self
Inerpret the points as a rectangle. The first point is the center of the rectangle and the second point is the size of the rectangle.
Sourcepub fn circle(self, center: Point, radius: f32) -> Self
pub fn circle(self, center: Point, radius: f32) -> Self
Create circle from it’s center and radius.
Sourcepub fn ellipse(self, center: Point, width: f32, height: f32) -> Self
pub fn ellipse(self, center: Point, width: f32, height: f32) -> Self
Create ellispse from it’s center, width and heighr.
Sourcepub fn polygon(self, center: Point, radius: f32, sides: u32) -> Self
pub fn polygon(self, center: Point, radius: f32, sides: u32) -> Self
Create a polygon from it’s center, radius and number of sides.
Sourcepub fn star(
self,
center: Point,
inner_radius: f32,
outer_radius: f32,
sides: u32,
) -> Self
pub fn star( self, center: Point, inner_radius: f32, outer_radius: f32, sides: u32, ) -> Self
Create a star from it’s center, inner radius, outer radius, number of sides and smoothness parameter.
Sourcepub fn pearl<R: RngCore>(
self,
center: Point,
a: f32,
b: f32,
sides: u32,
smoothness: u32,
rng: &mut R,
) -> Self
pub fn pearl<R: RngCore>( self, center: Point, a: f32, b: f32, sides: u32, smoothness: u32, rng: &mut R, ) -> Self
A pearl is a deformed polygon using the normal distribution to alter the
location of each point. The a and b parameters control the width and height
of the pearl. The sides parameter controls the number of sides of the polygon.
The smoothness parameter controls the smoothnes of the polygon.
using the Chaiken algorithm.
Sourcepub fn quad(self) -> Self
pub fn quad(self) -> Self
Interpret the points as a quadratic bezier curve. The first point is the start point, the second point is the control point and the third point is the end point and so on.
Sourcepub fn cubic(self) -> Self
pub fn cubic(self) -> Self
Interpret the points as a cubic bezier curve. The first point is the start point, the second point is the first control point, the third point is the second control point and the fourth point is the end point and so on.
Sourcepub fn line(self, from: Point, to: Point) -> Self
pub fn line(self, from: Point, to: Point) -> Self
Create a line from it’s start and end points.
Sourcepub fn cartesian<T: AsPrimitive<f32>>(self, width: T, height: T) -> Self
pub fn cartesian<T: AsPrimitive<f32>>(self, width: T, height: T) -> Self
Interpret points as cartiesian coordinates with center at (0, 0).
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Shape<'a>
impl<'a> RefUnwindSafe for Shape<'a>
impl<'a> Send for Shape<'a>
impl<'a> Sync for Shape<'a>
impl<'a> Unpin for Shape<'a>
impl<'a> UnsafeUnpin for Shape<'a>
impl<'a> UnwindSafe for Shape<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().