From d089df0ab51719ce5dd9f78702b1f03cb432394e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 15 Nov 2026 08:28:08 -0800 Subject: [PATCH] Recolor Artwork: Find tries every lighter tint down to 1% When a selected row listed the twenty tints from 25% through 6% of a color of an unselected row, Find left that color undimmed although its 5% tint was free. The search now tries each tint a percent apart from 25% down to 1% before leaving a color as it is. --- crates/ui-egui/src/dialogs/recolor.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dialogs/recolor.rs b/crates/ui-egui/src/dialogs/recolor.rs index e15256b693..238205216e 100644 --- a/crates/ui-egui/src/dialogs/recolor.rs +++ b/crates/ui-egui/src/dialogs/recolor.rs @@ -599,8 +599,9 @@ fn apply_params(d: &Dialog) -> Value { /// aren't selected shows while it is on (VectorCraft's own amount: [`Color::tinted`]). const FIND: &str = "findColors"; const FIND_DIM: f32 = 0.25; -/// The lighter tints, a percent apart, tried when a dimmed color is one a selected row lists. -const FIND_TRIES: usize = 20; +/// The tints tried when a dimmed color is one a selected row lists: [`FIND_DIM`] and each lighter +/// one a percent apart, down to 1%. +const FIND_TRIES: usize = 25; /// The colors of the art that the rows leave out (Preserve White, Black and Grays), as /// `recolor.reduce` returned them. const PRESERVED: &str = "__preserved"; @@ -2299,6 +2300,15 @@ mod tests { let p = find_params(&d).unwrap(); let to = color_value(&p["commands"][0]["params"]["map"]["rgb 0 0 255"]).unwrap(); assert_eq!(to.to_hex(), "#c2c2ff", "{p}"); + // When the twenty tints from 25% through 6% are all listed, the 5% tint is taken. + let blue = color_value(&json!("rgb 0 0 255")).unwrap(); + let tint = |n: usize| key(&blue.tinted(FIND_DIM - n as f32 * 0.01)); + let mut from = vec![json!("rgb 255 0 0")]; + from.extend((0..20).map(tint)); + rs[0]["from"] = json!(from); + d.fields.insert("rows".into(), json!(rs)); + let p = find_params(&d).unwrap(); + assert_eq!(p["commands"][0]["params"]["map"]["rgb 0 0 255"], tint(20), "{p}"); // Another key of the same hex matches only itself, so the tint is kept. rs[0]["from"] = json!(["rgb 255 0 0", "rgb 191 191 255"]); d.fields.insert("rows".into(), json!(rs));