pub struct Path { /* private fields */ }Expand description
路径的 safe 封装,底层为 C++ pk::SkPath。
Safe wrapper around pk::SkPath.
Implementations§
Source§impl Path
impl Path
Sourcepub fn count_points(&self) -> i32
pub fn count_points(&self) -> i32
点的数量。Returns the number of points in the path.
Sourcepub fn count_verbs(&self) -> i32
pub fn count_verbs(&self) -> i32
动词的数量。Returns the number of verbs (move, line, quad, cubic, close).
Sourcepub fn iter(&self, force_close: bool) -> PathIter<'_> ⓘ
pub fn iter(&self, force_close: bool) -> PathIter<'_> ⓘ
迭代路径中的动词与点。Iterates over path verbs and points.
force_close 为 true 时,开放轮廓会生成隐式 close。
When force_close is true, open contours generate implicit close.
Sourcepub fn get_point(&self, index: i32) -> Option<Point>
pub fn get_point(&self, index: i32) -> Option<Point>
获取第 i 个点。Returns the point at index, or None if out of range.
Sourcepub fn tight_bounds(&self) -> Rect
pub fn tight_bounds(&self) -> Rect
计算紧密包围盒。Returns the tight axis-aligned bounding box.
永不失败;空路径返回 (0,0,0,0)。对复杂曲线,pathops_tight_bounds 可能更精确但可能返回 None。
Never fails; empty path returns (0,0,0,0). For complex curves, pathops_tight_bounds may be more accurate but can return None.
Sourcepub fn is_last_contour_closed(&self) -> bool
pub fn is_last_contour_closed(&self) -> bool
最后一段轮廓是否闭合。Returns true if the last contour ends with close().
Sourcepub fn conservatively_contains_rect(&self, rect: &Rect) -> bool
pub fn conservatively_contains_rect(&self, rect: &Rect) -> bool
保守判断是否包含矩形(可能将部分内含矩形判为 false)。 Conservatively tests rect containment; may return false for some contained rects.
适用于单段凸轮廓路径。Works for single convex contour paths.
Sourcepub fn is_rect(&self) -> Option<(Rect, bool)>
pub fn is_rect(&self) -> Option<(Rect, bool)>
是否可表示为矩形。Returns Some((rect, is_closed)) if path is a rect, None otherwise.
Sourcepub fn contains(&self, x: f32, y: f32) -> bool
pub fn contains(&self, x: f32, y: f32) -> bool
是否包含点。Returns true if (x, y) is inside the filled path.
使用当前 fill_type(新建路径默认为 PathFillType::Winding)。
Uses current fill_type (new paths default to PathFillType::Winding).
Sourcepub fn fill_type(&self) -> PathFillType
pub fn fill_type(&self) -> PathFillType
当前填充规则。Current fill rule.
Sourcepub fn set_fill_type(&mut self, ft: PathFillType)
pub fn set_fill_type(&mut self, ft: PathFillType)
设置填充规则。Sets fill rule.
Sourcepub fn is_inverse_fill_type(&self) -> bool
pub fn is_inverse_fill_type(&self) -> bool
是否为反色填充(InverseWinding / InverseEvenOdd)。
True if fill type is inverse winding or inverse even-odd.
Sourcepub fn toggle_inverse_fill_type(&mut self)
pub fn toggle_inverse_fill_type(&mut self)
在「普通 / 反色」之间切换(Winding ↔ InverseWinding,EvenOdd ↔ InverseEvenOdd)。
Toggles between normal and inverse fill (winding/even-odd pairs).
Sourcepub fn move_to(&mut self, x: f32, y: f32) -> &mut Self
pub fn move_to(&mut self, x: f32, y: f32) -> &mut Self
移动到 (x, y),开始新轮廓。Moves to (x, y) and starts a new contour.
Sourcepub fn line_to(&mut self, x: f32, y: f32) -> &mut Self
pub fn line_to(&mut self, x: f32, y: f32) -> &mut Self
画线到 (x, y)。Adds a line from current point to (x, y).
需先调用 move_to;否则 Skia 以 (0, 0) 为隐式起点。
Requires prior move_to; otherwise Skia uses (0, 0) as implicit start.
Sourcepub fn quad_to(&mut self, x1: f32, y1: f32, x2: f32, y2: f32) -> &mut Self
pub fn quad_to(&mut self, x1: f32, y1: f32, x2: f32, y2: f32) -> &mut Self
二次贝塞尔曲线。Adds a quadratic bezier (control point, end point).
Sourcepub fn cubic_to(
&mut self,
x1: f32,
y1: f32,
x2: f32,
y2: f32,
x3: f32,
y3: f32,
) -> &mut Self
pub fn cubic_to( &mut self, x1: f32, y1: f32, x2: f32, y2: f32, x3: f32, y3: f32, ) -> &mut Self
三次贝塞尔曲线。Adds a cubic bezier (ctrl1, ctrl2, end point).
Sourcepub fn close(&mut self) -> &mut Self
pub fn close(&mut self) -> &mut Self
闭合当前轮廓。Closes the current contour (line back to first point).
Sourcepub fn add_rect(
&mut self,
rect: &Rect,
dir: Direction,
start: RectCorner,
) -> &mut Self
pub fn add_rect( &mut self, rect: &Rect, dir: Direction, start: RectCorner, ) -> &mut Self
添加矩形。Adds a rectangle as a closed contour.
Sourcepub fn add_oval(&mut self, rect: &Rect, dir: Direction) -> &mut Self
pub fn add_oval(&mut self, rect: &Rect, dir: Direction) -> &mut Self
添加椭圆(由矩形包围)。Adds an oval (ellipse) bounded by the given rect.
Sourcepub fn add_circle(
&mut self,
cx: f32,
cy: f32,
radius: f32,
dir: Direction,
) -> &mut Self
pub fn add_circle( &mut self, cx: f32, cy: f32, radius: f32, dir: Direction, ) -> &mut Self
添加圆。Adds a circle centered at (cx, cy) with given radius.
radius 应 ≥ 0;负值时 Skia 行为未定义。
radius should be ≥ 0; negative values have undefined Skia behavior.
Sourcepub fn add_round_rect(
&mut self,
rect: &Rect,
rx: f32,
ry: f32,
dir: Direction,
) -> &mut Self
pub fn add_round_rect( &mut self, rect: &Rect, rx: f32, ry: f32, dir: Direction, ) -> &mut Self
添加圆角矩形。Adds a rounded rectangle (rx, ry = corner radii).
rx, ry 应 ≥ 0。Should be ≥ 0.
Sourcepub fn add_rrect(&mut self, rrect: &RRect, dir: Direction) -> &mut Self
pub fn add_rrect(&mut self, rrect: &RRect, dir: Direction) -> &mut Self
添加 RRect(支持四角独立半径)。Adds RRect with per-corner radii.
Sourcepub fn add_rrect_with_start(
&mut self,
rrect: &RRect,
dir: Direction,
start: RectCorner,
) -> &mut Self
pub fn add_rrect_with_start( &mut self, rrect: &RRect, dir: Direction, start: RectCorner, ) -> &mut Self
添加 RRect 并指定起始角。Adds RRect with start corner.