HATCHEDIT: choosing SOLID on a gradient hatch makes it a plain solid fill (fixes #721) (#740)

Co-authored-by: Brandon Thomas <echelon@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Marco Arnulfo
2026-10-13 05:07:46 -04:00
committed by GitHub
co-authored by Brandon Thomas Claude Opus 5.5
parent 6394c7c6f3
commit 5d39f8710c
2 changed files with 18 additions and 2 deletions
+15
View File
@@ -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();
+3 -2
View File
@@ -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() {