From f54afb117b27335113b0dcdb0985b901f014965c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 21 Nov 2026 03:49:04 -0800 Subject: [PATCH] Smooth: a drag that would not make a path smoother leaves it as it was path.smoothRegion kept every changed result. A drag along the top of a clean ellipse split it from 4 to 5 anchors without smoothing it, took away its Live Shape and added an undo step, and a third drag left it with 7 anchors and about 20% more turning. Each subpath's result is now measured against the subpath at one spacing: how much it turns along its length, with each turn at an anchor counted twice, and how much it bends. The result is kept only when it turns no more than a thousandth more and has fewer anchors, turns less or bends less. Otherwise the subpath stays as it was; a path with no kept subpath keeps its Live Shape, is left out of ids and the counts, and a call that keeps nothing adds no undo step. The measure and the thresholds are VectorCraft's own. Three tests that dragged over a convex curve with nothing to smooth now drag over a sharp peak or crest, so they still test the reach search and a closed path of two anchors. --- crates/engine/src/cmd/draw2/commands.rs | 2 +- crates/engine/src/cmd/draw2/smooth.rs | 114 +++++++++++++++++++++++- crates/engine/src/tests/draw2.rs | 90 ++++++++++++++++--- docs/mcp.md | 8 ++ docs/target-app-parity.md | 1 + 5 files changed, 203 insertions(+), 12 deletions(-) diff --git a/crates/engine/src/cmd/draw2/commands.rs b/crates/engine/src/cmd/draw2/commands.rs index e4846367b5..d56c4be6b4 100644 --- a/crates/engine/src/cmd/draw2/commands.rs +++ b/crates/engine/src/cmd/draw2/commands.rs @@ -120,7 +120,7 @@ pub fn specs() -> Vec { "Smooth", [], None, - "{points: [[x,y]…] (pen values after x and y are checked as path.freehand checks them and do not change the smoothing), radius?: pt (12), fidelity?: pt (2.5; kept within 0.000078125 and about 3195, the Smooth tool's 0.05 to 100 px at the highest and the lowest zoom: the tool sends its Fidelity in screen pixels divided by the zoom)} smooth selected paths near the drag, keeping a corner where the path turns by more than 57.5° at the anchor and over radius and twice radius on either side → {ids, before, after}", + "{points: [[x,y]…] (pen values after x and y are checked as path.freehand checks them and do not change the smoothing), radius?: pt (12), fidelity?: pt (2.5; kept within 0.000078125 and about 3195, the Smooth tool's 0.05 to 100 px at the highest and the lowest zoom: the tool sends its Fidelity in screen pixels divided by the zoom)} smooth selected paths near the drag, keeping a corner where the path turns by more than 57.5° at the anchor and over radius and twice radius on either side, and leaving a subpath as it is when the result would not be smoother (docs/mcp.md) → {ids, before, after}", has_selection, smooth_region ), diff --git a/crates/engine/src/cmd/draw2/smooth.rs b/crates/engine/src/cmd/draw2/smooth.rs index d0f480d132..cca6cbbb2c 100644 --- a/crates/engine/src/cmd/draw2/smooth.rs +++ b/crates/engine/src/cmd/draw2/smooth.rs @@ -730,6 +730,89 @@ fn smooth_open(anchors: &[Anchor], marked: &[bool], near: &dyn Fn(Point) -> bool out } +/// Most pieces [`roughness`] cuts one curved segment into. +const ROUGHNESS_SEGMENT_PIECES: usize = 1024; + +/// Most pieces [`roughness`] cuts the curved segments of one subpath into, shared equally by them. +const ROUGHNESS_PIECES: usize = 1 << 18; + +/// How rough the subpath `sp` is, measured along the lines between points on each curved segment +/// no more than `step` apart along its control polygon (at least 4 and at most +/// [`ROUGHNESS_SEGMENT_PIECES`] pieces a segment, fewer on a subpath of very many segments): how +/// much it turns along its length in radians, from the direction each segment leaves its first anchor +/// along to the one it arrives at its last anchor along, with each turn at an anchor counted twice; +/// and how much it bends, the sum of each turn between two pieces squared over their mean length. +/// `None` when a point or a turn is not a number. +fn roughness(sp: &SubPath, step: f64) -> Option<(f64, f64)> { + let segments = sp.segment_count(); + let most = (ROUGHNESS_PIECES / segments.max(1)).clamp(4, ROUGHNESS_SEGMENT_PIECES); + // The directions along the path, each with whether it leaves an anchor, and the pieces' vectors. + let (mut dirs, mut pieces): (Vec<(kurbo::Vec2, bool)>, Vec) = (vec![], vec![]); + for i in 0..segments { + let c = sp.segment(i); + if sp.segment_is_line(i) { + dirs.push((c.p3 - c.p0, true)); + pieces.push(c.p3 - c.p0); + continue; + } + let leave = [c.p1 - c.p0, c.p2 - c.p0, c.p3 - c.p0].into_iter().find(|d| d.hypot() > 1e-12).unwrap_or_default(); + let arrive = [c.p3 - c.p2, c.p3 - c.p1, c.p3 - c.p0].into_iter().find(|d| d.hypot() > 1e-12).unwrap_or_default(); + let len = polygon_len(c); + let k = if step > 0.0 && step.is_finite() && len.is_finite() { (len / step).ceil().clamp(4.0, most as f64) as usize } else { most }; + dirs.push((leave, true)); + let mut at = c.p0; + for j in 1..=k { + let q = if j == k { c.p3 } else { c.eval(j as f64 / k as f64) }; + dirs.push((q - at, false)); + pieces.push(q - at); + at = q; + } + dirs.push((arrive, false)); + } + // A direction of no length is left out; the turn at an anchor is then taken at the next one. + let mut kept: Vec<(kurbo::Vec2, bool)> = Vec::with_capacity(dirs.len()); + let mut at_anchor = false; + for (d, anchor) in dirs { + at_anchor |= anchor; + if d.hypot() > 1e-12 { + kept.push((d, at_anchor)); + at_anchor = false; + } + } + pieces.retain(|d| d.hypot() > 1e-12); + let turn = |u: kurbo::Vec2, v: kurbo::Vec2| u.cross(v).atan2(u.dot(v)).abs(); + let pairs = |n: usize| if sp.closed { n } else { n.saturating_sub(1) }; + let mut turning = 0.0; + for j in 0..pairs(kept.len()) { + let (u, (v, anchor)) = (kept[j].0, kept[(j + 1) % kept.len()]); + turning += if anchor { 2.0 } else { 1.0 } * turn(u, v); + } + let mut bending = 0.0; + for j in 0..pairs(pieces.len()) { + let (u, v) = (pieces[j], pieces[(j + 1) % pieces.len()]); + bending += turn(u, v).powi(2) / (0.5 * (u.hypot() + v.hypot())); + } + (turning.is_finite() && bending.is_finite()).then_some((turning, bending)) +} + +/// Whether the Smooth tool keeps `new`, the subpath `old` smoothed with the reach `radius` +/// (VectorCraft's own rule). Both are measured with [`roughness`] at one spacing, an eighth of the +/// reach or 1/512 of the diagonal of `old`'s control points, whichever is smaller. `new` must turn +/// no more than a thousandth more than `old` (counting a turn of less than 1 radian as 1), and it +/// must have fewer anchors, turn less, or bend more than a ten-thousandth less. A result that would +/// leave the path rougher, or that adds anchors or changes the path without smoothing it, is not +/// kept. +fn smoother(old: &SubPath, new: &SubPath, radius: f64) -> bool { + let size = old.anchors.iter().fold(None, |r: Option, a| { + let b = Rect::from_points(a.p, a.h_in).union_pt(a.h_out); + Some(r.map_or(b, |r| r.union(b))) + }); + let step = (radius / 8.0).min(size.map_or(0.0, |r| r.width().hypot(r.height()) / 512.0)); + let (Some((t0, b0)), Some((t1, b1))) = (roughness(old, step), roughness(new, step)) else { return false }; + let scale = t0.max(1.0); + t1 <= t0 + 1e-3 * scale && (new.anchors.len() < old.anchors.len() || t0 - t1 >= 1e-6 * scale || b0 - b1 > 1e-4 * b0) +} + pub(super) fn smooth_region(s: &mut Session, p: &Value) -> Result { const C: &str = "path.smoothRegion"; let pts = points_param(p, "points", C)?; @@ -759,7 +842,10 @@ pub(super) fn smooth_region(s: &mut Session, p: &Value) -> Result { _ => sp.clone(), }) .collect(); - if changed { + // A subpath whose result would not be smoother stays as it was. + let subs: Vec = + subs.into_iter().zip(&pd.subpaths).map(|(n, sp)| if n == *sp || smoother(sp, &n, radius) { n } else { sp.clone() }).collect(); + if changed && subs != pd.subpaths { let np = PathData::new(subs); before += pd.anchor_count(); after += np.anchor_count(); @@ -1246,4 +1332,30 @@ mod tests { assert_eq!(smooth_corners(&jags, true, 12.0), vec![false; 16]); assert_eq!(smooth_corners(&polyline(&[(0.0, 0.0), (6.0, 0.0), (3.0, 5.196)]), true, 12.0), vec![true; 3]); } + + /// `sp` scaled by `k` about the origin. + fn scaled(sp: &SubPath, k: f64) -> SubPath { + let at = |p: Point| Point::new(p.x * k, p.y * k); + SubPath::new(sp.anchors.iter().map(|a| Anchor { p: at(a.p), h_in: at(a.h_in), h_out: at(a.h_out), ..*a }).collect::>(), sp.closed) + } + + /// The Smooth tool keeps a result that turns less, and not one that turns more with as many + /// anchors, one that adds an anchor and keeps the outline, or one that is the path itself, at + /// any size. + #[test] + fn the_smooth_tool_keeps_only_a_smoother_result() { + let round = ring(); + let mut bumped = ring(); + bumped.anchors[1].translate(kurbo::Vec2::new(0.0, -25.0)); + let split = start_nearest(ring(), round.segment(0).eval(0.3), &round); + assert_eq!(split.anchors.len(), 5, "{split:?}"); + for k in [1e-3, 1.0, 1e3] { + let (round, bumped, split) = (scaled(&round, k), scaled(&bumped, k), scaled(&split, k)); + let reach = 12.0 * k; + assert!(smoother(&bumped, &round, reach), "at {k}x a bump smoothed away is kept"); + assert!(!smoother(&round, &bumped, reach), "at {k}x a bump added is not kept"); + assert!(!smoother(&round, &split, reach), "at {k}x an anchor added on the outline is not kept"); + assert!(!smoother(&round, &round.clone(), reach), "at {k}x the same path is not kept"); + } + } } diff --git a/crates/engine/src/tests/draw2.rs b/crates/engine/src/tests/draw2.rs index 75d7d081d9..3e2a319c01 100644 --- a/crates/engine/src/tests/draw2.rs +++ b/crates/engine/src/tests/draw2.rs @@ -2306,13 +2306,13 @@ fn a_smooth_drag_that_comes_back_to_a_segment_smooths_where_it_comes_back() { assert!(gap < 0.5, "{between:?} is {gap} pt off the smoothed path"); } -/// A click on a curve 100,000 pt long, between the places a fixed number of samples along it would -/// look at, still finds the curve under it. +/// A click on a curve 100,000 pt long, at the sharp crest in its middle and between the places a +/// fixed number of samples along it would look at, still finds the curve under it. #[test] fn a_smooth_drag_finds_a_very_long_curve_under_it() { use kurbo::ParamCurve; let mut s = session(); - let anchors = [json!({"x": 0.0, "y": 0.0, "out": [30000.0, -9000.0]}), json!({"x": 100000.0, "y": 0.0, "in": [70000.0, -9000.0]})]; + let anchors = [json!({"x": 0.0, "y": 0.0, "out": [99800.0, -9000.0]}), json!({"x": 100000.0, "y": 0.0, "in": [200.0, -9000.0]})]; let id = smooth_test_path(&mut s, &anchors, false); let at = path(&s, id).subpaths[0].segment(0).eval(0.5 + 0.5 / 1024.0); assert_eq!(smooth_pass_ids(&mut s, &[at]), json!([id.0])); @@ -2329,9 +2329,9 @@ fn a_smooth_click_that_only_just_reaches_a_segment_smooths_it() { assert_ne!(path(&s, id), before); } -/// A drag that runs along a very long curve first and then crosses a second curve away from its -/// middle, with both of its anchors out of reach, smooths the second curve too: each curve in reach -/// gets the same share of the search, so the long one does not use it all. +/// A drag that runs along a very long curve first and then crosses a second curve at the peak in +/// its middle, with both of its anchors out of reach, smooths the second curve too: each curve in +/// reach gets the same share of the search, so the long one does not use it all. #[test] fn a_long_curve_searched_first_leaves_the_next_curve_its_share() { let mut s = session(); @@ -2342,7 +2342,7 @@ fn a_long_curve_searched_first_leaves_the_next_curve_its_share() { ); let next = smooth_test_path( &mut s, - &[json!({"x": 100100.0, "y": -100.0, "out": [100130.0, 200.0]}), json!({"x": 100100.0, "y": 900.0, "in": [100130.0, 600.0]})], + &[json!({"x": 100050.0, "y": 75.0, "out": [100150.0, -25.0]}), json!({"x": 100250.0, "y": 75.0, "in": [100150.0, -25.0]})], false, ); s.execute("select.set", &json!({"ids": [long.0, next.0]})).unwrap(); @@ -2372,14 +2372,14 @@ fn smoothing_smooths_an_open_two_anchor_path() { assert_eq!((a[0].p, a[a.len() - 1].p), (Point::new(100.0, 200.0), Point::new(200.0, 200.0)), "the ends stay"); } -/// A closed path of two anchors is smoothed along the middle of one side and stays closed. +/// A closed path of two anchors is smoothed at the peak in the middle of one side and stays closed. #[test] fn smoothing_smooths_a_closed_two_anchor_path() { use kurbo::ParamCurve; let mut s = session(); let anchors = [ - json!({"x": 100.0, "y": 300.0, "in": [100.0, 400.0], "out": [100.0, 200.0]}), - json!({"x": 300.0, "y": 300.0, "in": [300.0, 160.0], "out": [300.0, 440.0]}), + json!({"x": 100.0, "y": 300.0, "in": [100.0, 400.0], "out": [200.0, 150.0]}), + json!({"x": 300.0, "y": 300.0, "in": [200.0, 150.0], "out": [300.0, 440.0]}), ]; let id = smooth_test_path(&mut s, &anchors, true); let before = path(&s, id); @@ -2405,6 +2405,76 @@ fn smoothing_leaves_paths_out_of_reach_and_straight_segments_alone() { assert_eq!(path(&s, line), before); } +/// Whether `id` is still a Live Shape. +fn smooth_test_live(s: &Session, id: NodeId) -> bool { + matches!(s.doc().unwrap().doc.node(id).unwrap().kind, NodeKind::Path { live: Some(_), .. }) +} + +/// Smooth drags over a clean ellipse, again and again and at any Fidelity, change nothing: the +/// ellipse has nothing to smooth, so no pass adds anchors to it, leaves it rougher, adds an undo step +/// or takes its Live Shape away. Each returns no ids and counts of 0, as a drag that reaches no path +/// does. +#[test] +fn smooth_drags_over_a_clean_ellipse_change_nothing() { + for fidelity in [0.05, 0.5, 2.5, 10.0] { + let mut s = session(); + let id = NodeId(s.execute("shape.ellipse", &json!({"x": 100, "y": 100, "width": 200, "height": 120})).unwrap()["id"].as_u64().unwrap()); + s.execute("select.set", &json!({"ids": [id.0]})).unwrap(); + let before = path(&s, id); + let undo = s.doc().unwrap().history.undo.len(); + let pts: Vec<_> = smooth_drag_along(100.0, 160.0, 240.0).iter().map(|p| json!([p.x, p.y])).collect(); + for pass in 1..=4 { + let r = s.execute("path.smoothRegion", &json!({"points": pts, "radius": 12, "fidelity": fidelity})).unwrap(); + assert_eq!(r, json!({"ids": [], "before": 0, "after": 0}), "Fidelity {fidelity}, pass {pass}"); + assert_eq!(path(&s, id), before, "Fidelity {fidelity}, pass {pass}: {} anchors", path(&s, id).anchor_count()); + assert!(smooth_test_live(&s, id), "Fidelity {fidelity}, pass {pass}: still a Live Shape"); + assert_eq!(s.doc().unwrap().history.undo.len(), undo, "Fidelity {fidelity}, pass {pass}: no undo step"); + } + } +} + +/// A Smooth drag over a clean ellipse and a jagged line selected together smooths the line only: the +/// result names the line and counts its anchors alone, the ellipse stays as it was and a Live Shape, +/// and one undo brings the line back. +#[test] +fn a_smooth_drag_over_an_ellipse_and_a_jagged_line_changes_only_the_line() { + let mut s = session(); + let ellipse = NodeId(s.execute("shape.ellipse", &json!({"x": 100, "y": 100, "width": 200, "height": 120})).unwrap()["id"].as_u64().unwrap()); + let mut seed = 11u64; + let anchors: Vec<_> = (0..=50).map(|i| json!({"x": 320.0 + 5.0 * f64::from(i), "y": 100.0 + smooth_noise(&mut seed)})).collect(); + let line = smooth_test_path(&mut s, &anchors, false); + s.execute("select.set", &json!({"ids": [ellipse.0, line.0]})).unwrap(); + let (oval, jagged) = (path(&s, ellipse), path(&s, line)); + let pts: Vec<_> = smooth_drag_along(100.0, 160.0, 580.0).iter().map(|p| json!([p.x, p.y])).collect(); + let r = s.execute("path.smoothRegion", &json!({"points": pts, "radius": 12, "fidelity": 2.5})).unwrap(); + let smoothed = path(&s, line); + assert!(smoothed.anchor_count() < jagged.anchor_count(), "the line is smoothed: {} anchors", smoothed.anchor_count()); + assert_eq!(r, json!({"ids": [line.0], "before": jagged.anchor_count(), "after": smoothed.anchor_count()})); + assert_eq!(path(&s, ellipse), oval); + assert!(smooth_test_live(&s, ellipse), "the ellipse is still a Live Shape"); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!((path(&s, line), path(&s, ellipse)), (jagged, oval)); +} + +/// A Smooth drag at the lowest Fidelity still smooths a jagged line: it turns less and has fewer +/// anchors after each of three drags. +#[test] +fn a_smooth_drag_at_the_lowest_fidelity_still_smooths_a_jagged_line() { + let mut s = session(); + let mut seed = 11u64; + let anchors: Vec<_> = (0..=60).map(|i| json!({"x": 100.0 + 5.0 * f64::from(i), "y": 200.0 + smooth_noise(&mut seed)})).collect(); + let id = smooth_test_path(&mut s, &anchors, false); + let pts: Vec<_> = smooth_drag_along(200.0, 90.0, 410.0).iter().map(|p| json!([p.x, p.y])).collect(); + let mut before = path(&s, id); + for pass in 1..=3 { + s.execute("path.smoothRegion", &json!({"points": pts, "radius": 12, "fidelity": 0.05})).unwrap(); + let after = path(&s, id); + assert!(after.anchor_count() < before.anchor_count(), "pass {pass}: {} -> {} anchors", before.anchor_count(), after.anchor_count()); + assert!(total_turning(&after) < total_turning(&before), "pass {pass}: turning {} -> {}", total_turning(&before), total_turning(&after)); + before = after; + } +} + /// The turn, in degrees, of `sp` at each of its anchors: round a closed path, and 0 at an open /// path's first and last anchors. fn smooth_anchor_turns(sp: &vectorcraft_geom::SubPath) -> Vec { diff --git a/docs/mcp.md b/docs/mcp.md index 5032690fc6..27b2b0d236 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -7171,6 +7171,14 @@ own, and the corner keeps its place and the directions the path arrives and leav `fidelity`. A call that changes no anchor returns `{ids: [], before: 0, after: 0}` and adds no undo step. The 57.5° threshold is VectorCraft's own value. +`path.smoothRegion` keeps a subpath's result only when it is smoother. Measured along lines between points no more +than an eighth of `radius` apart (or 1/512 of the subpath's size when that is smaller), the result must turn no more +than a thousandth more than the subpath did, with each turn at an anchor counted twice, and it must have fewer +anchors, turn less, or bend more than a ten-thousandth less (the sum of each turn squared over the length it is taken +over). Any other result is dropped and the subpath stays as it was. A path none of whose subpaths is kept stays a Live +Shape if it was one, is left out of `ids` and is not counted in `before` or `after`. The measure and both thresholds +are VectorCraft's own. + In the desktop app, Object › Path › Smooth, the canvas context menu's Smooth… (listed while the selection holds a path) and the Contextual Task Bar's Smooth (with a path selected whole with the Direct Selection tool) open the slider (`ui.menuDialog {command: "object.path.smooth"}`, dialog `smoothSlider` with field `level`) at the diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index f8a3dc84a0..e5658b152a 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1547,6 +1547,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur `brush.freehand` refuses a `brush` that names no brush in the document, or is not a string, and a `style` other than "pencil" or "brush", with an error and no change or undo step, instead of drawing the plain path; the Paintbrush skips a chosen brush that has since been deleted (engine tests `brush_freehand_refuses_a_brush_or_style_it_cannot_use` and `paintbrush_tool_skips_a_deleted_brush`). A `brush.freehand` stroke and its brush are one undo step, so one Undo removes both. A `brush` for a path with no stroke (a continued or redrawn path without one, or a new filled "pencil" path while the stroke is None) is refused with "cannot apply brush ``: path has no stroke", and a key the command does not take with "unknown parameter", with no change or undo step; the no-stroke refusal is VectorCraft's own rule (engine tests `brush_freehand_direct_call_has_one_undo_step`, `brush_freehand_refuses_a_brush_on_a_path_without_a_stroke` and `brush_freehand_refuses_unknown_keys`). Each drag of the Smooth tool smooths the stretch of a selected path in its reach along its length before refitting it within Fidelity, so a wobble wider than Fidelity is smoothed out and another drag over the same place smooths it further, as [the help page](https://helpx.adobe.com/illustrator/using/tool-techniques/smooth-tool.html) describes (`path.smoothRegion`). The smoothing spread (a third of the reach) and the rule that each refit stays within twice the distance the smoothing moved the path, so repeated drags do not drift from it, are VectorCraft's own. A drag over the whole of a closed path smooths it across its first anchor too, so a bump there is smoothed like any other and no corner is left; Object › Path › Smooth smooths a closed path across its first anchor the same way. + A Smooth drag changes a path only when the result is smoother, which [the help page](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=79) gives as the aim of the tool's Fidelity: the result turns no more than a thousandth more along its length than the path did, with each turn at an anchor counted twice, and it has fewer anchors, turns less or bends less. Otherwise the path stays as it was and keeps its Live Shape, and the drag adds no undo step, so drags over a clean ellipse no longer add anchors to it or leave it rougher. A drag that only splits a convex curve into more anchors without smoothing it now leaves the path as it was. The measure and its thresholds are VectorCraft's own (engine tests `smooth_drags_over_a_clean_ellipse_change_nothing`, `a_smooth_drag_over_an_ellipse_and_a_jagged_line_changes_only_the_line`, `a_smooth_drag_at_the_lowest_fidelity_still_smooths_a_jagged_line` and `cmd::draw2::smooth::tests::the_smooth_tool_keeps_only_a_smoother_result`). When a Smooth tool drag reaches the first anchor of a closed path, the smoothed path starts at its point nearest where that anchor was: at an anchor there, or at a new anchor split into the curve without changing its outline. Dashes and type on the path start from that point. A drag that does not reach the first anchor leaves it first. This is VectorCraft's own rule (engine tests `smoothing_over_a_closed_paths_first_anchor_keeps_its_start` and `smoothing_a_whole_closed_path_with_a_spike_keeps_its_start`). The Smooth tool shows the Not Allowed cursor while no path is selected that it can act on (an editable path, not a guide, with three or more anchors on one of its subpaths or two anchors joined by a curve), and the release of a drag then sends no command and changes nothing; [the help page](https://helpx.adobe.com/illustrator/using/tool-techniques/smooth-tool.html) has the path selected first. A selected path anywhere on the canvas gives the Smooth cursor wherever the pointer is. The Pencil with Alt key toggles to Smooth Tool on and the Blob Brush show Not Allowed the same way when Alt gives them the Smooth tool; the Paintbrush keeps its closing cursor, since its release with Alt closes the stroke. Use Precise Cursors leaves Not Allowed as it is. This cursor rule is VectorCraft's own (tools `smooth_shows_not_allowed_without_a_selected_path_to_smooth`, `borrowed_smooth_shows_not_allowed_without_a_selected_path_to_smooth`, `smoothing_release_sends_nothing_without_a_selected_path_to_smooth`; engine `use_precise_cursors_keeps_the_smooth_tools_not_allowed_pointer`). When a Smooth tool drag reaches the first or last anchor of an open path, that anchor stays where it is and the curve there leaves or arrives along the smoothed path within the reach, so a jagged first or last segment no longer sets the end's direction; an end where the smoothed path turns back by 90° or more keeps its segment's direction, and where the refitted stretch ends inside the path the curve keeps the direction of the part outside the drag. This rule is VectorCraft's own (`tests/draw2.rs`, `smoothing_an_open_path_turns_its_jagged_ends_with_the_path` and `a_smooth_drag_turns_only_the_end_it_reaches`).