pub struct PathBuilder { /* private fields */ }image or svg or canvas only.Expand description
A path builder.
Implementations§
Source§impl PathBuilder
impl PathBuilder
Sourcepub fn new() -> PathBuilder
pub fn new() -> PathBuilder
Creates a new builder.
Sourcepub fn with_capacity(
verbs_capacity: usize,
points_capacity: usize,
) -> PathBuilder
pub fn with_capacity( verbs_capacity: usize, points_capacity: usize, ) -> PathBuilder
Creates a new builder with a specified capacity.
Number of points depends on a verb type:
- Move - 1
- Line - 1
- Quad - 2
- Cubic - 3
- Close - 0
Sourcepub fn from_rect(rect: Rect) -> Path
pub fn from_rect(rect: Rect) -> Path
Creates a new Path from Rect.
Never fails since Rect is always valid.
Segments are created clockwise: TopLeft -> TopRight -> BottomRight -> BottomLeft
The contour is closed.
Sourcepub fn from_circle(cx: f32, cy: f32, radius: f32) -> Option<Path>
pub fn from_circle(cx: f32, cy: f32, radius: f32) -> Option<Path>
Creates a new Path from a circle.
See PathBuilder::push_circle for details.
Sourcepub fn from_oval(oval: Rect) -> Option<Path>
pub fn from_oval(oval: Rect) -> Option<Path>
Creates a new Path from an oval.
See PathBuilder::push_oval for details.
Sourcepub fn move_to(&mut self, x: f32, y: f32)
pub fn move_to(&mut self, x: f32, y: f32)
Adds beginning of a contour.
Multiple continuous MoveTo segments are not allowed. If the previous segment was also MoveTo, it will be overwritten with the current one.
Sourcepub fn line_to(&mut self, x: f32, y: f32)
pub fn line_to(&mut self, x: f32, y: f32)
Adds a line from the last point.
- If
Pathis empty - adds Move(0, 0) first. - If
Pathends with Close - adds Move(last_x, last_y) first.
Sourcepub fn quad_to(&mut self, x1: f32, y1: f32, x: f32, y: f32)
pub fn quad_to(&mut self, x1: f32, y1: f32, x: f32, y: f32)
Adds a quad curve from the last point to x, y.
- If
Pathis empty - adds Move(0, 0) first. - If
Pathends with Close - adds Move(last_x, last_y) first.
Sourcepub fn cubic_to(&mut self, x1: f32, y1: f32, x2: f32, y2: f32, x: f32, y: f32)
pub fn cubic_to(&mut self, x1: f32, y1: f32, x2: f32, y2: f32, x: f32, y: f32)
Adds a cubic curve from the last point to x, y.
- If
Pathis empty - adds Move(0, 0) first. - If
Pathends with Close - adds Move(last_x, last_y) first.
Sourcepub fn close(&mut self)
pub fn close(&mut self)
Closes the current contour.
A closed contour connects the first and the last Point with a line, forming a continuous loop.
Does nothing when Path is empty or already closed.
Open and closed contour will be filled the same way. Stroking an open contour will add LineCap at contour’s start and end. Stroking an closed contour will add LineJoin at contour’s start and end.
Sourcepub fn last_point(&self) -> Option<Point>
pub fn last_point(&self) -> Option<Point>
Returns the last point if any.
Sourcepub fn push_rect(&mut self, rect: Rect)
pub fn push_rect(&mut self, rect: Rect)
Adds a rectangle contour.
The contour is closed and has a clock-wise direction.
Sourcepub fn push_oval(&mut self, oval: Rect)
pub fn push_oval(&mut self, oval: Rect)
Adds an oval contour bounded by the provided rectangle.
The contour is closed and has a clock-wise direction.
Sourcepub fn push_circle(&mut self, x: f32, y: f32, r: f32)
pub fn push_circle(&mut self, x: f32, y: f32, r: f32)
Adds a circle contour.
The contour is closed and has a clock-wise direction.
Does nothing when:
radius<= 0- any value is not finite or really large
Trait Implementations§
Source§impl Clone for PathBuilder
impl Clone for PathBuilder
Source§fn clone(&self) -> PathBuilder
fn clone(&self) -> PathBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PathBuilder
impl Debug for PathBuilder
Source§impl Default for PathBuilder
impl Default for PathBuilder
Source§fn default() -> PathBuilder
fn default() -> PathBuilder
Auto Trait Implementations§
impl Freeze for PathBuilder
impl RefUnwindSafe for PathBuilder
impl Send for PathBuilder
impl Sync for PathBuilder
impl Unpin for PathBuilder
impl UnwindSafe for PathBuilder
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<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
Source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
Source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
Source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
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>
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>
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)
&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)
&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>
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().