Outline Stroke: a stroke whose geometry effects leave no path is outlined to nothing

A stroke-only path whose Offset Path or other geometry effect leaves no path
paints nothing on the canvas. Outline Stroke reported "no stroked paths
selected" for it, and Expand and Flatten Transparency kept the live stroke.
An empty group now takes the path's place.
This commit is contained in:
dotCooCoo
2026-10-27 14:31:17 -07:00
parent c273227cf8
commit d50ac14da2
2 changed files with 27 additions and 1 deletions
+8 -1
View File
@@ -843,7 +843,8 @@ pub(crate) fn outlined_stroke(
/// it with a gradient, or has Scale Strokes & Effects or Transform Patterns on, becomes the art the
/// canvas draws for it, each copy with its own gradient, stroke width and pattern, and its strokes
/// outlined before the art gets new ids. Random in a Transform effect takes its seed
/// from the object's id, so these effects give the outline the values the canvas drew.
/// from the object's id, so these effects give the outline the values the canvas drew. When the
/// geometry effects leave nothing to paint, an empty group takes the path's place.
/// `None` when `l` has no stroke to outline.
pub(crate) fn outline_strokes(d: &mut Document, brushes: &[vectorcraft_brush::Brush], l: &Node) -> Option<Node> {
use vectorcraft_render::effects::{GeomContext, apply_geometry_with, has_geometry, has_transform_art, is_geometry, reshape};
@@ -894,6 +895,12 @@ pub(crate) fn outline_strokes(d: &mut Document, brushes: &[vectorcraft_brush::Br
if !fills.is_empty() {
parts.push(styled_copy(d, l, fills));
}
let reshapes = reshaped.is_some()
|| l.appearance.items.iter().any(|i| matches!(i, AppearanceItem::Stroke(st) if outlinable(st) && has_geometry(&st.effects)));
if parts.is_empty() && reshapes {
// The geometry effects leave nothing to paint, as on the canvas: an empty group takes the path's place.
parts.push(Node::group(d.alloc_id(), vec![]));
}
assemble(d, l, parts)
}
+19
View File
@@ -245,6 +245,25 @@ fn a_geometry_effect_on_the_stroke_shapes_the_path_it_outlines() {
assert!(near(area(&n), 124.0 * 124.0 - 116.0 * 116.0, 2.0), "{}", area(&n));
}
/// A stroke whose geometry effect leaves no path paints nothing on the canvas, and outlining it
/// replaces the live stroke with an empty group.
#[test]
fn a_stroke_its_effects_empty_is_outlined_to_nothing() {
for (command, p) in outlining() {
let mut s = session();
square_with(&mut s, json!({"none": true}), json!(1), &[("path.offsetPath", json!({"offset": -60}))]);
let before = render(&s);
let n = outlined_by(&mut s, command, &p);
assert!(matches!(&n.kind, NodeKind::Group { children, .. } if children.is_empty()), "{command}: {n:?}");
let mut stroked = false;
for layer in &s.doc().unwrap().doc.layers {
layer.walk(&mut |m| stroked |= m.appearance.items.iter().any(|i| matches!(i, AppearanceItem::Stroke(_))));
}
assert!(!stroked, "{command} left a live stroke");
assert_eq!(differing(&before, &render(&s), 64), 0, "{command}");
}
}
/// A drop shadow on a stroke with a geometry effect stays on the outline, which draws as the
/// stroke did.
#[test]