From 87b5aef6394417e788092b49ba1cd54a7001f46d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:13:51 -0800 Subject: [PATCH] Scripts: point removals keep the selection, defaults and batching right Follow-up to #9288. - Removing the last anchor of a closed path with its closing segment selected also deselects the first anchor, the segment's other end. - Removing a point puts back new art's paint, so a default stroke width a script set still applies to the next path it draws. - A removal that leaves the direct selection as it was waits with the other point changes, unless every remaining anchor is now selected, the selection refers to points that are gone, or the path is in an Objects on Path group. - Reading the points of a path first writes the waiting point changes of another path in the same Objects on Path group. - Writing a path in an Objects on Path group checks the other tracked paths in the outermost such group, so their PathPoint handles go stale when the group moves them, even after an undo. Docs: docs/mcp.md, docs/target-app-parity.md. --- crates/engine/src/script/dom/paths.rs | 119 +++++++++-- crates/engine/src/tests/script_dom_paths.rs | 215 ++++++++++++++++++++ docs/mcp.md | 10 +- docs/target-app-parity.md | 2 +- 4 files changed, 321 insertions(+), 25 deletions(-) diff --git a/crates/engine/src/script/dom/paths.rs b/crates/engine/src/script/dom/paths.rs index 27b449a5b9..e4f6bb203e 100644 --- a/crates/engine/src/script/dom/paths.rs +++ b/crates/engine/src/script/dom/paths.rs @@ -1225,7 +1225,26 @@ fn path_resize(h: &super::Host, a: &[Data]) -> Answer { fn points_path(h: &super::Host, a: &[Data]) -> std::result::Result { let Some(handle) = handle_of(arg(a, 0), "PathPoints") else { return Err(HostError::Type("this is not a PathPoints".into())) }; let [run, uid, high, low] = handle.as_slice() else { return Err(HostError::Type("this is not a PathPoints".into())) }; - path_at(h, *run, *uid, *high, *low) + let item = path_at(h, *run, *uid, *high, *low)?; + flush_other(h, item)?; + Ok(item) +} + +/// Writes the waiting point changes of another path in the same Objects on Path group as `item`. +fn flush_other(h: &super::Host, item: Item) -> std::result::Result<(), HostError> { + let waiting = h.dom.pending.borrow().as_ref().map(|(w, _)| *w); + let other = waiting.is_some_and(|w| { + w.doc.uid == item.doc.uid + && w.id != item.id + && with_doc(h, item.doc, |_, st| { + let d = &st.doc; + let read = d.ancestry(item.id).unwrap_or_default(); + d.ancestry(w.id).is_some_and(|a| { + a.iter().any(|g| read.contains(g) && d.node(*g).is_some_and(vectorcraft_doc::objects_on_path::is_objects_on_path)) + }) + }) + }); + if other { flush(h) } else { Ok(()) } } /// `typename` of the points of a path that is still in its document. @@ -1322,7 +1341,8 @@ fn see_points(h: &super::Host, key: (u64, u64), own: impl FnOnce() -> bool) { /// the object model is changing ([`super::State`]), or that object itself, take the change as the /// object model's own, and their points stay valid. A document that is the one the run last looked /// at is skipped, as are its paths. While the object model writes one path's points -/// ([`super::State`]'s `one_path`), only that path is looked at in its document. +/// ([`super::State`]'s `one_path`), only that path and tracked paths in its outermost enclosing +/// Objects on Path group are looked at in its document. pub(super) fn see_all_points(h: &super::Host) { let keys: Vec<(u64, u64)> = { let seen = h.dom.point_nodes.borrow(); @@ -1335,9 +1355,24 @@ pub(super) fn see_all_points(h: &super::Host) { let mut keys = Vec::new(); // The documents that changed since the last look, kept as they are now. for (uid, paths) in seen.iter().filter(|(_, paths)| !paths.is_empty()) { + // Editing a path in an Objects on Path group can move other paths in the group. + let mut moved = Vec::new(); match s.documents().iter().find(|d| d.uid == *uid) { Some(st) if docs.get(uid).is_some_and(|d| Arc::ptr_eq(d, &st.doc)) => continue, Some(st) => { + if let Some(item) = one.filter(|i| i.doc.uid == *uid) { + let d = &st.doc; + let group = d.ancestry(item.id).and_then(|a| { + a.into_iter().filter_map(|id| d.node(id)).find(|g| vectorcraft_doc::objects_on_path::is_objects_on_path(g)) + }); + if let Some(g) = group { + g.walk(&mut |n: &crate::doc::Node| { + if n.id != item.id && paths.contains_key(&n.id.0) { + moved.push((*uid, n.id.0)); + } + }); + } + } docs.insert(*uid, st.doc.clone()); } None => { @@ -1345,7 +1380,10 @@ pub(super) fn see_all_points(h: &super::Host) { } } match one { - Some(item) if item.doc.uid == *uid => keys.extend(paths.contains_key(&item.id.0).then_some((*uid, item.id.0))), + Some(item) if item.doc.uid == *uid => { + keys.extend(paths.contains_key(&item.id.0).then_some((*uid, item.id.0))); + keys.append(&mut moved); + } _ => keys.extend(paths.keys().map(|id| (*uid, *id))), } } @@ -1432,6 +1470,7 @@ pub(super) fn this_point(h: &super::Host, a: &[Data]) -> std::result::Result<(It let Some(handle) = handle_of(arg(a, 0), "PathPoint") else { return Err(HostError::Type("this is not a PathPoint".into())) }; let [run, uid, high, low, i, cuts] = handle.as_slice() else { return Err(HostError::Type("this is not a PathPoint".into())) }; let item = path_at(h, *run, *uid, *high, *low)?; + flush_other(h, item)?; if whole(*cuts) != Some(point_cuts(h, item)) { return Err(HostError::Error(STALE_POINT.into())); } @@ -1664,38 +1703,69 @@ fn pt_remove(h: &super::Host, a: &[Data]) -> Answer { let sel = &st.selection; (sel.anchors.contains_key(&item.id) || sel.segments.contains_key(&item.id)).then(|| sel.clone()) }; + // Writing the points can prune the selection, and selecting loads the selected paths' paint + // into new art, so new art's paint, the defaults a script set included, is put back. + keeping_paint(h, || remove_point(h, item, i, selected))?; + cut_points(h, item); + Ok(Data::Undefined) +} + +/// Removes point `i` of the path of `item` for [`pt_remove`], and renumbers `selected`, the +/// direct selection of the path's points before the removal. +fn remove_point(h: &super::Host, item: Item, i: usize, selected: Option) -> std::result::Result<(), HostError> { let removed = edit_points(h, item, |subs| { let (s, j) = locate(subs, i)?; let sp = subs.get_mut(s)?; - // The segment that closes a closed subpath ends at its first anchor. - let closing = (sp.closed && j == 0).then(|| sp.anchors.len() - 1); + // The segment that closes a closed subpath runs from its last anchor to its first. + let last = sp.closed.then(|| sp.anchors.len() - 1); sp.anchors.remove(j); let gone = sp.anchors.is_empty(); if gone { subs.remove(s); } - Some((s, j, gone, closing)) + Some((s, j, gone, last)) })?; - if let (Some((s, j, gone, closing)), Some(mut sel)) = (removed, selected) { - // The points are written first, and the selection is then set with selection commands, - // which the journal records with the edit. - flush(h)?; - renumber_selected(&mut sel, item.id, s, j, gone, closing); - on_doc(h, item.doc.uid, false, |h| { - let doc = h.session.borrow().active().map(|st| st.doc.clone()).ok_or_else(|| HostError::Error(super::STALE_DOCUMENT.into()))?; - super::restore_selection(h, &doc, &sel) - })?; + if let (Some((s, j, gone, last)), Some(before)) = (removed, selected) { + let mut sel = before.clone(); + renumber_selected(&mut sel, item.id, s, j, gone, last); + // A selection the removal leaves as it was waits with the points, so that removals in a + // row are written together, unless its anchors are now all of the path's, which selects + // the path whole, or the path is in an Objects on Path group, which places it again. + let wait = sel == before && { + let valid = read_points(h, item, |subs| { + sel.anchors.get(&item.id).is_none_or(|a| a.iter().all(|(p, k)| subs.get(*p).is_some_and(|sp| *k < sp.anchors.len()))) + && sel.segments.get(&item.id).is_none_or(|a| a.iter().all(|(p, k)| subs.get(*p).is_some_and(|sp| sp.has_segment(*k, true)))) + })?; + let total = points_of(h, item)?; + let all = sel.anchors.get(&item.id).is_some_and(|a| a.len() >= total) && !sel.segments.contains_key(&item.id); + let on_path = with_doc(h, item.doc, |_, st| { + let d = &st.doc; + d.ancestry(item.id).is_some_and(|a| a.iter().any(|g| d.node(*g).is_some_and(vectorcraft_doc::objects_on_path::is_objects_on_path))) + }); + valid && !all && !on_path + }; + if !wait { + // The points are written first, and the selection is then set with selection + // commands, which the journal records with the edit. + flush(h)?; + on_doc(h, item.doc.uid, false, |h| { + let doc = h.session.borrow().active().map(|st| st.doc.clone()).ok_or_else(|| HostError::Error(super::STALE_DOCUMENT.into()))?; + super::restore_selection(h, &doc, &sel) + })?; + } } - cut_points(h, item); - Ok(Data::Undefined) + Ok(()) } /// Updates the direct selection `sel` of the path `id` after the anchor `j` of its subpath `s` was /// removed, and the subpath with it when `gone`: the anchor, the segments it ended and their other /// ends leave the selection, unless a segment still selected ends there, and the anchors, segments -/// and subpaths after it keep the points they selected. `closing` is the segment that closed the -/// subpath at the removed anchor, when it did. -fn renumber_selected(sel: &mut crate::doc::Selection, id: NodeId, s: usize, j: usize, gone: bool, closing: Option) { +/// and subpaths after it keep the points they selected. `last` is the index of the subpath's last +/// anchor before the removal when the subpath is closed: its closing segment runs from that anchor +/// to anchor 0. +fn renumber_selected(sel: &mut crate::doc::Selection, id: NodeId, s: usize, j: usize, gone: bool, last: Option) { + // The closing segment ends at the removed anchor when the removed anchor is the first one. + let closing = last.filter(|_| j == 0); // An anchor (or a segment, by its first anchor) after the removed one moves down one place. let shift = |(p, k): (usize, usize), segment: bool| -> Option<(usize, usize)> { match p.cmp(&s) { @@ -1713,7 +1783,14 @@ fn renumber_selected(sel: &mut crate::doc::Selection, id: NodeId, s: usize, j: u let cut: Vec<(usize, usize)> = segments.iter().copied().filter(|g| shift(*g, true).is_none() && g.0 == s && !gone).collect(); for (p, k) in cut { // Segment k runs from anchor k to anchor k + 1; one of the two is the removed one. - let other = if k == j { k + 1 } else { k }; + // The closing segment of a closed subpath ends at anchor 0. + let other = if k != j { + k + } else if last == Some(k) { + 0 + } else { + k + 1 + }; // The closing segment's other end is its first anchor, the old last one. let other = if closing == Some(k) { k } else { other }; ends.extend(shift((p, other), false)); diff --git a/crates/engine/src/tests/script_dom_paths.rs b/crates/engine/src/tests/script_dom_paths.rs index d33246aba7..87f1c4f9ab 100644 --- a/crates/engine/src/tests/script_dom_paths.rs +++ b/crates/engine/src/tests/script_dom_paths.rs @@ -809,6 +809,221 @@ fn removing_a_point_keeps_the_direct_selection_on_the_same_anchors() { assert!(!s.active().unwrap().selection.objects.contains(&a)); } +/// Removing the last anchor of a closed path with only its closing segment selected takes the +/// segment's other end, the first anchor, out of the selection too. +#[test] +fn removing_the_last_point_deselects_the_closing_segment_and_its_first_anchor() { + let (mut s, a, _) = doc(); + s.execute("select.segments", &json!({"id": a.0, "segments": [[0, 3]], "mode": "set"})).unwrap(); + log(&mut s, "app.activeDocument.pathItems[0].pathPoints[3].remove();"); + assert_eq!(selected_anchors(&s, a), None, "the first anchor is not selected"); + assert!(!s.active().unwrap().selection.objects.contains(&a)); +} + +/// Removing a point that renumbers the selected anchors keeps the new-art stroke width a script +/// set, so the next path it draws gets it. +#[test] +fn removing_a_point_keeps_the_default_stroke_width_a_script_set() { + let (mut s, a, _) = doc(); + s.execute("select.anchorsMany", &json!({"items": [{"id": a.0, "anchors": [[0, 2]]}], "mode": "set"})).unwrap(); + let out = log( + &mut s, + "var d = app.activeDocument; d.defaultStrokeWidth = 7; d.pathItems[0].pathPoints[0].remove();\ + vc.log(d.pathItems.rectangle(10, 10, 5, 5).strokeWidth);", + ); + assert_eq!(selected_anchors(&s, a), Some(vec![(0, 1)])); + assert_eq!(out, [json!(7)]); +} + +/// Removals that leave the direct selection as it was are written together, with one +/// `path.setAnchors`. +#[test] +fn removals_that_keep_the_selection_are_written_together() { + let (mut s, a, _) = doc(); + s.execute("select.anchorsMany", &json!({"items": [{"id": a.0, "anchors": [[0, 0]]}], "mode": "set"})).unwrap(); + let start = s.journal.len(); + log(&mut s, "var q = app.activeDocument.pathItems[0].pathPoints; q[3].remove(); q[2].remove();"); + let writes = s.journal.iter().skip(start).filter(|(id, _)| id == "path.setAnchors").count(); + assert_eq!(writes, 1); + assert_eq!(node(&s, a).path_data().unwrap().subpaths[0].anchors.len(), 2); + assert_eq!(selected_anchors(&s, a), Some(vec![(0, 0)])); +} + +#[test] +fn removing_a_replacement_point_clears_selection_of_a_missing_subpath() { + for segments in [false, true] { + let (mut s, a, _) = doc(); + let anchors: Vec = (0..3).map(|x| json!({"x": x, "y": 0, "in": [x, 0], "out": [x, 0], "smooth": false})).collect(); + s.execute("path.setAnchors", &json!({"id": a.0, "subpaths": [{"anchors": anchors, "closed": false}, {"anchors": anchors, "closed": false}]})) + .unwrap(); + if segments { + s.execute("select.segments", &json!({"id": a.0, "segments": [[1, 0]], "mode": "set"})).unwrap(); + } else { + s.execute("select.anchorsMany", &json!({"items": [{"id": a.0, "anchors": [[1, 0]]}], "mode": "set"})).unwrap(); + } + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0]; p.setEntirePath([[0, 0], [10, 0], [20, 0], [30, 0]]);\ + p.pathPoints[3].remove(); vc.log(p.selected); vc.log(p.selectedPathPoints.length);", + ); + assert_eq!(out, [json!(false), json!(0)], "segments: {segments}"); + let path = node(&s, a); + let subs = &path.path_data().unwrap().subpaths; + assert_eq!(subs.len(), 1); + assert_eq!(subs[0].anchors.len(), 3); + assert_eq!(selected_anchors(&s, a), None); + let sel = &s.active().unwrap().selection; + assert!(!sel.segments.contains_key(&a)); + assert!(!sel.objects.contains(&a)); + } +} + +#[test] +fn reading_an_unrelated_path_keeps_point_edits_written_together() { + let (mut s, a, b) = doc(); + let before = node(&s, b); + let start = s.journal.len(); + let out = log( + &mut s, + "var P = app.activeDocument.pathItems, p = P[0].pathPoints, q = P[1].pathPoints;\ + p[0].anchor = [20, 30]; vc.log(q.length); vc.log(q[0].anchor); p[1].anchor = [50, 30];", + ); + let writes = s.journal.iter().skip(start).filter(|(id, _)| id == "path.setAnchors").count(); + assert_eq!(writes, 1); + assert_eq!(out, [json!(4), json!([100, 200])]); + assert_eq!(node(&s, b), before); + let edited = node(&s, a); + let anchors = &edited.path_data().unwrap().subpaths[0].anchors; + assert_eq!(anchors[0].p, vectorcraft_geom::Point::new(20.0, 270.0)); + assert_eq!(anchors[1].p, vectorcraft_geom::Point::new(50.0, 270.0)); +} + +/// Removing the one point that was not direct-selected leaves every point selected, which +/// selects the path whole. +#[test] +fn removing_the_only_unselected_point_selects_the_path_whole() { + let (mut s, a, _) = doc(); + s.execute("select.anchorsMany", &json!({"items": [{"id": a.0, "anchors": [[0, 0], [0, 1], [0, 2]]}], "mode": "set"})).unwrap(); + log(&mut s, "app.activeDocument.pathItems[0].pathPoints[3].remove();"); + assert_eq!(selected_anchors(&s, a), None); + assert!(s.active().unwrap().selection.objects.contains(&a)); +} + +/// Removing a point of a direct-selected member of an Objects on Path group writes it at once, so +/// its points read where the group places it. +#[test] +fn removing_a_point_of_a_selected_member_reads_where_the_group_places_it() { + let (mut s, b) = doc_on_path(); + s.execute("select.anchorsMany", &json!({"items": [{"id": b.0, "anchors": [[0, 0]]}], "mode": "set"})).unwrap(); + let out = log( + &mut s, + "var P = app.activeDocument.pathItems, m = P.getByName('m');\ + m.pathPoints[3].remove(); m.pathPoints[2].remove(); vc.log(m.pathPoints[0].anchor);\ + P.rectangle(0, 0, 1, 1); vc.log(P.getByName('m').pathPoints[0].anchor);", + ); + assert_eq!(out[0], out[1], "the member read where it is after the run"); +} + +/// [`doc`] with path `drive`, the path of an Objects on Path group that holds `b`, named `m`. +fn doc_on_path() -> (Session, NodeId) { + let (mut s, _, b) = doc(); + let c = rect(&mut s, 200.0, 50.0, 100.0, 100.0); + log(&mut s, "var p = app.activeDocument.pathItems; p[0].name = 'drive'; p[2].name = 'm';"); + s.execute("select.set", &json!({"ids": [b.0]})).unwrap(); + s.execute("object.objectsOnPath.attach", &json!({"path": c.0, "ids": [b.0]})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + (s, b) +} + +/// Reading the points of a path writes the waiting point changes of another path first, so a +/// member of an Objects on Path group reads where the group's edited path moved it. +#[test] +fn reading_a_member_point_after_editing_its_group_path_reads_where_it_moved() { + let (mut s, _) = doc_on_path(); + let out = log( + &mut s, + "var P = app.activeDocument.pathItems, g = P.getByName('drive'), m = P.getByName('m');\ + var x = m.pathPoints[0].anchor[0];\ + for (var i = 0; i < g.pathPoints.length; i++) { var q = g.pathPoints[i]; q.anchor = [q.anchor[0] + 50, q.anchor[1]]; }\ + vc.log(m.pathPoints[0].anchor[0] - x);\ + P.rectangle(0, 0, 1, 1); vc.log(P.getByName('m').pathPoints[0].anchor[0] - x);", + ); + assert_ne!(out[1], json!(0), "the member moved"); + assert_eq!(out[0], out[1], "the member read where it is after the run"); +} + +/// A member point read before the group's path is edited is stale afterwards, as the engine moved +/// the member, even when an undo puts the member back. +#[test] +fn a_member_point_read_before_its_group_path_changes_is_stale() { + let (mut s, _) = doc_on_path(); + let e = failure( + &mut s, + "var P = app.activeDocument.pathItems, g = P.getByName('drive'), m = P.getByName('m');\ + var mp = m.pathPoints[0]; mp.anchor;\ + var q = g.pathPoints[0]; q.anchor = [q.anchor[0] + 50, q.anchor[1]]; app.undo();\ + mp.anchor;", + ); + assert!(e.contains("Stale path point"), "{e}"); +} + +#[test] +fn a_point_in_a_nested_member_is_stale_after_another_path_changes_and_undoes() { + let (mut s, a, b) = doc(); + log(&mut s, "var P = app.activeDocument.pathItems; P[0].name = 'edit'; P[1].name = 'm';"); + s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap(); + s.execute("object.group", &json!({})).unwrap(); + let group = s.active().unwrap().doc.parent_of(a).unwrap(); + let drive = rect(&mut s, 200.0, 50.0, 100.0, 100.0); + s.execute("object.objectsOnPath.attach", &json!({"path": drive.0, "ids": [group.0]})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + let before = art(&s); + let e = failure( + &mut s, + "var P = app.activeDocument.pathItems, p = P.getByName('edit'), m = P.getByName('m');\ + var mp = m.pathPoints[0]; mp.anchor;\ + var q = p.pathPoints[0]; q.anchor = [q.anchor[0] - 50, q.anchor[1]]; app.undo();\ + mp.anchor;", + ); + assert!(e.contains("Stale path point"), "{e}"); + assert_eq!(art(&s), before); +} + +#[test] +fn a_point_outside_an_inner_objects_on_path_group_is_stale_after_its_path_changes_and_undoes() { + let (mut s, a, b) = doc(); + log(&mut s, "app.activeDocument.pathItems[0].name = 'drive';"); + s.execute("object.objectsOnPath.attach", &json!({"path": a.0, "ids": [b.0]})).unwrap(); + let inner = s.active().unwrap().doc.parent_of(a).unwrap(); + let sibling = rect(&mut s, 100.0, 200.0, 50.0, 50.0); + s.execute("object.setProps", &json!({"ids": [sibling.0], "name": "m"})).unwrap(); + s.execute("select.set", &json!({"ids": [inner.0, sibling.0]})).unwrap(); + s.execute("object.group", &json!({})).unwrap(); + let group = s.active().unwrap().doc.parent_of(inner).unwrap(); + let outer_drive = rect(&mut s, 200.0, 50.0, 100.0, 100.0); + s.execute("object.objectsOnPath.attach", &json!({"path": outer_drive.0, "ids": [group.0]})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + let before = art(&s); + let out = log( + &mut s, + "var P = app.activeDocument.pathItems, p = P.getByName('drive'), m = P.getByName('m');\ + vc.log(m.pathPoints[0].anchor);\ + var q = p.pathPoints[0]; q.anchor = [q.anchor[0] - 50, q.anchor[1]];\ + vc.log(m.pathPoints[0].anchor); app.undo();", + ); + assert_ne!(out[0], out[1], "the sibling outside the inner group moved"); + assert_eq!(art(&s), before); + let e = failure( + &mut s, + "var P = app.activeDocument.pathItems, p = P.getByName('drive'), m = P.getByName('m');\ + var mp = m.pathPoints[0]; mp.anchor;\ + var q = p.pathPoints[0]; q.anchor = [q.anchor[0] - 50, q.anchor[1]]; app.undo();\ + mp.anchor;", + ); + assert!(e.contains("Stale path point"), "{e}"); + assert_eq!(art(&s), before); +} + /// [`doc`] with pattern `Dots` and spot swatch `Ink`, and path `a` with no fill or stroke. fn doc_with_paints() -> (Session, NodeId) { let (mut s, a, _) = doc(); diff --git a/docs/mcp.md b/docs/mcp.md index 7ed0eebae6..12696f04f0 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3116,8 +3116,9 @@ through `$`: stroke options through `stroke.set`, the fill rule through `path.setFillRule`, overprint through `object.setOverprint` and the transforms through `object.move`, `object.rotate` and `object.scale`. Changes to the points of a path (`closed`, `setEntirePath`, `pathPoints` and each `PathPoint`) are written together with one - `path.setAnchors` before the script uses any other member or command, or the points of another path, and when the - script ends; a path aligned to the pixel grid, or in an object that is, is written at each change, so its points + `path.setAnchors` before the script uses any other member or command, edits the points of another path, or reads + the points of another path in the same Objects on Path group, and when the script ends; + a path aligned to the pixel grid, or in an object that is, is written at each change, so its points read as the grid snaps them. `pathPoints` (https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/) has `length`, `[i]`, `index(i)`, `add()` and @@ -3142,7 +3143,10 @@ through `$`: a point of its path (`remove()`, `removeAll()`) or replaced its points (`setEntirePath`), or before anything other than the object model changed the path's points (a command run with `vc.run`, such as `path.setAnchors`, `object.move` or `edit.undo`); points stay valid through the object model's other changes to the path or to an - object that holds it, such as `translate()`. Every point of a path selected as a whole is a selected anchor point, + object that holds it, such as `translate()`. An exception applies when editing another path in an Objects on + Path group moves a path inside that group. Its existing `PathPoint` handles throw `Stale path point`. + Read those points again from `pathPoints`. Reading a path's points first writes any waiting point changes of + another path in the same Objects on Path group. Every point of a path selected as a whole is a selected anchor point, and the endpoints of selected segments are not; a path in a selected group or compound path is selected as a whole. Direction handles are not selected on their own, so assigning `LEFTDIRECTION`, `RIGHTDIRECTION` or `LEFTRIGHTPOINT` to `selected` throws an error that says it is not available yet, and so does assigning `NOSELECTION` to a point of a diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index f2d93a4568..3d7064e18b 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1120,7 +1120,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Synthetic input validates complete gestures before queue mutation: at most 256 drag steps, 16 clicks and 1,024 pending events; up to 64 control requests per frame, with later requests retained for the next frame (#1709). - The control server writes each reply through a 64 KiB buffer. On Windows 11 it sends the 17 MB `document.inspect` reply of a document with 50,000 objects on one layer to a client over loopback in 0.09 s instead of 34 s. - Scripts: File › Scripts › Other Script… and `script.run` run a JavaScript file against the open documents as one transaction with one undo step for each changed document. A failed or stopped run puts every document back. `crates/engine/src/tests/script_run.rs`. - - Scripts: `Document.pathItems` lists the paths and makes rectangles, rounded rectangles, ellipses, polygons, stars and empty paths with the defaults the help page https://ai-scripting.docsforadobe.dev/jsobjref/PathItems/ gives; each path's points, closed state, fill rule, area, length, guide state, selected points, fill and stroke colors, stroke options and transforms read and change as https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/, https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/ and https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/ describe them, and `RGBColor`, `CMYKColor`, `GrayColor`, `LabColor` and `NoColor` make colors (`docs/mcp.md`). The transforms move gradients with the art: `changeFillGradients` false throws an error, as do `changeFillPatterns` and `changeStrokePattern` given as different values, and `transform` is not there yet (`docs/mcp.md` lists these limits). Gradient stops are not there yet. `crates/engine/src/tests/script_dom_paths.rs`. + - Scripts: `Document.pathItems` lists the paths and makes rectangles, rounded rectangles, ellipses, polygons, stars and empty paths with the defaults the help page https://ai-scripting.docsforadobe.dev/jsobjref/PathItems/ gives; each path's points, closed state, fill rule, area, length, guide state, selected points, fill and stroke colors, stroke options and transforms read and change as https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/, https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/ and https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/ describe them, and `RGBColor`, `CMYKColor`, `GrayColor`, `LabColor` and `NoColor` make colors (`docs/mcp.md`). The transforms move gradients with the art: `changeFillGradients` false throws an error, as do `changeFillPatterns` and `changeStrokePattern` given as different values, and `transform` is not there yet (`docs/mcp.md` lists these limits). Gradient stops are not there yet. A `PathPoint` of a path in an Objects on Path group goes stale when an edit of another path in the group moves it. `crates/engine/src/tests/script_dom_paths.rs`. - Scripts: a document's `default*` members (https://ai-scripting.docsforadobe.dev/jsobjref/Document/) read and set the fill, stroke and stroke options of the next object drawn through `appearance.setNewArt`, leaving the selection and its art as they were, and `scaleFactor` reads 1 (`docs/mcp.md`). `crates/engine/src/tests/script_dom_defaults.rs`. - Scripts: `app.undo()` and `app.redo()` undo and redo the edits the run made, and each document open before and after the run that it changed gets one undo step. `crates/engine/src/tests/script_dom.rs`. - Scripts: `document.textFrames` makes point type, area type and type on a path, and each text frame gives its kind, its contents, its text as text ranges with their characters, words and paragraphs (which can add text), their character attributes (size, leading, tracking, baseline shift, scales, rotation, underline, strikethrough, font) and paragraph attributes (alignment, indents, space before and after), outlines and point and area conversion; `app.textFonts` lists the fonts, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/TextFrameItems/, https://ai-scripting.docsforadobe.dev/jsobjref/TextFrameItem/, https://ai-scripting.docsforadobe.dev/jsobjref/TextRange/ and https://ai-scripting.docsforadobe.dev/jsobjref/TextFonts/ describe them (`docs/mcp.md`). Offsets count UTF-16 units, VectorCraft's own rule. Lines, tab stops and colors are not there yet. `crates/engine/src/tests/script_text.rs`.