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
impl PathMeasure
Sourcepub fn from_path(path: &Path, force_closed: bool, res_scale: f32) -> Self
pub fn from_path(path: &Path, force_closed: bool, res_scale: f32) -> Self
从路径创建测量器。 Creates path measure from path.
force_closed 为 true 时,开放轮廓按闭合计算长度。
res_scale 控制精度,> 1 提高精度(可能变慢)。
Sourcepub fn length(&mut self) -> f32
pub fn length(&mut self) -> f32
当前轮廓的总长度,无路径时返回 0。 Total length of current contour, or 0 if no path.
Sourcepub fn pos_tan(&mut self, distance: f32) -> Option<(Point, Point)>
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].
Sourcepub fn get_segment(
&mut self,
start_d: f32,
stop_d: f32,
dst: &mut Path,
start_with_move_to: bool,
) -> bool
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 开始。
Sourcepub fn next_contour(&mut self) -> bool
pub fn next_contour(&mut self) -> bool
移动到下一个轮廓,返回是否还有更多。 Move to next contour; returns true if more exist.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PathMeasure
impl RefUnwindSafe for PathMeasure
impl !Send for PathMeasure
impl !Sync for PathMeasure
impl Unpin for PathMeasure
impl UnsafeUnpin for PathMeasure
impl UnwindSafe for PathMeasure
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
Mutably borrows from an owned value. Read more