Skip to main content

Path

Struct Path 

Source
pub struct Path { /* private fields */ }
Expand description

An immutable path: verb + point arrays (SoA), built once via PathBuilder, shared by Arc inside display-list ops (cloning a recorded list never copies point data). Flattening is the CALLER’s move because tolerance depends on the device scale at draw time — a path has no scale of its own.

Implementations§

Source§

impl Path

Source

pub fn bounds(&self) -> Rect

Source

pub fn tight_bounds(&self) -> Rect

Exact axis-aligned bounds of the path’s lines and Bézier curves. Recording uses the cheaper control-point bounds above; queries such as Canvas text metrics use this slower extrema walk when tight ink bounds are part of the API contract.

Source

pub fn is_empty(&self) -> bool

Source

pub fn heap_bytes(&self) -> usize

Heap footprint estimate (points dominate) — memory reports only.

Source

pub fn contains(&self, point: Point, fill_rule: FillRule) -> bool

Is point inside this path under fill_rule? The query runs on the curves themselves rather than a flattened approximation, so the answer does not drift with zoom. Every contour closes implicitly, matching how fills are drawn, and a point exactly on the outline counts as inside.

“On the outline” is decided with the same ABSOLUTE tolerance Skia uses (1/4096 of a unit), so on a path whose coordinates are tiny or enormous that band is proportionally wider or narrower than it looks.

Source

pub fn measure(&self, tolerance: f32) -> Vec<ContourMeasure>

Measure each contour for arc length — Skia’s SkContourMeasure. Contours with no length (a lone point) are dropped, so every returned measure can be sampled. tolerance is the flattening tolerance, and bounds the measurement’s accuracy with it.

Source

pub fn flatten(&self, tolerance: f32) -> Vec<Contour>

Flatten to polygonal contours at tolerance (max deviation, in the path’s own units). Fills treat last→first as an implicit edge for every contour; strokes branch on Contour::closed.

Trait Implementations§

Source§

impl Clone for Path

Source§

fn clone(&self) -> Path

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Path

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.