mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-21 09:26:43 +00:00
Color Replacement strokes use the Tolerance as the field stores it (CodeRabbit review on crates/engine/src/cmd/brush_cmds.rs:850)
A restored fractional Tolerance (12.5) reached the stroke unrounded while the options bar was hidden, and as 13 once the bar had shown it. The stroke params now round it with the field's rule, as the Background Eraser's do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
44bfd8b056
commit
63d051bccf
3 files changed
+16
-2
No files matched your search
@@ -110,3 +110,15 @@ fn the_command_runs_tolerance_below_one_as_one() {
|
||||
let spec = photocraft_engine::command_specs().iter().find(|s| s.id == "paint.colorReplacement").unwrap();
|
||||
assert!(spec.params.contains("\"tolerance\":1..100"), "{}", spec.params);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_restored_fraction_reaches_the_stroke_as_a_whole_number() {
|
||||
// The options bar need not have drawn: the stroke's params round it themselves, so a stroke
|
||||
// replaces the same pixels before and after the bar shows the setting.
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
|
||||
for (saved, want) in [(12.5, 13.0), (23.4, 23.0), (0.0, 1.0), (150.0, 100.0)] {
|
||||
app.ui.tool_options.cr_tolerance = saved;
|
||||
let p = crate::retouch_ui::color_replacement_params(&app);
|
||||
assert_eq!(p["tolerance"].as_f64(), Some(want), "{saved}");
|
||||
}
|
||||
}
|
||||
@@ -195,7 +195,7 @@ pub(crate) fn whole_tolerance_field(ui: &mut egui::Ui, value: &mut f32, draft: &
|
||||
/// A Tolerance as the field stores it: a whole number in 1..=100, the default 50 for a value
|
||||
/// that is no number. Strokes use it too, so a restored setting erases the same before and after
|
||||
/// the options bar shows it.
|
||||
fn stored_tolerance(v: f32) -> f32 {
|
||||
pub(crate) fn stored_tolerance(v: f32) -> f32 {
|
||||
if v.is_finite() { v.round().clamp(1.0, 100.0) } else { 50.0 }
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,9 @@ pub(crate) fn color_replacement_params(app: &PhotocraftApp) -> Value {
|
||||
"mode": o.cr_mode,
|
||||
"sampling": o.cr_sampling,
|
||||
"limits": o.cr_limits,
|
||||
"tolerance": o.cr_tolerance,
|
||||
// As the field stores it (#11930), so a restored fraction replaces the same pixels before
|
||||
// and after the options bar shows it.
|
||||
"tolerance": crate::eraser_ui::stored_tolerance(o.cr_tolerance),
|
||||
"antiAlias": o.cr_anti_alias,
|
||||
// A mask or channel target is refused: the tool recolours layer pixels only.
|
||||
"target": crate::canvas::paint_target(app),
|
||||
|
||||
Reference in new issue
Block a user