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 <[email protected]>
This commit is contained in:
Juan Manuel Verges SolanasandClaude Opus 5.5 committed 2026-10-09 11:31:29 +00:00
1 parent eefe849e14
commit ad8458832d
2 files changed
+23 -3

No files matched your search

+4 -3
View File
@@ -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<Node>) -> 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;
}
+19
View File
@@ -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");
}