mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-16 14:17:14 +00:00
Image Trace: Outline view leaves out renamed seam fills
Outline views left out an Abutting trace's seam fills only while their clip group kept the name "Seam Fills". Renamed, the group drew its clipping box and, on a stretched image, the outlines of its filled seam bands. The group is now also left out when it is still the lowest traced shape, where the trace puts it. The outline-view test samples inside the seam band beside the shared edge on the stretched image, and checks that renaming the group leaves the view unchanged.
This commit is contained in:
@@ -7737,7 +7737,8 @@ fn image_trace_views_draw_on_screen_only_and_expand_to_the_result() {
|
||||
}
|
||||
|
||||
/// Outline views draw the traced paths' outlines and leave out an Abutting trace's seam fills
|
||||
/// (their clipping box and strokes, or on a stretched image the strokes' filled outlines).
|
||||
/// (their clipping box and strokes, or on a stretched image the strokes' filled outlines), renamed
|
||||
/// too.
|
||||
#[test]
|
||||
fn image_trace_outline_view_leaves_out_the_seam_fills() {
|
||||
// Red beside blue in the middle of a transparent 60 × 40 image, placed at 50, 50 and scaled 2×,
|
||||
@@ -7769,6 +7770,14 @@ fn image_trace_outline_view_leaves_out_the_seam_fills() {
|
||||
}
|
||||
// The art's left edge (x = 70) is outlined.
|
||||
assert!((68..=72).any(|x| screen.pixel(x, 90)[0] < 128), "{scale:?}");
|
||||
// Beside the red and blue paths' shared edge (x = 110), inside the seam band (1.5 units
|
||||
// each side on the stretched image) but off the traced outlines (x = 109 and 110): nothing.
|
||||
for x in [108, 111] {
|
||||
assert!(screen.pixel(x, 100)[0] > 245, "{scale:?}, x = {x}: {:?}", screen.pixel(x, 100));
|
||||
}
|
||||
// Renamed, the group is still left out: the view draws as it did.
|
||||
s.execute("layer.setProps", &json!({"id": seams.id.0, "name": "Edges"})).unwrap();
|
||||
assert!(render_doc(&s, true).pixels == screen.pixels, "{scale:?}: renamed seam fills drawn");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -653,19 +653,20 @@ impl Renderer {
|
||||
if view.shows_outlines() {
|
||||
let opts = RenderOptions { outline: true, ..f.opts.clone() };
|
||||
let frame = Frame { opts: &opts, ..*f };
|
||||
// An Abutting trace's seam fills hold no traced outline: a clip group named "Seam Fills"
|
||||
// of paths that are each stroked without a fill or (on a stretched image, the strokes'
|
||||
// outlines) filled without a stroke.
|
||||
let seam_fills = |c: &Arc<Node>| {
|
||||
// An Abutting trace's seam fills hold no traced outline: a clip group of paths that are
|
||||
// each stroked without a fill or (on a stretched image, the strokes' outlines) filled
|
||||
// without a stroke, named "Seam Fills" or, renamed, still the lowest shape, where the
|
||||
// trace puts it.
|
||||
let seam_fills = |i: usize, c: &Arc<Node>| {
|
||||
let one_paint = |m: &Arc<Node>| {
|
||||
matches!(m.kind, NodeKind::Path { .. } | NodeKind::Compound { .. })
|
||||
&& m.appearance.fill_paint().is_none() != m.appearance.stroke_paint().is_none()
|
||||
};
|
||||
c.name.as_deref() == Some("Seam Fills")
|
||||
(i == 0 || c.name.as_deref() == Some("Seam Fills"))
|
||||
&& matches!(&c.kind, NodeKind::Group { clip: true, children }
|
||||
if children.split_first().is_some_and(|(_, members)| !members.is_empty() && members.iter().all(one_paint)))
|
||||
};
|
||||
for c in shapes.iter().filter(|c| !seam_fills(c)) {
|
||||
for (_, c) in shapes.iter().enumerate().filter(|(i, c)| !seam_fills(*i, c)) {
|
||||
self.draw_outline_member(ctx, &frame, c);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user