Scripts: pathItems.removeAll keeps a clipping path that still holds an image

The document's pathItems.removeAll() refused to delete paths from a group
that is a clipping path when an image or placed document stayed inside
that group, although the image's frame still clips. It now counts the frame
of a visible image or placed document as clipping geometry when the frame
encloses an area, as Node::clip_shapes does, and still refuses when the
frame is collapsed to a line.
This commit is contained in:
dotCooCoo committed 2026-12-04 06:49:26 -08:00
1 parent b36fbc76bd
commit 761f99fc5a
4 files changed
+71 -6

No files matched your search

+9 -4
View File
@@ -561,7 +561,7 @@ fn items_index(h: &super::Host, a: &[Data]) -> Answer {
/// path, one in a hidden or locked layer or group, or one on a locked artboard stops it before
/// anything is deleted, as `PageItems.removeAll()` does. So does the clipping path of a group or
/// layer that keeps other objects, or a compound path or group that clips one and would be left
/// with no visible path or visible type that lays out glyphs to clip by.
/// 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 {
if super::layers::is_scoped(a, "PathItems") {
return super::layers::scoped_remove_all(h, a);
@@ -617,12 +617,17 @@ 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, _)| kurbo::Shape::area(frame).abs() > 0.0)
}
NodeKind::Text(t) => {
in_mask.contains(&n.id) && !vectorcraft_text::layout(vectorcraft_text::FontDb::global(), t).to_bezpath().elements().is_empty()
}