From da8f6ab721ed3bef5c33426d4be08deba776d08c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 14 Nov 2026 08:31:41 -0800 Subject: [PATCH] Smooth tool: a whole closed path with a corner starts nearest its old start When a drag reaches every anchor of a closed path that has a corner, the path is cut open at the corner and refitted. The result started at the corner unless the refit kept an anchor exactly at the old first anchor. It now starts at its point nearest the old first anchor, at an anchor there or at a new anchor split into the curve, as the other closed-path cases do. --- crates/engine/src/cmd/draw2/smooth.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/cmd/draw2/smooth.rs b/crates/engine/src/cmd/draw2/smooth.rs index e91fa138e4..be7db9a1ae 100644 --- a/crates/engine/src/cmd/draw2/smooth.rs +++ b/crates/engine/src/cmd/draw2/smooth.rs @@ -571,11 +571,9 @@ fn smooth_subpath(sp: &SubPath, pts: &[Point], radius: f64, share: usize, tol: f if let Some(r0) = res.first_mut() { *r0 = Anchor::with_handles(r0.p, l.h_in, r0.h_out); } - // The path starts where it did when the refit keeps an anchor there. - if let Some(j) = res.iter().position(|a| a.p == sp.anchors[0].p) { - res.rotate_left(j); - } - return Some(SubPath::new(res, true)); + // The path starts where it did when the refit keeps an anchor there, and otherwise at its + // point nearest there. + return Some(start_nearest(SubPath::new(res, true), start, sp)); }; // Rotate so an untouched anchor comes first, duplicate it at the end and treat as open. let mut open = sp.clone();