pub struct Path {
pub commands: Vec<PathCommand>,
/* private fields */
}Expand description
A path made of PathCommands.
Used by DrawCommand::Fill and DrawCommand::PushClip. The GPU rasterizer
converts the path into a polygon with Path::as_polygon_vertices,
flattening curved segments into line segments.
Fields§
§commands: Vec<PathCommand>Implementations§
Source§impl Path
impl Path
Sourcepub fn line_to(&mut self, x: f32, y: f32)
pub fn line_to(&mut self, x: f32, y: f32)
Draws a straight line to (x, y).
If the path has no current point yet, the line is treated as a starting point.
Sourcepub fn quad_to(&mut self, c: (f32, f32), p: (f32, f32))
pub fn quad_to(&mut self, c: (f32, f32), p: (f32, f32))
Draws a quadratic Bézier curve to p with control point c.
If the path has no current point yet, the curve is dropped and the
path is moved to p instead (a curve has no defined start point).
Sourcepub fn cubic_to(&mut self, c1: (f32, f32), c2: (f32, f32), p: (f32, f32))
pub fn cubic_to(&mut self, c1: (f32, f32), c2: (f32, f32), p: (f32, f32))
Draws a cubic Bézier curve to p with control points c1 and c2.
If the path has no current point yet, the curve is dropped and the
path is moved to p instead (a curve has no defined start point).
Sourcepub fn close(&mut self)
pub fn close(&mut self)
Closes the current subpath, returning the current point to the subpath start.
Sourcepub fn bounding_box(&self) -> Option<Rect>
pub fn bounding_box(&self) -> Option<Rect>
Computes the axis-aligned bounding box of the path, or None for an
empty path.
Curve bounds include the control points, so they may overestimate the true extent.
Sourcepub fn subpaths(&self) -> Vec<Vec<(f32, f32)>>
pub fn subpaths(&self) -> Vec<Vec<(f32, f32)>>
Returns the path flattened into a list of vertices per subpath, curving segments into line segments.
Each entry is one closed ring (its closing edge back to the first
point is implicit). Multiple MoveTos yield multiple rings.
Sourcepub fn as_polygon_vertices(&self) -> Option<Vec<(f32, f32)>>
pub fn as_polygon_vertices(&self) -> Option<Vec<(f32, f32)>>
Returns the path as a single flat list of vertices, or None if the
path has fewer than three vertices total.
Prefer Path::subpaths when subpaths must be triangulated
independently.
pub fn commands(&self) -> &[PathCommand]
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Path
impl RefUnwindSafe for Path
impl Send for Path
impl Sync for Path
impl Unpin for Path
impl UnsafeUnpin for Path
impl UnwindSafe for Path
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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().