From 5d39f8710ce621f87850e37374815f6df1418ba7 Mon Sep 17 00:00:00 2001 From: Marco Arnulfo <103679419+marcoarnulfo@users.noreply.github.com> Date: Tue, 13 Oct 2026 11:07:46 +0200 Subject: [PATCH] HATCHEDIT: choosing SOLID on a gradient hatch makes it a plain solid fill (fixes #721) (#740) Co-authored-by: Brandon Thomas Co-authored-by: Claude Opus 5.5 --- crates/engine/src/cmd/hatch.rs | 15 +++++++++++++++ crates/engine/src/cmd/hatch/edit.rs | 5 +++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/cmd/hatch.rs b/crates/engine/src/cmd/hatch.rs index f1c65792..acfb42b6 100644 --- a/crates/engine/src/cmd/hatch.rs +++ b/crates/engine/src/cmd/hatch.rs @@ -798,6 +798,21 @@ mod tests { assert!(hatch.gradient.is_none()); } + #[test] + fn hatchedit_solid_replaces_gradient() { + let mut s = Session::new(); + s.execute("rectang", &json!({ "p1": [0, 0], "p2": [10, 10] })).unwrap(); + s.execute("gradient", &json!({ "points": [[5, 5]], "color1": "1", "color2": "3" })).unwrap(); + let (h, before) = only_hatch(&s); + assert!(before.gradient.is_some()); + s.execute("hatchedit", &json!({ "handles": [h.clone()], "pattern": "SOLID" })).unwrap(); + let (h2, hatch) = only_hatch(&s); + assert_eq!(h2, h); + assert!(hatch.solid); + assert!(hatch.gradient.is_none(), "SOLID is a plain fill, not the gradient"); + assert_eq!(hatch.loops, before.loops); + } + #[test] fn the_pattern_picker_is_offered_and_its_choice_sets_the_pattern() { let mut s = Session::new(); diff --git a/crates/engine/src/cmd/hatch/edit.rs b/crates/engine/src/cmd/hatch/edit.rs index db56167f..ae7a9551 100644 --- a/crates/engine/src/cmd/hatch/edit.rs +++ b/crates/engine/src/cmd/hatch/edit.rs @@ -146,9 +146,10 @@ fn properties(h: &mut Hatch, p: &Value) { if let Some(v) = str_param(p, "pattern").map(str::trim).filter(|v| !v.is_empty()) { h.pattern = v.to_ascii_uppercase(); h.solid = h.pattern == "SOLID"; + // A named pattern, SOLID included, replaces the gradient fill; the renderer draws the + // gradient first when it is set. + h.gradient = None; if !h.solid { - // A named pattern replaces the gradient fill; the renderer draws the gradient first when it is set. - h.gradient = None; // A library pattern is drawn from the library; a loaded .pat pattern brings its lines; // any other name is the hatch's own and keeps its definition. if cadcraft_doc::library::pattern(&h.pattern).is_some() {