mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 13:32:45 -05:00
Merge pull request #10834 from dotCooCoo/fix/remove-all-image-frame-clip
Scripts: pathItems.removeAll keeps a clipping path that still holds an image
This commit is contained in:
4 files changed
+168
-9
No files matched your search
@@ -718,8 +718,8 @@ thread_local! {
|
||||
/// before anything is deleted, as `PageItems.removeAll()` does. A compound path's
|
||||
/// `pathItems.removeAll()` leaves the compound path, empty, as `remove()` of its last path does.
|
||||
/// It also throws and deletes nothing when it would delete the clipping path of a group or layer
|
||||
/// that keeps other objects, or leave a compound path or group that clips one with no visible path
|
||||
/// or visible type that lays out glyphs to clip by.
|
||||
/// that keeps other objects, or leave a compound path or group that clips one with no visible path,
|
||||
/// image, placed document or visible type that lays out glyphs to clip by.
|
||||
fn items_remove_all(h: &super::Host, a: &[Data]) -> Answer {
|
||||
let (doc, c) = items_scope(h, a)?;
|
||||
let (ids, refused, on_locked, masks, tracing) = with_doc(h, doc, |_, st| {
|
||||
@@ -807,12 +807,15 @@ fn items_remove_all(h: &super::Host, a: &[Data]) -> Answer {
|
||||
{
|
||||
going.insert(n.id);
|
||||
}
|
||||
// A clip outline takes in visible paths and the glyphs of visible type, as
|
||||
// `push_clip_shapes` does; type that lays out no glyphs (blank, or overset) gives no
|
||||
// outline. A list marker is a glyph too, so whitespace-only type is laid out as well.
|
||||
// A clip outline takes in visible paths, the frames of visible images and placed
|
||||
// documents that enclose an area, and the glyphs of visible type, as `push_clip_shapes` does; type that lays
|
||||
// out no glyphs (blank, or overset) gives no outline. A list marker is a glyph too, so
|
||||
// whitespace-only type is laid out as well.
|
||||
let shape = n.visible
|
||||
&& match &n.kind {
|
||||
NodeKind::Path { .. } => true,
|
||||
// A frame collapsed to a line or a point encloses nothing to clip by.
|
||||
NodeKind::Image(_) | NodeKind::PlacedDocument(_) => n.clip_shapes(None).iter().any(|(frame, _)| encloses(frame)),
|
||||
NodeKind::Text(t) => {
|
||||
in_mask.contains(&n.id) && !vectorcraft_text::layout(vectorcraft_text::FontDb::global(), t).to_bezpath().elements().is_empty()
|
||||
}
|
||||
@@ -824,10 +827,18 @@ fn items_remove_all(h: &super::Host, a: &[Data]) -> Answer {
|
||||
if n.visible && ((shape && !going.contains(&n.id)) || inner) {
|
||||
geometry.insert(n.id);
|
||||
}
|
||||
// The live geometry effects of what stays in the clipping path reshape the region it
|
||||
// clips by, as the renderer draws it; deleting paths that lets an effect shrink the
|
||||
// region to nothing leaves no outline. A region that was empty before is left as it is.
|
||||
// The region is the area the outline fills under its fill rule, so outlines that run
|
||||
// opposite ways over the same area under nonzero fill nothing.
|
||||
let reshaped_empty = |m: &vectorcraft_doc::Node| {
|
||||
vectorcraft_render::effects::reshaped_clip_outline(m).is_some_and(|o| !o.is_some_and(|(bp, rule)| fills(&bp, rule)))
|
||||
};
|
||||
if n.clips()
|
||||
&& let Some(mask) = kids.first()
|
||||
&& affected.contains(&mask.id)
|
||||
&& !geometry.contains(&mask.id)
|
||||
&& (!geometry.contains(&mask.id) || (reshaped_empty(&without(mask, &going, &affected)) && !reshaped_empty(mask)))
|
||||
&& kids.iter().skip(1).any(|k| !going.contains(&k.id) && !matches!(k.kind, NodeKind::RulerGuide { .. }))
|
||||
&& masks.len() < 20
|
||||
{
|
||||
@@ -858,6 +869,57 @@ fn items_remove_all(h: &super::Host, a: &[Data]) -> Answer {
|
||||
Ok(Data::Undefined)
|
||||
}
|
||||
|
||||
/// Whether a subpath of `outline` encloses an area. Each subpath's area is measured from its first
|
||||
/// point, so its position does not change the result, and an area within roundoff of its own
|
||||
/// bounding box's is counted as none.
|
||||
fn encloses(outline: &kurbo::BezPath) -> bool {
|
||||
let mut subpaths: Vec<kurbo::BezPath> = Vec::new();
|
||||
for el in outline.elements() {
|
||||
if matches!(el, kurbo::PathEl::MoveTo(_)) || subpaths.is_empty() {
|
||||
subpaths.push(kurbo::BezPath::new());
|
||||
}
|
||||
if let Some(last) = subpaths.last_mut() {
|
||||
last.push(*el);
|
||||
}
|
||||
}
|
||||
subpaths.into_iter().any(|mut sub| {
|
||||
let Some(start) = sub.elements().iter().find_map(|e| e.end_point()) else { return false };
|
||||
sub.apply_affine(kurbo::Affine::translate(-start.to_vec2()));
|
||||
let area = kurbo::Shape::area(&sub).abs();
|
||||
area > 0.0 && area > 64.0 * f64::EPSILON * kurbo::Shape::bounding_box(&sub).area()
|
||||
})
|
||||
}
|
||||
|
||||
/// Whether `outline` fills an area under `rule`: a subpath encloses an area ([`encloses`]) and the
|
||||
/// outline with its overlaps resolved, thin strips included, has an area. An outline the path
|
||||
/// operations refuse is judged by [`encloses`] alone.
|
||||
fn fills(outline: &kurbo::BezPath, rule: vectorcraft_geom::FillRule) -> bool {
|
||||
if !encloses(outline) {
|
||||
return false;
|
||||
}
|
||||
match vectorcraft_pathops::try_area(&vectorcraft_geom::PathData::from_bezpath(outline), rule) {
|
||||
Ok(area) => area > 0.0,
|
||||
Err(_) => true,
|
||||
}
|
||||
}
|
||||
|
||||
/// `n` without the members in `going`, at every depth. Only the members in `affected` (those that
|
||||
/// hold a member in `going`) are copied; the others are shared.
|
||||
fn without(
|
||||
n: &vectorcraft_doc::Node,
|
||||
going: &std::collections::HashSet<NodeId>,
|
||||
affected: &std::collections::HashSet<NodeId>,
|
||||
) -> vectorcraft_doc::Node {
|
||||
let mut m = n.clone();
|
||||
if let Some(kids) = m.children_mut() {
|
||||
kids.retain(|k| !going.contains(&k.id));
|
||||
for k in kids.iter_mut().filter(|k| affected.contains(&k.id)) {
|
||||
*k = Arc::new(without(k, going, affected));
|
||||
}
|
||||
}
|
||||
m
|
||||
}
|
||||
|
||||
/// The id in the JSON result of a command that made an object, read exactly, as the text creators
|
||||
/// read it.
|
||||
fn made_id(r: &(Data, Value)) -> std::result::Result<NodeId, HostError> {
|
||||
|
||||
@@ -4469,6 +4469,103 @@ fn document_path_items_remove_all_refuses_to_empty_a_clipping_group_with_an_empt
|
||||
assert_eq!(undo_steps(&s), steps);
|
||||
}
|
||||
|
||||
/// An image's frame clips as a clipping path does, so a clipping group whose clipping path keeps
|
||||
/// an image still has an outline after its paths are deleted.
|
||||
#[test]
|
||||
fn document_path_items_remove_all_keeps_a_clipping_group_whose_clipping_path_keeps_an_image() {
|
||||
for frame in [Frame::Square, Frame::Line, Frame::Far, Frame::Inset, Frame::Mirrored, Frame::Strip] {
|
||||
remove_all_beside_an_image(frame);
|
||||
}
|
||||
}
|
||||
|
||||
/// The image frame of [`remove_all_beside_an_image`].
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
enum Frame {
|
||||
/// 40 pt square.
|
||||
Square,
|
||||
/// Collapsed to a line.
|
||||
Line,
|
||||
/// 1/64 pt square 3,500,000 pt from the origin.
|
||||
Far,
|
||||
/// 40 pt square with a live Offset Path of -30 pt, which leaves nothing.
|
||||
Inset,
|
||||
/// 40 pt square with a live Transform effect that adds one copy reflected about its center:
|
||||
/// the two outlines run opposite ways over the same area and fill nothing under nonzero.
|
||||
Mirrored,
|
||||
/// 40 pt square with a live Transform effect that scales it to 0.004 pt high, which still
|
||||
/// clips to a thin strip.
|
||||
Strip,
|
||||
}
|
||||
|
||||
/// A clipping group whose clipping path is a group of one path and an image with `frame`, then the
|
||||
/// document's `pathItems.removeAll()`.
|
||||
fn remove_all_beside_an_image(frame: Frame) {
|
||||
let flat = matches!(frame, Frame::Line | Frame::Inset | Frame::Mirrored);
|
||||
let (mut s, a, b) = doc();
|
||||
let t = NodeId(s.execute("text.create", &json!({"x": 10, "y": 250, "text": "hi"})).unwrap()["id"].as_u64().unwrap());
|
||||
s.execute("select.set", &json!({"ids": [a.0]})).unwrap();
|
||||
let mask = NodeId(s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap());
|
||||
let image = s
|
||||
.edit("Place", |d, _| {
|
||||
let id = d.alloc_id();
|
||||
let im = vectorcraft_doc::ImageObject {
|
||||
key: "pic".into(),
|
||||
width: 4,
|
||||
height: 4,
|
||||
xf: match frame {
|
||||
Frame::Square | Frame::Inset | Frame::Mirrored | Frame::Strip => kurbo::Affine::scale(10.0),
|
||||
Frame::Line => kurbo::Affine::scale_non_uniform(10.0, 0.0),
|
||||
Frame::Far => kurbo::Affine::translate((3_500_000.0, 3_500_000.0)) * kurbo::Affine::scale(1.0 / 256.0),
|
||||
},
|
||||
link: None,
|
||||
placement: Default::default(),
|
||||
pixels: None,
|
||||
};
|
||||
d.insert(Some(mask), 0, vectorcraft_doc::Node::new(id, NodeKind::Image(Box::new(im))))?;
|
||||
Ok(id)
|
||||
})
|
||||
.unwrap();
|
||||
if frame == Frame::Inset {
|
||||
s.execute("effect.apply", &json!({"effect": "path.offsetPath", "params": {"offset": -30}, "ids": [image.0], "item": null})).unwrap();
|
||||
}
|
||||
if frame == Frame::Mirrored {
|
||||
s.execute(
|
||||
"effect.apply",
|
||||
&json!({"effect": "distort.transform", "params": {"reflectX": true, "copies": 1, "reference": 4}, "ids": [image.0], "item": null}),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
if frame == Frame::Strip {
|
||||
s.execute("effect.apply", &json!({"effect": "distort.transform", "params": {"scaleV": 0.01}, "ids": [image.0], "item": null})).unwrap();
|
||||
}
|
||||
s.execute("select.set", &json!({"ids": [mask.0, t.0]})).unwrap();
|
||||
let outer = NodeId(s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap());
|
||||
s.edit("Clip", |d, _| {
|
||||
if let Some(NodeKind::Group { children, clip }) = d.node_mut(outer).map(|n| &mut n.kind) {
|
||||
children.sort_by_key(|c| c.id != mask);
|
||||
*clip = true;
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
let before = s.active().unwrap().doc.clone();
|
||||
let out = log(&mut s, CAUGHT_PATHS_REMOVE_ALL);
|
||||
if flat {
|
||||
assert_eq!(
|
||||
out[0],
|
||||
json!(format!("cannot delete a clipping path while its group or layer keeps other objects; release the clipping mask first: {}", mask.0))
|
||||
);
|
||||
assert_eq!(s.active().unwrap().doc, before);
|
||||
return;
|
||||
}
|
||||
assert_eq!(out, [json!(""), json!(0)]);
|
||||
let d = &s.active().unwrap().doc;
|
||||
assert!(d.node(a).is_none() && d.node(b).is_none());
|
||||
assert!(d.node(outer).unwrap().clips());
|
||||
assert_eq!(d.parent_of(image), Some(mask));
|
||||
assert!(d.node(t).is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn document_path_items_remove_all_keeps_empty_groups_but_removes_empty_compounds() {
|
||||
for compound in [false, true] {
|
||||
|
||||
+1
-1
@@ -3317,7 +3317,7 @@ through `$`:
|
||||
or layer that keeps other objects that are not ruler guides. `removeAll()` on the `pathItems` of a compound path that is such a clipping
|
||||
path throws the same way, since it would leave the clipping path empty. The document's `pathItems.removeAll()` still deletes the paths of a group that
|
||||
is the clipping path when a visible text object that lays out glyphs stays inside that group, because the text then
|
||||
clips. Text beside the clipping path in the clipping group does not count. Hidden text, text
|
||||
clips. A visible image or placed document inside that group keeps it clipping by its frame too, when the frame encloses an area. When deleting the paths makes a live geometry effect, such as an Offset Path inset, leave no clipping region where there was one before, `removeAll()` throws and deletes nothing. A region that the effect already left empty before the call does not count as such a change; the call still throws when no clipping geometry stays in the mask. Text beside the clipping path in the clipping group does not count. Hidden text, text
|
||||
in a hidden group, blank text without a list marker, area text too short for its first line, and text that a clipping group nested in
|
||||
the mask clips do not keep it clipping, so `removeAll()` then throws and deletes nothing. `remove()` on an object that
|
||||
is hidden or locked, is inside a hidden or locked layer or group, or is a group that holds one, and `removeAll()`
|
||||
|
||||
@@ -1121,11 +1121,11 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- 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.exportForScreens` writes the artboards, assets or whole document of an `ExportForScreensItemToExport` into a folder as JPEG, PNG-24, PNG-8, SVG or PDF with a file name prefix, with the option classes and enumerations the reference pages https://www.indesignjs.de/indesignapi/illustrator/Document.html, https://www.indesignjs.de/indesignapi/illustrator/ExportForScreensItemToExport.html and https://www.indesignjs.de/indesignapi/illustrator/ExportForScreensType.html describe, and writes only where the script's `File` objects may (`docs/mcp.md`). With PNG8 transparency enabled, `matte: false` preserves transparency without a white background. Raster width and height requests outside an effective scale of 0.01 to 64 pixels per point are rejected before the underlying export command writes output; files written by earlier exports in the same script call remain. SVG embeds raster images and rejects `RasterImageLocation.LINK`. `crates/engine/src/tests/script_screens.rs`.
|
||||
- Scripts: `Document.rasterize` replaces page items with an embedded image and `Document.imageCapture` writes a PNG of the art or of an area of the page, with the option classes the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/RasterizeOptions/ and https://ai-scripting.docsforadobe.dev/jsobjref/ImageCaptureOptions/ describe; `object.rasterize` takes `ids` and `clipBounds` for them (`docs/mcp.md`). `Document.windowCapture` is not there yet. `crates/engine/src/tests/script_raster_capture.rs`.
|
||||
- Scripts: `Document.pathItems`, and a layer's or group's `pathItems` (https://ai-scripting.docsforadobe.dev/jsobjref/Layer/, https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/) for the paths directly in it, list the paths and make 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`). For ordinary layer placement, the creators use the topmost shown, unlocked layer when the active layer is locked or hidden. The call also throws and makes no path when the document has layers and every one is locked or hidden. `pathItems["name"]` reads a path by name as `pageItems` does, and `removeAll()` deletes nothing and throws when any path is hidden or locked, is on a locked artboard or is a guide while guides are locked, or when it would delete or empty the clipping path of a group or layer that keeps other objects. It still deletes the paths of a group that is the clipping path when a visible text object that lays out glyphs stays inside that group, because the text then clips; text beside the clipping path does not count, and a clipping group nested in the mask counts only when its own clipping path keeps such geometry. A path takes the page item transforms, and `resize` also sets its stroke weight to a `changeLineWidths` percent from 0 to 100000 (at most 1000 points; a member of a compound sets the compound's stroke); gradients move with positions, so a `changeFillGradients` different from `changePositions` throws an error, as do `changeFillPatterns` and `changeStrokePattern` given as different values (`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. A `PathPoint` of another Global Edit member goes stale when Global Edit changes its path's points. `crates/engine/src/tests/script_dom_paths.rs`, `crates/engine/src/tests/script_dom.rs`.
|
||||
- Scripts: `Document.pathItems`, and a layer's or group's `pathItems` (https://ai-scripting.docsforadobe.dev/jsobjref/Layer/, https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/) for the paths directly in it, list the paths and make 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`). For ordinary layer placement, the creators use the topmost shown, unlocked layer when the active layer is locked or hidden. The call also throws and makes no path when the document has layers and every one is locked or hidden. `pathItems["name"]` reads a path by name as `pageItems` does, and `removeAll()` deletes nothing and throws when any path is hidden or locked, is on a locked artboard or is a guide while guides are locked, or when it would delete or empty the clipping path of a group or layer that keeps other objects. It still deletes the paths of a group that is the clipping path when a visible text object that lays out glyphs stays inside that group, because the text then clips, and the same holds for a visible image or placed document whose frame encloses an area, unless deleting the paths makes a live geometry effect leave no clipping region where there was one before; text beside the clipping path does not count, and a clipping group nested in the mask counts only when its own clipping path keeps such geometry. A path takes the page item transforms, and `resize` also sets its stroke weight to a `changeLineWidths` percent from 0 to 100000 (at most 1000 points; a member of a compound sets the compound's stroke); gradients move with positions, so a `changeFillGradients` different from `changePositions` throws an error, as do `changeFillPatterns` and `changeStrokePattern` given as different values (`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. A `PathPoint` of another Global Edit member goes stale when Global Edit changes its path's points. `crates/engine/src/tests/script_dom_paths.rs`, `crates/engine/src/tests/script_dom.rs`.
|
||||
- Scripts: a page item's `translate`, `rotate`, `resize` and `transform` move, turn, scale and transform the object by offsets, an angle, percentages or a `Matrix` record, about its center or a `Transformation` point, with positions, patterns, gradients and line widths following their arguments (https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/). Each call that moves or reshapes the object runs `object.transform` inside the run's transaction, a call that changes only a path's stroke weight runs `stroke.set`, and a call that changes nothing runs no command. `resize` and `transform` on a member of a compound path with `changeLineWidths` at their own scale set the compound's stroke weight; locked art, art on a locked artboard and bad arguments throw an error with nothing changed (`docs/mcp.md`). `crates/engine/src/tests/script_dom_transform.rs`.
|
||||
- Scripts: `Document.placedItems` and `Document.rasterItems` list a document's linked and embedded images; `placedItems.add()` with a `File` assigned to `file` places an image linked, and `PlacedItem.relink(file)` and `embed()` relink and embed it, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/PlacedItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PlacedItem/, https://ai-scripting.docsforadobe.dev/jsobjref/RasterItems/ and https://ai-scripting.docsforadobe.dev/jsobjref/RasterItem/ describe them. A raster item's bits per channel, channels, color space and transparency come from its encoded pixels' header. Only files the script may read, of at most 256 MiB and holding an image, are placed or relinked. `crates/engine/src/tests/script_dom_images.rs`.
|
||||
- Scripts: `app.preferences` reads, stores and removes values by key with the type they were set as, keeps them across runs and restarts, and turns the warning before a picked script on with the key `ShowExternalJSXWarning`, and off only after the person answers Yes to a confirm (https://ai-scripting.docsforadobe.dev/jsobjref/Preferences/; the confirm is VectorCraft's own rule); `app` makes, joins, inverts and compares `Matrix` records (https://ai-scripting.docsforadobe.dev/jsobjref/Matrix/), rounding each joined value once from its exact sum of products and deciding whether an inverted value overflows from its exact quotient, and runs Copy, Cut and Paste on the active document inside the run's transaction (https://ai-scripting.docsforadobe.dev/jsobjref/Application/). `crates/engine/src/tests/script_dom_prefs.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`). For ordinary layer placement, the creators use the topmost shown, unlocked layer when the active layer is locked or hidden. The call also throws and makes no path when the document has layers and every one is locked or hidden. `pathItems["name"]` reads a path by name as `pageItems` does, and `removeAll()` deletes nothing and throws when any path is hidden or locked, is on a locked artboard or is a guide while guides are locked, or when it would delete or empty the clipping path of a group or layer that keeps other objects. It still deletes the paths of a group that is the clipping path when a visible text object that lays out glyphs stays inside that group, because the text then clips; text beside the clipping path does not count, and a clipping group nested in the mask counts only when its own clipping path keeps such geometry. A path takes the page item transforms, and `resize` also sets its stroke weight to a `changeLineWidths` percent from 0 to 100000 (at most 1000 points; a member of a compound sets the compound's stroke); gradients move with positions, so a `changeFillGradients` different from `changePositions` throws an error, as do `changeFillPatterns` and `changeStrokePattern` given as different values (`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. A `PathPoint` of another Global Edit member goes stale when Global Edit changes its path's points. `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`). For ordinary layer placement, the creators use the topmost shown, unlocked layer when the active layer is locked or hidden. The call also throws and makes no path when the document has layers and every one is locked or hidden. `pathItems["name"]` reads a path by name as `pageItems` does, and `removeAll()` deletes nothing and throws when any path is hidden or locked, is on a locked artboard or is a guide while guides are locked, or when it would delete or empty the clipping path of a group or layer that keeps other objects. It still deletes the paths of a group that is the clipping path when a visible text object that lays out glyphs stays inside that group, because the text then clips, and the same holds for a visible image or placed document whose frame encloses an area, unless deleting the paths makes a live geometry effect leave no clipping region where there was one before; text beside the clipping path does not count, and a clipping group nested in the mask counts only when its own clipping path keeps such geometry. A path takes the page item transforms, and `resize` also sets its stroke weight to a `changeLineWidths` percent from 0 to 100000 (at most 1000 points; a member of a compound sets the compound's stroke); gradients move with positions, so a `changeFillGradients` different from `changePositions` throws an error, as do `changeFillPatterns` and `changeStrokePattern` given as different values (`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. A `PathPoint` of another Global Edit member goes stale when Global Edit changes its path's points. `crates/engine/src/tests/script_dom_paths.rs`.
|
||||
- Scripts: `PlacedItem.trace()` and `RasterItem.trace()` make an Image Trace object and return it as a `PluginItem` whose `tracing` gives its path, anchor and color counts, the source image's resolution, `expandTracing()`, `releaseTracing()` and its `TracingOptions`; assigning an option or loading a preset traces it again, except that the view options (`viewRaster` and `viewVector`) only change the view, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/PluginItem/, https://ai-scripting.docsforadobe.dev/jsobjref/TracingObject/ and https://ai-scripting.docsforadobe.dev/jsobjref/TracingOptions/ describe them. Loading the built-in preset the tracing already has, by its name with or without brackets (`[Default]`), with unchanged options does not trace again. Option values are checked for type and range before any trace, a script cannot save a preset, and the options without a VectorCraft setting throw. Tracing again and `releaseTracing()` throw, with nothing changed, when the tracing holds added artwork, an opacity mask on the tracing or on an object the trace made included; the source image keeps its own mask. A tracing saved without `made` is checked only for artwork added during the same run, so tracing it again or releasing it discards artwork that was added before the run without an error, and the opacity mask check applies with or without `made`. The source image of a traced item is left out of `pageItems`, `placedItems` and `rasterItems`; a script reaches it through `PluginItem.tracing.sourceArt`. `remove()` also refuses a shown source image. Renaming an ordinary group that holds an image first to `Image Trace`, or moving or duplicating an image to the bottom of an ordinary group with that name, throws an error, and so does a `groupItems.removeAll()` or `compoundPathItems.removeAll()` that would leave an image at the bottom of such a group. `crates/engine/src/tests/script_dom_tracing.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`.
|
||||
|
||||
Reference in new issue
Block a user