VectorCraft: An open-source, vector art tool written by scratch in pure Rust
Anchor Point tool: a click on a handle end retracts that handle only (fixes #2267)
Marco Arnulfobb660708416a
diff --git a/crates/engine/src/tests_draw2.rs b/crates/engine/src/tests_draw2.rsindex cb81d413f..053f6b2f4 100644--- a/crates/engine/src/tests_draw2.rs+++ b/crates/engine/src/tests_draw2.rs@@ -430,6 +430,25 @@ fn anchor_point_tool_converts() {assert!(d < 0.5, "{q:?}");}+/// #2267: clicking one handle end with the Anchor Point tool retracts that handle alone, as one+/// undo step.+#[test]+fn anchor_point_tool_click_on_a_handle_retracts_it() {+ let mut s = session();+ let id = rect(&mut s, 100.0, 100.0, 100.0, 100.0);+ drag(&mut s, "anchorPoint", &[(100.0, 100.0), (130.0, 80.0)], Mods::default());+ s.execute("select.set", &json!({"ids": [id.0]})).unwrap();+ let smooth = path(&s, id).subpaths[0].anchors[0];+ let undo = undo_steps(&s);+ click(&mut s, "anchorPoint", 130.0, 80.0);+ let a = path(&s, id).subpaths[0].anchors[0];+ assert!(!a.has_out());+ assert_eq!((a.p, a.h_in, a.kind), (smooth.p, smooth.h_in, vectorcraft_geom::AnchorKind::Corner));+ assert_eq!(undo_steps(&s), undo + 1);+ s.execute("edit.undo", &json!({})).unwrap();+ assert_eq!(path(&s, id).subpaths[0].anchors[0], smooth);+}+#[test]fn scissors_opens_closed_path() {let mut s = session();diff --git a/crates/tools/src/draw2/anchor.rs b/crates/tools/src/draw2/anchor.rsindex 0e6cba65e..56c54b476 100644--- a/crates/tools/src/draw2/anchor.rs+++ b/crates/tools/src/draw2/anchor.rs@@ -2,9 +2,10 @@//!//! Add: click a segment to insert an anchor without changing the shape (Alt = delete).//! Delete: click an anchor to remove it, re-fitting the neighbouring curve (Alt = add).-//! Anchor Point: click a smooth anchor → corner; drag an anchor → pull out smooth handles; drag a-//! handle → move it independently (Shift: at 45° steps round its anchor); drag a segment → reshape-//! the curve, a selected blend's spine's too, straight or curved (#1111).+//! Anchor Point: click a smooth anchor → corner; drag an anchor → pull out smooth handles; click a+//! handle end → retract that handle only (#2267); drag a handle → move it independently (Shift: at+//! 45° steps round its anchor); drag a segment → reshape the curve, a selected blend's spine's too,+//! straight or curved (#1111).//! Scissors: click a path to split it there.use serde_json::json;@@ -31,6 +32,7 @@ enum State {si: usize,ai: usize,out: bool,+ start: Point,began: bool,},/// Bending a segment: a path's, or (`spine`) a selected blend's spine's.@@ -110,7 +112,7 @@ impl Tool for AnchorTool {}("anchorPoint", PointerKind::Down) => {if let Some((id, si, ai, out)) = hit_handle(cx, p, point) {- self.state = State::Handle { id, si, ai, out, began: false };+ self.state = State::Handle { id, si, ai, out, start: p, began: false };self.snap = HandleSnap::default();} else if let Some((id, si, ai)) = hit_anchor(cx, p, point) {self.state = State::Convert { id, si, ai, start: p, began: false };@@ -125,8 +127,9 @@ impl Tool for AnchorTool {let mut out = vec![];let (began, far) = match self.state {State::Idle => return out,- State::Convert { began, start, .. } | State::Reshape { began, start, .. } => (began, p.distance(start) >= cx.tol(2.0)),- State::Handle { began, .. } => (began, true),+ State::Convert { began, start, .. } | State::Handle { began, start, .. } | State::Reshape { began, start, .. } => {+ (began, p.distance(start) >= cx.tol(2.0))+ }};if !began {if !far {@@ -183,6 +186,15 @@ impl Tool for AnchorTool {vec![]}}+ State::Handle { id, si, ai, out, began: false, .. } => {+ let Some(a) = cx.doc.node(id).and_then(|n| n.path_data()).and_then(|pd| pd.subpaths.get(si)?.anchors.get(ai)) else {+ return vec![];+ };+ vec![Action::Exec(+ "path.setHandle".into(),+ json!({"id": id.0, "subpath": si, "anchor": ai, "which": if out { "out" } else { "in" }, "x": a.p.x, "y": a.p.y, "independent": true}),+ )]+ }_ => vec![],}}@@ -305,4 +317,39 @@ mod tests {let single = ToolContext { handles_multiple: false, ..cx(&d, &s, &p) };assert_eq!(dragged(press(&single, 240.0, 301.0)), "path.reshapeSegment");}++ /// #2267: clicking a handle end retracts that handle only; the anchor becomes a corner and+ /// keeps the other handle, as Illustrator's Anchor Point tool does.+ #[test]+ fn anchor_point_click_on_a_handle_retracts_only_that_handle() {+ let (mut d, _) = doc_with_rect();+ let l = d.layers[0].id;+ let id = d.alloc_id();+ let mut sp = vectorcraft_geom::SubPath::polyline(&[Point::new(100.0, 300.0), Point::new(200.0, 300.0), Point::new(300.0, 300.0)], false);+ sp.anchors[1] = vectorcraft_geom::Anchor::smooth(Point::new(200.0, 300.0), Point::new(240.0, 320.0));+ let path = vectorcraft_geom::PathData::single(sp);+ d.insert(Some(l), 1, vectorcraft_doc::Node::path(id, path, vectorcraft_doc::Appearance::default_art())).unwrap();+ let mut s = Selection::default();+ s.set([id]);+ let p = paint();+ let cx = cx(&d, &s, &p);+ let retract = |which: &str| {+ vec![Action::Exec(+ "path.setHandle".into(),+ json!({"id": id.0, "subpath": 0, "anchor": 1, "which": which, "x": 200.0, "y": 300.0, "independent": true}),+ )]+ };+ let mut t = AnchorTool::new("anchorPoint");+ t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 240.0, 320.0));+ assert_eq!(t.pointer(&cx, &PointerEvent::new(PointerKind::Up, 240.0, 320.0)), retract("out"));+ // A hand that shakes by a pixel still clicks; the incoming handle sits opposite, at (160, 280).+ t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 160.0, 280.0));+ assert!(t.pointer(&cx, &PointerEvent::new(PointerKind::Drag, 160.5, 280.5)).is_empty());+ assert_eq!(t.pointer(&cx, &PointerEvent::new(PointerKind::Up, 160.5, 280.5)), retract("in"));+ // The command leaves the other handle where it was.+ let mut a = vectorcraft_geom::Anchor::smooth(Point::new(200.0, 300.0), Point::new(240.0, 320.0));+ a.set_handle(true, a.p, true);+ assert!(!a.has_out());+ assert_eq!(a.h_in, Point::new(160.0, 280.0));+ }}diff --git a/docs/ui-parity.md b/docs/ui-parity.mdindex d30373cf3..d465f3d86 100644--- a/docs/ui-parity.md+++ b/docs/ui-parity.md@@ -1,6 +1,6 @@# UI and interaction parity-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-16 · **Change:** minor (Smart Guides: the dragged end of a straight segment keeps to its extension at any angle, #2120; Warp Options controls verified by focused checks and original-image review; estimates unchanged; existing-guide Escape cancellation validated 2026-10-14; scores and hours unchanged; open-path anchor Delete keeps surviving runs separate; estimates unchanged; Artboard tab-switch follow-up historically validated on `a0671777`; scores and hours unchanged; Artboard clean active-tab close/Delete follow-up validated 2026-10-15; Curvature curve geometry, #1236 in part; Width-point finite-arithmetic follow-up validated; scores and hours unchanged; Image Trace adjustment discovery; later 2026-10-14 merges: macOS save sheet Format menu back to missing, #1855, #866 reopened; anchor X/Y/W/H in the Transform panel, Properties and Control bar, #1824; Snap to Grid over Snap to Pixel, #1816; toolbar labels, columns and the All Tools drawer, #1751; Actions panel selection, #1629 in part; scores unchanged; 2026-10-14 merges: anchor Align and Distribute, #1636; Delete on closed paths and whole objects, #1674; selection inside isolation, #1666; Escape in a Direct Selection drag and while typing, #1743, #1686; Pen clicks under 3 px, #1663; [ and ] on more tools, #1661 in part; fields commit on click away, #1787; command search keys, #1757; a guide's position in the Transform panel is a convenience with no parity claim, #1659; scores unchanged; intersect Smart Guides for drawn points and dragged anchors, #1602 in part; a ruler guide's position in the Transform panel, #1597 in part; Symbol Options before New Symbol, #1560; tool flyout widths, #1616; Pathfinder Trim, Merge and Crop strokes, #1570; scores unchanged; G1/M11: Artboard deletion and history selection normalization; history regressions and full workspace CI pass; scores and hours unchanged; Width Point Edit: Shift-double-click enables adjoining adjustment; plain double-click keeps it off; scores and hours unchanged; per-corner radius fields with a link toggle, split from #1594; Join merges anchors lying on one another, #1533; correction: Average and Join with a corner or smooth choice is missing, not done; guide objects take the guide colour and style and Lock Guides, #1534; Keyboard Shortcuts lists commands outside the menus, #1539; round corners next to curves and the Smooth tool's reach, #1512; Make Compound Path on a group, #1537; dialog slider rails, #1483; template layers stay in Preview in Outline view, #1486; Direct Selection takes the selected object's anchor where anchors coincide, #1508; Tabs panel stop drags, #1458; Split Into Grid dialog, #1462; Transform Objects and Reflect's angle, #1448 and #1460; Pathfinder panel on a group, #1450; value fields: readable selection, #1465 in part, and a focused field follows its value, #1457; scores unchanged; Transform dialogs have a live Preview and step with the arrow keys, #1412; transform tools, dialogs and Move act on direct-selected anchors, #1408; the bounding box hides during a corner drag, #1229; scores unchanged; dialogs focus their first field on every open, #1367, and a first field that starts greyed out once it is enabled, #1395; scores unchanged; Rectangular Grid and Polar Grid click dialogs take the skew, frame, compound path and Fill Grid options, #1377 in part, score unchanged; Live Corners: a Direct Selection click on a widget selects its corner, #1239; custom ruler origin, #1212; Artboard tool clicks fit the topmost editable object in one undo step (#1227); scores unchanged; Pathfinder single-result source names and SVG IDs retained, #1293; DXF control-point SPLINE closure read, #1299 follow-up; Document Setup: Edit Artboards closes the modal after applying valid settings; pointer-click regressions; scores and hours unchanged; Artboards: Escape exits editing; an active drag cancels first; shortcut-routing regression; scores and hours unchanged; Simplify preview/counts and valid rewritten-path selection (#1272); parity remains partial; Texture-effect drag redraws optimized (#1257); idle Windows interaction still unverified; scores unchanged; Curvature point display improved (#1236, in part); scores unchanged; Direct Selection: no-op anchor Align preserves Undo, Redo and saved state (#1180 follow-up); Eyedropper cursor distinguished from precise crosshair (#1269); scores unchanged; Eyedropper can read visible locked and outside-isolation sources (#1251); scores unchanged; Direct Selection: independent segment picks and Delete (#1278); scores unchanged; Adding paint to an unpainted zero-width stroke restores the 1 pt default (#1253); scores unchanged; macOS save sheets offer a Format menu, #866; Attributes fill-rule controls edit the compound when a member is selected, #1197; a marquee needs to touch a path, not just lie inside its fill, #1103; earlier: Live Corners round corners between curved sides, #1144) · **Target:** Adobe Illustrator 2026 (30.x)+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-16 · **Change:** minor (Anchor Point tool: a click on a handle end retracts that handle only, #2267; scores unchanged; Smart Guides: the dragged end of a straight segment keeps to its extension at any angle, #2120; Warp Options controls verified by focused checks and original-image review; estimates unchanged; existing-guide Escape cancellation validated 2026-10-14; scores and hours unchanged; open-path anchor Delete keeps surviving runs separate; estimates unchanged; Artboard tab-switch follow-up historically validated on `a0671777`; scores and hours unchanged; Artboard clean active-tab close/Delete follow-up validated 2026-10-15; Curvature curve geometry, #1236 in part; Width-point finite-arithmetic follow-up validated; scores and hours unchanged; Image Trace adjustment discovery; later 2026-10-14 merges: macOS save sheet Format menu back to missing, #1855, #866 reopened; anchor X/Y/W/H in the Transform panel, Properties and Control bar, #1824; Snap to Grid over Snap to Pixel, #1816; toolbar labels, columns and the All Tools drawer, #1751; Actions panel selection, #1629 in part; scores unchanged; 2026-10-14 merges: anchor Align and Distribute, #1636; Delete on closed paths and whole objects, #1674; selection inside isolation, #1666; Escape in a Direct Selection drag and while typing, #1743, #1686; Pen clicks under 3 px, #1663; [ and ] on more tools, #1661 in part; fields commit on click away, #1787; command search keys, #1757; a guide's position in the Transform panel is a convenience with no parity claim, #1659; scores unchanged; intersect Smart Guides for drawn points and dragged anchors, #1602 in part; a ruler guide's position in the Transform panel, #1597 in part; Symbol Options before New Symbol, #1560; tool flyout widths, #1616; Pathfinder Trim, Merge and Crop strokes, #1570; scores unchanged; G1/M11: Artboard deletion and history selection normalization; history regressions and full workspace CI pass; scores and hours unchanged; Width Point Edit: Shift-double-click enables adjoining adjustment; plain double-click keeps it off; scores and hours unchanged; per-corner radius fields with a link toggle, split from #1594; Join merges anchors lying on one another, #1533; correction: Average and Join with a corner or smooth choice is missing, not done; guide objects take the guide colour and style and Lock Guides, #1534; Keyboard Shortcuts lists commands outside the menus, #1539; round corners next to curves and the Smooth tool's reach, #1512; Make Compound Path on a group, #1537; dialog slider rails, #1483; template layers stay in Preview in Outline view, #1486; Direct Selection takes the selected object's anchor where anchors coincide, #1508; Tabs panel stop drags, #1458; Split Into Grid dialog, #1462; Transform Objects and Reflect's angle, #1448 and #1460; Pathfinder panel on a group, #1450; value fields: readable selection, #1465 in part, and a focused field follows its value, #1457; scores unchanged; Transform dialogs have a live Preview and step with the arrow keys, #1412; transform tools, dialogs and Move act on direct-selected anchors, #1408; the bounding box hides during a corner drag, #1229; scores unchanged; dialogs focus their first field on every open, #1367, and a first field that starts greyed out once it is enabled, #1395; scores unchanged; Rectangular Grid and Polar Grid click dialogs take the skew, frame, compound path and Fill Grid options, #1377 in part, score unchanged; Live Corners: a Direct Selection click on a widget selects its corner, #1239; custom ruler origin, #1212; Artboard tool clicks fit the topmost editable object in one undo step (#1227); scores unchanged; Pathfinder single-result source names and SVG IDs retained, #1293; DXF control-point SPLINE closure read, #1299 follow-up; Document Setup: Edit Artboards closes the modal after applying valid settings; pointer-click regressions; scores and hours unchanged; Artboards: Escape exits editing; an active drag cancels first; shortcut-routing regression; scores and hours unchanged; Simplify preview/counts and valid rewritten-path selection (#1272); parity remains partial; Texture-effect drag redraws optimized (#1257); idle Windows interaction still unverified; scores unchanged; Curvature point display improved (#1236, in part); scores unchanged; Direct Selection: no-op anchor Align preserves Undo, Redo and saved state (#1180 follow-up); Eyedropper cursor distinguished from precise crosshair (#1269); scores unchanged; Eyedropper can read visible locked and outside-isolation sources (#1251); scores unchanged; Direct Selection: independent segment picks and Delete (#1278); scores unchanged; Adding paint to an unpainted zero-width stroke restores the 1 pt default (#1253); scores unchanged; macOS save sheets offer a Format menu, #866; Attributes fill-rule controls edit the compound when a member is selected, #1197; a marquee needs to touch a path, not just lie inside its fill, #1103; earlier: Live Corners round corners between curved sides, #1144) · **Target:** Adobe Illustrator 2026 (30.x)How VectorCraft's tools, handles, snapping and panels behave next to Illustrator's. A vector illustrator'strust is in the details: where a handle lands, what Shift and Alt do mid-drag, what a smart guide snaps to,@@ -53,7 +53,7 @@ tools, never checked side by side) isn't captured row by row.| Pen cursors (new path ×, continue /, close o, add +, delete −, convert ^) | partial | vector cursors exist; not every state verified || Each anchor snaps to Smart Guides and construction angles | done | `DrawSnap` || Curvature tool: click/drag points, double-click or Alt-click for a corner, temporary Direct Selection, point conversion | partial | circular point markers without direction handles or duplicate markers, Anchor Size and Hide Edges regression-tested (#1236, in part); curve geometry: each stretch of three points follows the circle through them (handles along its tangent, chord/(3·cos²(α/2)) long, shorter in a turn tighter than 30°), open ends curving in, the same rule for the rubber band, dragged, inserted and converted points (#1236, in part); neighbours of a point dragged on an existing path keep their tangents, and modifiers requested in #975 remain |-| Add/Delete/Anchor Point tools; Anchor Point tool drags segments to reshape | done | |+| Add/Delete/Anchor Point tools; Anchor Point tool drags segments to reshape | done | #2267: a click on a handle end retracts that handle and leaves the anchor a corner with the other one || Pencil: Fidelity, Keep selected, Alt to Smooth, edit selected paths, close by proximity | partial | Alt to Smooth is missing; with Keep selected (Pencil and Paintbrush, on by default) off, the path a stroke draws or continues is not selected afterwards; a filled Pencil path keeps a stroke of None (#1804, part of #1679) || Join tool scrubbing, Average, Join | done | Join merges the direct-selected anchors lying on one another along a path, as after Average, into one (#1533) || Average and Join in one step, with a corner or smooth choice for the joined anchor | missing | `path.join` and `path.average` are separate commands, and Join has no corner/smooth choice; [gap 1](gaps.md) |@@ -227,6 +227,7 @@ re-measure of the panels added since. Slider rails show on Medium Dark (#1808, #| Date | Change | Summary ||---|---|---|+| 2026-10-16 | minor | Anchor Point tool: a click on one handle end retracts that handle only; the anchor becomes a corner and keeps the other handle (#2267). Handle drags start past the same 2 px as anchor drags. Scores and hours unchanged. || 2026-10-16 | minor | Smart Guides: the dragged end of a straight segment snaps to the segment's extension at any angle, with the guide from its other end (#2120); scores and hours unchanged || 2026-10-14 | minor | Effect > Warp: style, orientation and percent controls; focused checks passed and original captures reviewed; scores and hours unchanged || 2026-10-14 | minor | G11: open-path anchor Delete leaves separate surviving runs; dedicated Remove Anchors remains connected. Keyboard and history regression coverage added; scores and hours unchanged. |