Skip to main content

PathMeasure

Struct PathMeasure 

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

路径测量器,用于获取路径长度、沿路径的位置和切线。 PathMeasure - measures path length and samples position/tangent along path.

支持多轮廓路径,通过 next_contour 遍历。 Supports multi-contour paths; use next_contour to iterate.

Implementations§

Source§

impl PathMeasure

Source

pub fn new() -> Self

创建空测量器。Creates empty path measure (no path).

Source

pub fn from_path(path: &Path, force_closed: bool, res_scale: f32) -> Self

从路径创建测量器。 Creates path measure from path.

force_closed 为 true 时,开放轮廓按闭合计算长度。 res_scale 控制精度,> 1 提高精度(可能变慢)。

Source

pub fn set_path(&mut self, path: &Path, force_closed: bool)

重置为指定路径。Resets with given path.

Source

pub fn length(&mut self) -> f32

当前轮廓的总长度,无路径时返回 0。 Total length of current contour, or 0 if no path.

Source

pub fn pos_tan(&mut self, distance: f32) -> Option<(Point, Point)>

在指定距离处的位置和切线。 Position and tangent at given distance along path.

距离会被限制在 [0, length] 内。 Distance is clamped to [0, length].

Source

pub fn get_segment( &mut self, start_d: f32, stop_d: f32, dst: &mut Path, start_with_move_to: bool, ) -> bool

提取路径的 [start_d, stop_d] 段。 Extracts path segment between start_d and stop_d.

start_with_move_to 为 true 时,段以 moveTo 开始。

Source

pub fn is_closed(&mut self) -> bool

当前轮廓是否闭合。Whether current contour is closed.

Source

pub fn next_contour(&mut self) -> bool

移动到下一个轮廓,返回是否还有更多。 Move to next contour; returns true if more exist.

Trait Implementations§

Source§

impl Default for PathMeasure

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> 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, 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.