From bdb87ce7145a7b3d2a45b200776f22f4ce4fe6b6 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 5 Dec 2026 05:47:42 -0800 Subject: [PATCH] Live Corners: map removal successors in one pass over the subpaths Remove Anchor Points mapped each subpath's next anchor to the path as drawn with `LiveCorners::drawn_anchor`, which counted the anchors of every earlier subpath again for each one. `LiveCorners::drawn_anchors` maps the whole set while walking the subpaths once. The docs now say that Remove Anchor Points selects the next anchor of the uncut outline, which can be an anchor added on a side as well as a corner. --- crates/doc/src/corners.rs | 30 ++++++++++++++++++++++++++ crates/engine/src/cmd/draw2/anchors.rs | 2 +- docs/mcp.md | 2 +- docs/target-app-parity.md | 2 +- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/crates/doc/src/corners.rs b/crates/doc/src/corners.rs index f4bda4adb0..a4f4a683d6 100644 --- a/crates/doc/src/corners.rs +++ b/crates/doc/src/corners.rs @@ -224,6 +224,21 @@ impl<'a> LiveCorners<'a> { self.sources.get(si)?.iter().position(|s| *s == k).map(|drawn| (si, drawn)) } + /// [`LiveCorners::drawn_anchor`] of each of `anchors`, counting the subpaths' anchors once. + pub fn drawn_anchors(&self, anchors: &BTreeSet) -> BTreeSet { + let mut out = BTreeSet::new(); + let mut first = 0; + for (si, sp) in self.base.subpaths.iter().enumerate() { + let Some(sources) = self.sources.get(si) else { break }; + for &(_, ai) in anchors.range((si, 0)..(si + 1, 0)) { + let k = first + ai; + out.extend(sources.iter().position(|s| *s == k).map(|drawn| (si, drawn))); + } + first += sp.anchors.len(); + } + out + } + /// The radius and kind `corners` share (each `None` when they differ, or for no corners). /// Radius is what was set ([`LiveCorners::radius`]: document lengths, or a fraction in 0..1 /// when [`LiveCorners::radii_relative`]), not the fitted draw size ([`LiveCorners::drawn_radius`]). @@ -602,6 +617,21 @@ mod tests { assert_eq!((path, live), (star, None)); } + /// Mapping a set of outline anchors gives the same anchors as drawn as mapping each one. + #[test] + fn drawn_anchors_match_drawn_anchor_across_subpaths() { + let mut star = shapes::star(Point::new(100.0, 100.0), 50.0, 25.0, 5, 0.0); + star.subpaths.extend(shapes::star(Point::new(300.0, 100.0), 50.0, 25.0, 4, 0.0).subpaths); + let (mut path, mut live) = (star, None); + set_corners(&mut path, &mut live, &set(&[0, 2, 10, 13]), Some(5.0), None); + let c = LiveCorners::new(&path, live.as_deref()).unwrap(); + let refs: BTreeSet = (0..3).flat_map(|si| (0..12).map(move |ai| (si, ai))).collect(); + let one_by_one: BTreeSet = refs.iter().filter_map(|r| c.drawn_anchor(*r)).collect(); + assert_eq!(one_by_one.len(), 18, "ten and eight outline anchors"); + assert_eq!(c.drawn_anchors(&refs), one_by_one); + assert_eq!(c.drawn_anchors(&BTreeSet::from([(1, 3)])), BTreeSet::from([(1, c.drawn_anchor((1, 3)).unwrap().1)])); + } + /// A polygon's corners are cut in the document and survive a change of sides when shared. #[test] fn polygon_corners_follow_their_sides() { diff --git a/crates/engine/src/cmd/draw2/anchors.rs b/crates/engine/src/cmd/draw2/anchors.rs index 90092fd6ae..9d23053e2c 100644 --- a/crates/engine/src/cmd/draw2/anchors.rs +++ b/crates/engine/src/cmd/draw2/anchors.rs @@ -311,7 +311,7 @@ fn remove_live_corner_anchors(d: &mut Document, id: NodeId, anchors: &[(usize, u })?; let next = following_anchors(&shape, &outline); Some(match vectorcraft_doc::LiveCorners::new(path, live.as_deref()) { - Some(lc) => next.into_iter().filter_map(|r| lc.drawn_anchor(r)).collect(), + Some(lc) => lc.drawn_anchors(&next), None => next, }) } diff --git a/docs/mcp.md b/docs/mcp.md index e670ad92d6..d22033c93a 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -9515,7 +9515,7 @@ and kinds; a relative radius keeps the length it is drawn at, up to the corner's the selected anchors follow their corners, the selected segments stay on their sides with only their own ends selected, and a selected segment that the new anchor splits stays selected as its two halves with the new anchor. Removing anchors clears the path's selected anchors and segments, and `path.removeAnchors` then selects the first anchor of the next -corner along, or the anchor before the removed one at an open path's end. An anchor added on a corner's +anchor of the uncut outline along (a corner, or an anchor added on a side), or the anchor before the removed one at an open path's end. An anchor added on a corner's arc, or on a path the fallbacks above apply to, makes the shape a plain path, and when the path had rounded corners `path.insertAnchor` answers with a `warning`, which the status bar shows. `path.setHandle` with `symmetric: true` also places the anchor's other handle opposite the moved one at the same diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index f9b5d1d7d7..596e866a10 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -868,7 +868,7 @@ since 2026-10-01. - **Shift-click on corner widgets (#5188):** with Direct Selection, when every corner of every selected path is selected (the paths selected whole), a Shift-click on a corner widget picks that corner alone, so the next drag rounds just it. When another selected path has only some corners picked, a Shift-click on a widget of a path selected whole deselects that corner and keeps the other picks. The other corners' widgets then show as not picked; a Shift-click on another corner's anchor or widget adds that corner, and a Shift-click on a picked widget deselects its corner. Corner widgets are chosen by clicking one and Shift-clicking the others ([a tutorial on rounded corners](https://logosbynick.com/?p=15787)). Test: `corners::tests::a_shift_click_on_a_widget_of_a_whole_path_picks_its_corner`. - **Picking corner widgets (#1232):** with Direct Selection, every corner's widget shows while some corners are picked: a picked corner's widget has a dot at its center and the others are hollow. A click on a widget that is not picked picks its corner alone, a Shift-click adds or removes a corner across selected paths, and a double-click on a picked widget opens Corners for the picked corners of its path ([Live Corners help page, archived](https://web.archive.org/web/2019/https://helpx.adobe.com/illustrator/using/reshape-with-live-corners.html)). As VectorCraft's own rules, a plain click on a picked widget keeps the picks (while every corner of every selected path is picked, it picks that corner alone, and a double-click then opens Corners for that corner), a drag or Alt-click on a widget that is not picked edits its corner together with the picked ones, and over a widget that is not picked, a selected anchor's handle end or a nearer anchor takes the press. Tests: `corners::tests::a_press_on_a_widget_not_picked_edits_it_with_the_picked_corners`, `corners::tests::widgets_are_picked_across_paths`, `corners::tests::a_handle_end_over_a_widget_not_picked_takes_the_press`, `corners::tests::a_nearer_anchor_over_a_widget_not_picked_takes_the_press`, `corners::tests::a_shift_click_toggles_a_rounded_corner_whole`, `corners::tests::a_path_with_hidden_widgets_keeps_its_picks`, `tests::corner_widgets_pick_corners_across_paths_through_the_session`. - **Anchor edits keep Live Corners (#10545):** moving an anchor of a path with rounded corners (Direct Selection drag, arrow keys, `path.moveAnchor`) moves its uncut corner by the drag delta and recuts it at its radius. A grabbed arc end can finish away from a snap target. A live rectangle or polygon becomes a path with live corners. When the anchor layout changes, the path's whole anchor selection is remapped and its segment selection is cleared. A corner that a move straightens keeps its radius and rounds again when a later move bends it. An anchor edit makes the shape a plain path when no anchor stores a radius above 0 (a straightened corner's stored radius keeps the path live), a live rectangle is sheared or unevenly scaled, an arrow-key nudge bends selected curved segments or holds their anchors, or direct-selected anchors receive a transform other than a move. A nudge that changes nothing, including one that the pixel-grid snap of pixel-aligned paths takes back (with objects selected whole too), records no undo step and leaves Live Corners as they are: a live rectangle stays a live rectangle. These are VectorCraft's own rules. Tests: `tests::livecorners::moving_an_anchor_keeps_the_corners_live`, `tests::livecorners::dragging_selected_anchors_keeps_the_corners_live`, `tests::livecorners::moving_an_anchor_of_a_distorted_rectangle_edits_the_drawn_path`, `tests::livecorners::a_recut_remaps_the_whole_anchor_selection`, `tests::livecorners::a_recut_clears_segments_even_when_selected_anchor_indices_stay_the_same`, `tests::livecorners::an_unchanged_corner_layout_keeps_the_selection`, `corners::tests::a_straightened_corner_rounds_again_when_it_bends_back`. -- **Adding and removing anchors keeps Live Corners (#10545):** the Pen, Add Anchor Point and Delete Anchor Point tools, Object › Path › Remove Anchor Points and the Delete key with Delete Removes Anchor Points and Keeps Paths Joined on (`path.insertAnchor`, `path.removeAnchor`, `path.removeAnchors`) edit the uncut outline of a path with rounded corners and cut its corners again at their radii and kinds, so the corner widgets stay. An anchor added on a side has no radius; removing either end of a corner's arc removes that corner; a relative radius keeps its drawn length, up to the corner's new largest radius. When an anchor is added, selected anchors follow their corners and selected segments their sides, with only the segments' own ends selected; removing anchors clears the path's selected anchors and segments, and Remove Anchor Points then selects the first anchor of the next corner, or the anchor before the removed one at an open path's end. An anchor added on a corner's arc makes the path plain, and the status bar says the corners were expanded. These are VectorCraft's own rules. Tests: `tests::livecorners::adding_and_deleting_an_anchor_on_a_side_keeps_the_corners_live`, `tests::livecorners::adding_an_anchor_keeps_the_selected_segments_on_their_sides`, `tests::livecorners::adding_an_anchor_selects_only_the_ends_of_the_selected_segments`, `tests::livecorners::adding_an_anchor_on_a_corners_curve_expands_the_corners_and_warns`, `tests::livecorners::deleting_an_anchor_of_a_cut_corner_removes_the_corner_and_keeps_the_rest_live`, `tests::livecorners::remove_anchor_points_on_a_cut_corner_selects_the_next_corner`, `tests::livecorners::an_added_anchor_keeps_a_relative_radius_at_its_length`. +- **Adding and removing anchors keeps Live Corners (#10545):** the Pen, Add Anchor Point and Delete Anchor Point tools, Object › Path › Remove Anchor Points and the Delete key with Delete Removes Anchor Points and Keeps Paths Joined on (`path.insertAnchor`, `path.removeAnchor`, `path.removeAnchors`) edit the uncut outline of a path with rounded corners and cut its corners again at their radii and kinds, so the corner widgets stay. An anchor added on a side has no radius; removing either end of a corner's arc removes that corner; a relative radius keeps its drawn length, up to the corner's new largest radius. When an anchor is added, selected anchors follow their corners and selected segments their sides, with only the segments' own ends selected; removing anchors clears the path's selected anchors and segments, and Remove Anchor Points then selects the first anchor of the next anchor of the uncut outline (a corner, or an anchor added on a side), or the anchor before the removed one at an open path's end. An anchor added on a corner's arc makes the path plain, and the status bar says the corners were expanded. These are VectorCraft's own rules. Tests: `tests::livecorners::adding_and_deleting_an_anchor_on_a_side_keeps_the_corners_live`, `tests::livecorners::adding_an_anchor_keeps_the_selected_segments_on_their_sides`, `tests::livecorners::adding_an_anchor_selects_only_the_ends_of_the_selected_segments`, `tests::livecorners::adding_an_anchor_on_a_corners_curve_expands_the_corners_and_warns`, `tests::livecorners::deleting_an_anchor_of_a_cut_corner_removes_the_corner_and_keeps_the_rest_live`, `tests::livecorners::remove_anchor_points_on_a_cut_corner_selects_the_next_corner`, `tests::livecorners::an_added_anchor_keeps_a_relative_radius_at_its_length`. - **TIFF in screen and asset export:** both format menus expose the existing TIFF encoder and Format Settings. Headless UI regressions choose TIFF and check scaled dimensions, artboard selection, filenames, encoding options, saved settings and collected-asset output. Public reference: [Export for Screens](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/export-for-screens.html), updated 2026-09-28, lists TIFF for both artboards and assets. Adobe staff [confirmed support in 30.2.1](https://illustrator.uservoice.com/forums/333657-illustrator-desktop-feature-requests/suggestions/49081034-add-tiff-format-into-export-for-screens-assets-d) on 2026-02-19; the older 2025 Collect assets guide omits TIFF. - **Lossy WebP with a Quality setting:** WebP Options has a Compression menu (Lossless, Lossy) and a Quality slider from 0 to 100 that is enabled for Lossy. Lossy writes a `VP8 ` WebP file, with an `ALPH` chunk that keeps the alpha exactly when some pixels are not opaque. `document.export`, `document.serialize` and Export for Screens take `lossless: false` with `quality` (default 90, VectorCraft's own value), in a format row or in `settings.webp`; Format Settings for WebP keeps both. Lossless stays the default, and a quality above 100 or one that is not a whole number is refused. Public reference: [export file format options](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/export-file-format-options-in-illustrator.html) describes Lossless and Lossy WebP and a Quality setting for Lossy (`webp_is_lossless_by_default_and_lossy_when_asked`, `lossy_webp_keeps_translucent_pixels`, `webp_quality_out_of_its_range_is_refused` in `crates/engine/src/cmd/fileio/tests_text.rs`, `webp_options_choose_lossless_or_lossy_at_a_quality`). - **Export for Screens of the selected artboards:** while the Artboard tool is in use, File › Export › Export for Screens… (`file.exportForScreens`) opens with the artboards the tool has selected checked on its Artboards tab, and Export Artboard writes only those. Shift-clicks on the canvas, or Shift- or Ctrl/Cmd-clicks on the Artboards panel's rows, select several. The other fields show the settings the document last exported with. With another tool in use, the dialog takes its artboard choice from those settings too. Public reference: [Export selected artboards](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/organize-manage-artboards/export-artboards.html).