From ad8458832d53967d0a62fda0cbbb20cf26653124 Mon Sep 17 00:00:00 2001 From: Juan Manuel Verges Solanas Date: Fri, 9 Oct 2026 11:31:29 +0000 Subject: [PATCH] Fix #743: raster export leaves guides out skip_templates, which exports and thumbnails set, left template layers out but drew guide paths as hairlines. It now skips guide paths too, as the SVG, PSD and PDF exports and printing already do. Co-Authored-By: Claude Opus 5.5 --- crates/render/src/lib.rs | 7 ++++--- crates/render/src/tests_layeropts.rs | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/crates/render/src/lib.rs b/crates/render/src/lib.rs index 3bf40288..a50cadc5 100644 --- a/crates/render/src/lib.rs +++ b/crates/render/src/lib.rs @@ -85,7 +85,8 @@ pub struct RenderOptions { pub overprint_preview: bool, /// Trim View: clip the artwork to the artboards (nothing on the pasteboard is drawn). pub trim: bool, - /// Leave template layers out (exports and thumbnails: templates are guides, not artwork). + /// Leave template layers and guides out (exports and thumbnails: they're aids to drawing, not + /// artwork). pub skip_templates: bool, /// Pattern editing mode's tile edge and swatch bounds colour (Object → Pattern → Tile Edge /// Color), RGB. @@ -725,9 +726,9 @@ impl Renderer { Some(p) } - /// Whether `a` is left out of this frame: hidden, a skipped template, or culled. + /// Whether `a` is left out of this frame: hidden, a skipped template or guide, or culled. fn skipped(&mut self, f: &Frame, a: &Arc) -> bool { - let skipped_template = f.opts.skip_templates && matches!(a.kind, NodeKind::Layer { template: true, .. }); + let skipped_template = f.opts.skip_templates && matches!(a.kind, NodeKind::Layer { template: true, .. } | NodeKind::Path { guide: true, .. }); if !a.visible || skipped_template || f.opts.hidden.contains(&a.id) { return true; } diff --git a/crates/render/src/tests_layeropts.rs b/crates/render/src/tests_layeropts.rs index 53e75758..db8b6eb2 100644 --- a/crates/render/src/tests_layeropts.rs +++ b/crates/render/src/tests_layeropts.rs @@ -66,3 +66,22 @@ fn dim_images_fades_only_the_images() { assert_eq!(img.pixel(25, 25), [255, 0, 0, 255], "vector art stays"); assert_eq!(render(&d, true).pixel(65, 25), [255, 0, 0, 255], "exports are not dimmed"); } + +/// A guide path draws on screen only: exports leave it out, as they leave templates out (and as +/// the SVG, PSD and PDF exports and printing already do). +#[test] +fn guides_draw_on_screen_only() { + let mut d = Document::new(100.0, 100.0); + let l = d.layers[0].id; + let mut g = Node::path(d.alloc_id(), shapes::rectangle(Rect::new(70.0, 70.0, 90.0, 90.0)), Appearance::default()); + if let NodeKind::Path { guide, .. } = &mut g.kind { + *guide = true; + } + d.insert(Some(l), 0, g).unwrap(); + let drawn = |export: bool| { + let r = render(&d, export); + (60..100).flat_map(|y| (60..100).map(move |x| (x, y))).filter(|&(x, y)| r.pixel(x, y) != [255, 255, 255, 255]).count() + }; + assert!(drawn(false) > 0, "on screen the guide shows"); + assert_eq!(drawn(true), 0, "exports leave it out"); +}