pub struct PathBuilder { /* private fields */ }Expand description
路径构造器(多回路,支持 fill 三角化与 stroke 曲线导出)
Implementations§
Source§impl PathBuilder
impl PathBuilder
pub fn new() -> Self
Sourcepub fn transform(&mut self, sx: f32, sy: f32)
pub fn transform(&mut self, sx: f32, sy: f32)
对所有已积累的坐标乘 (sx, sy) —— 用于把 viewBox 坐标缩放到屏幕像素。 段内 flatten 容差按 max(|sx|,|sy|) 同步缩放(均匀缩放下严格正确)。
pub fn move_to(&mut self, x: f32, y: f32)
pub fn line_to(&mut self, x: f32, y: f32)
Sourcepub fn quad_to(&mut self, cx: f32, cy: f32, ex: f32, ey: f32, flat: f32)
pub fn quad_to(&mut self, cx: f32, cy: f32, ex: f32, ey: f32, flat: f32)
二次贝塞尔(控制点 cx,cy,终点 ex,ey),flat = 当前坐标空间容差(0.5 / scale)。 存储期保留曲线,fill/paths 导出时才按 flat flatten。
Sourcepub fn cubic_to(
&mut self,
c1x: f32,
c1y: f32,
c2x: f32,
c2y: f32,
ex: f32,
ey: f32,
flat: f32,
)
pub fn cubic_to( &mut self, c1x: f32, c1y: f32, c2x: f32, c2y: f32, ex: f32, ey: f32, flat: f32, )
三次贝塞尔(控制点 c1/c2,终点 ex,ey),flat 语义同 quad_to
Sourcepub fn arc_to(
&mut self,
cx: f32,
cy: f32,
r: f32,
start_angle: f32,
end_angle: f32,
num_segments: u32,
)
pub fn arc_to( &mut self, cx: f32, cy: f32, r: f32, start_angle: f32, end_angle: f32, num_segments: u32, )
圆弧(圆心 cx,cy + 半径 r + 起/终角度(弧度) + 分段数上限) 以三次贝塞尔段逼近存储(kappa 圆逼近),fill 导出时 flatten。
start_angle/end_angle标准数学极坐标:0 = +X 轴,逆时针增大num_segments只是段数上限;实际段数 = ceil(|sweep| / 90°)- 自动处理跨过 ±TAU 的情况(end < start 时逆时针走大弧)
pub fn close(&mut self)
Sourcepub fn paths(&self) -> Vec<Vec<(f32, f32)>>
pub fn paths(&self) -> Vec<Vec<(f32, f32)>>
导出所有已闭合回路(去掉首尾重复点;曲线段 flatten 成折线)。 需要曲线时请用 curve_contours。
Sourcepub fn curve_contours(&self) -> Vec<((f32, f32), Vec<PathSeg>, bool)>
pub fn curve_contours(&self) -> Vec<((f32, f32), Vec<PathSeg>, bool)>
曲线保留导出:每个回路 (起点, 段序列, 是否显式 close)。
与 paths() 的区别:Quad/Cubic 不 flatten,把曲线原样交给曲线感知 消费者(如 tiny-skia PathStroker 的 quad/cubic stroke 路径)——密集折线 逼近会让 stroker 在每个折点发 inner join 毛刺,锐角/密段时互相交叉。
Trait Implementations§
Source§impl Clone for PathBuilder
impl Clone for PathBuilder
Source§impl Debug for PathBuilder
impl Debug for PathBuilder
Auto Trait Implementations§
impl Forget for PathBuilder
impl Freeze for PathBuilder
impl Move for PathBuilder
impl RefUnwindSafe for PathBuilder
impl Send for PathBuilder
impl Sync for PathBuilder
impl Unpin for PathBuilder
impl UnsafeUnpin for PathBuilder
impl UnwindSafe for PathBuilder
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