Add healing brush
This commit is contained in:
@@ -303,6 +303,7 @@ impl BrushEngine {
|
||||
RasterBlendMode::Erase => 1u32,
|
||||
RasterBlendMode::Smudge => 2u32,
|
||||
RasterBlendMode::CloneStamp => 3u32,
|
||||
RasterBlendMode::Healing => 4u32,
|
||||
};
|
||||
|
||||
let push_dab = |dabs: &mut Vec<GpuDab>,
|
||||
@@ -325,7 +326,7 @@ impl BrushEngine {
|
||||
color_b: cb,
|
||||
// Clone stamp: color_r/color_g hold source canvas X/Y, so color_a = 1.0
|
||||
// (blend strength is opa_weight × opacity × 1.0 in the shader).
|
||||
color_a: if blend_mode_u == 3 { 1.0 } else { stroke.color[3] },
|
||||
color_a: if blend_mode_u == 3 || blend_mode_u == 4 { 1.0 } else { stroke.color[3] },
|
||||
ndx, ndy, smudge_dist,
|
||||
blend_mode: blend_mode_u,
|
||||
elliptical_dab_ratio: bs.elliptical_dab_ratio.max(1.0),
|
||||
@@ -359,7 +360,7 @@ impl BrushEngine {
|
||||
state, bs, pt.x, pt.y, base_r, pt.pressure, stroke.color,
|
||||
);
|
||||
if !matches!(base_blend, RasterBlendMode::Smudge) {
|
||||
let (cr2, cg2, cb2) = if matches!(base_blend, RasterBlendMode::CloneStamp) {
|
||||
let (cr2, cg2, cb2) = if matches!(base_blend, RasterBlendMode::CloneStamp | RasterBlendMode::Healing) {
|
||||
// Store offset in color_r/color_g; shader adds it per-pixel.
|
||||
let (ox, oy) = stroke.clone_src_offset.unwrap_or((0.0, 0.0));
|
||||
(ox, oy, 0.0)
|
||||
@@ -478,7 +479,7 @@ impl BrushEngine {
|
||||
push_dab(&mut dabs, &mut bbox,
|
||||
ex, ey, radius2, opacity2, cr, cg, cb,
|
||||
ndx, ndy, smudge_dist);
|
||||
} else if matches!(base_blend, RasterBlendMode::CloneStamp) {
|
||||
} else if matches!(base_blend, RasterBlendMode::CloneStamp | RasterBlendMode::Healing) {
|
||||
// Store the offset (not absolute position) in color_r/color_g.
|
||||
// The shader adds this to each pixel's own position for per-pixel sampling.
|
||||
let (ox, oy) = stroke.clone_src_offset.unwrap_or((0.0, 0.0));
|
||||
@@ -517,7 +518,7 @@ impl BrushEngine {
|
||||
last_smooth_x, last_smooth_y,
|
||||
base_r, last_pressure, stroke.color,
|
||||
);
|
||||
let (cr2, cg2, cb2) = if matches!(base_blend, RasterBlendMode::CloneStamp) {
|
||||
let (cr2, cg2, cb2) = if matches!(base_blend, RasterBlendMode::CloneStamp | RasterBlendMode::Healing) {
|
||||
// Store offset in color_r/color_g; shader adds it per-pixel.
|
||||
let (ox, oy) = stroke.clone_src_offset.unwrap_or((0.0, 0.0));
|
||||
(ox, oy, 0.0)
|
||||
|
||||
@@ -20,6 +20,8 @@ pub enum RasterBlendMode {
|
||||
Smudge,
|
||||
/// Clone stamp: copy pixels from a source region
|
||||
CloneStamp,
|
||||
/// Healing brush: color-corrected clone stamp (preserves source texture, shifts color to match destination)
|
||||
Healing,
|
||||
}
|
||||
|
||||
impl Default for RasterBlendMode {
|
||||
|
||||
Reference in New Issue
Block a user