mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-15 07:42:42 +00:00
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.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user