Scripts: tracing counts leave out only the trace's own seam fills

pathCount, anchorCount and usedColorCount skipped every group anywhere in
the tracing that looked like seam fills, so a group named "Seam Fills"
moved into a tracing was not counted. The counts now leave out a clip
group directly in the tracing that is seam fills, or the lowest item
above the source image for traces made before seam fills were clipped,
as retracing does. An Image Trace object inside the tracing leaves out
its own seam fills the same way.
This commit is contained in:
dotCooCoo committed 2026-11-30 08:59:11 -08:00
1 parent affd7a8853
commit 164c3c53a6
2 files changed
+51 -4

No files matched your search

+22 -2
View File
@@ -375,16 +375,24 @@ fn anchors_of(n: &Node) -> u64 {
}
/// The traced paths of the Image Trace object `g`, their anchor points and paints: every path
/// and compound path in it but its source image, the seam fills and clipping paths.
/// and compound path in it but its source image, the seam fills and clipping paths. The seam fills
/// are a clip group directly in the tracing that [`crate::cmd::is_seam_fills`] accepts, or, for a
/// trace made before seam fills were clipped, the lowest item above the source image when it
/// accepts that. A group nested deeper, or an unclipped group higher up, is counted. An Image
/// Trace object inside `g` leaves out its own seam fills the same way.
fn counts(g: &Node) -> Counts {
let mut c = Counts::default();
let mut paints = HashSet::new();
let mut todo: Vec<&Arc<Node>> = g.children().map(|ch| ch.iter().skip(1).collect()).unwrap_or_default();
let mut seams = seam_fills_of(g);
while let Some(n) = todo.pop() {
c.visited += 1;
if crate::cmd::is_seam_fills(n) {
if seams.contains(&n.id) {
continue;
}
if crate::cmd::is_trace_group(n) {
seams.extend(seam_fills_of(n));
}
match &n.kind {
NodeKind::Path { clipping: true, .. } => {}
NodeKind::Path { .. } | NodeKind::Compound { .. } => {
@@ -405,6 +413,18 @@ fn counts(g: &Node) -> Counts {
c
}
/// The seam fills of the Image Trace object `g` ([`counts`]).
fn seam_fills_of(g: &Node) -> HashSet<NodeId> {
g.children()
.into_iter()
.flatten()
.skip(1)
.enumerate()
.filter(|(i, n)| (*i == 0 || matches!(n.kind, NodeKind::Group { clip: true, .. })) && crate::cmd::is_seam_fills(n))
.map(|(_, n)| n.id)
.collect()
}
/// Reads the counts of the tracing `this` names with `f`.
fn count(h: &Host, a: &[Data], f: fn(&Counts) -> u64) -> Answer {
let (item, _) = tracing_of(h, arg(a, 0), "TracingObject")?;