Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Spot Healing Brush trail is Photoshop's dark half-opaque tint (#7342) (#7374)

Khawar Zamman Wani4b2bee675eb2
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs
index 91644b5f7..c2494a08e 100644
--- a/crates/ui-egui/src/canvas.rs
+++ b/crates/ui-egui/src/canvas.rs
@@ -4968,6 +4968,9 @@ fn draw_drag_preview(app: &mut PhotocraftApp, painter: &egui::Painter, xf: &View
Tool::QuickSelection => Color32::from_white_alpha(40),
// The Remove Tool tints what it will remove, like Photoshop's.
Tool::Remove => crate::theme::Tokens::get(painter.ctx()).danger.gamma_multiply(0.45),
+ // Photoshop paints the area to heal in half-opaque dark grey; a faint white trail
+ // barely showed on light pixels (#7342).
+ Tool::SpotHealing => Color32::from_black_alpha(128),
_ => Color32::from_white_alpha(60),
};
let Some(st) = app.session.active() else { return };
diff --git a/crates/ui-egui/tests/drag_preview_canvas.rs b/crates/ui-egui/tests/drag_preview_canvas.rs
index fc516ed30..9b7d682ab 100644
--- a/crates/ui-egui/tests/drag_preview_canvas.rs
+++ b/crates/ui-egui/tests/drag_preview_canvas.rs
@@ -295,3 +295,27 @@ fn a_held_marquee_drag_keeps_requesting_frames() {
assert!(d.is_some_and(|d| d <= Duration::from_millis(100)), "mid-drag repaint request: {d:?}");
button(&mut h, 300.0, 220.0, false);
}
+
+#[test]
+fn the_spot_healing_trail_is_a_dark_half_opaque_tint() {
+ // #7342: the trail was white at a quarter opacity, invisible on white and faint elsewhere.
+ // Photoshop shows the area to heal in half-opaque dark grey.
+ let _gpu = photocraft_testkit::gpu_lock();
+ let Some(mut h) = harness(1.0) else { return };
+ h.run_steps(4);
+ for bg in ["white", "#808080"] {
+ setup(&mut h, bg, "spotHealing");
+ let app = h.state_mut();
+ app.session.tools.brush.size = 40.0;
+ app.session.tools.brush.hardness = 1.0;
+ let before = render(&mut h);
+ drag_to(&mut h, [80.0, 150.0], [320.0, 150.0]);
+ let img = render(&mut h);
+ let p = screen(&h, 200.0, 150.0);
+ let (was, now) = (before.luma(p.x as i64, p.y as i64).unwrap_or(0), img.luma(p.x as i64, p.y as i64).unwrap_or(0));
+ assert!(f32::from(now) < f32::from(was) * 0.6, "spot healing trail on {bg}: luma {was} -> {now}, not dark enough");
+ assert!(f32::from(now) > f32::from(was) * 0.4, "spot healing trail on {bg}: luma {was} -> {now}, should stay see-through");
+ button(&mut h, 320.0, 150.0, false);
+ h.run_steps(2);
+ }
+}