Add sponge tool
This commit is contained in:
@@ -306,6 +306,7 @@ impl BrushEngine {
|
||||
RasterBlendMode::Healing => 4u32,
|
||||
RasterBlendMode::PatternStamp => 5u32,
|
||||
RasterBlendMode::DodgeBurn => 6u32,
|
||||
RasterBlendMode::Sponge => 7u32,
|
||||
};
|
||||
|
||||
let push_dab = |dabs: &mut Vec<GpuDab>,
|
||||
@@ -328,7 +329,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 || blend_mode_u == 4 || blend_mode_u == 6 { 1.0 } else { stroke.color[3] },
|
||||
color_a: if blend_mode_u == 3 || blend_mode_u == 4 || blend_mode_u == 6 || blend_mode_u == 7 { 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),
|
||||
@@ -372,6 +373,9 @@ impl BrushEngine {
|
||||
} else if matches!(base_blend, RasterBlendMode::DodgeBurn) {
|
||||
// color_r = mode (0=dodge, 1=burn); strength comes from opacity
|
||||
(stroke.dodge_burn_mode as f32, 0.0, 0.0, 0.0, 0.0)
|
||||
} else if matches!(base_blend, RasterBlendMode::Sponge) {
|
||||
// color_r = mode (0=saturate, 1=desaturate); strength comes from opacity
|
||||
(stroke.sponge_mode as f32, 0.0, 0.0, 0.0, 0.0)
|
||||
} else {
|
||||
(cr, cg, cb, 0.0, 0.0)
|
||||
};
|
||||
@@ -505,6 +509,12 @@ impl BrushEngine {
|
||||
ex, ey, radius2, opacity2,
|
||||
stroke.dodge_burn_mode as f32, 0.0, 0.0,
|
||||
0.0, 0.0, 0.0);
|
||||
} else if matches!(base_blend, RasterBlendMode::Sponge) {
|
||||
// color_r = mode (0=saturate, 1=desaturate)
|
||||
push_dab(&mut dabs, &mut bbox,
|
||||
ex, ey, radius2, opacity2,
|
||||
stroke.sponge_mode as f32, 0.0, 0.0,
|
||||
0.0, 0.0, 0.0);
|
||||
} else {
|
||||
push_dab(&mut dabs, &mut bbox,
|
||||
ex, ey, radius2, opacity2, cr, cg, cb,
|
||||
@@ -547,6 +557,9 @@ impl BrushEngine {
|
||||
} else if matches!(base_blend, RasterBlendMode::DodgeBurn) {
|
||||
// color_r = mode (0=dodge, 1=burn)
|
||||
(stroke.dodge_burn_mode as f32, 0.0, 0.0, 0.0, 0.0)
|
||||
} else if matches!(base_blend, RasterBlendMode::Sponge) {
|
||||
// color_r = mode (0=saturate, 1=desaturate)
|
||||
(stroke.sponge_mode as f32, 0.0, 0.0, 0.0, 0.0)
|
||||
} else {
|
||||
(cr, cg, cb, 0.0, 0.0)
|
||||
};
|
||||
|
||||
@@ -26,6 +26,8 @@ pub enum RasterBlendMode {
|
||||
PatternStamp,
|
||||
/// Dodge / Burn: lighten (dodge) or darken (burn) existing pixels
|
||||
DodgeBurn,
|
||||
/// Sponge: saturate or desaturate existing pixels
|
||||
Sponge,
|
||||
}
|
||||
|
||||
impl Default for RasterBlendMode {
|
||||
@@ -70,6 +72,9 @@ pub struct StrokeRecord {
|
||||
/// Dodge/Burn mode: 0 = dodge (lighten), 1 = burn (darken)
|
||||
#[serde(default)]
|
||||
pub dodge_burn_mode: u32,
|
||||
/// Sponge mode: 0 = saturate, 1 = desaturate
|
||||
#[serde(default)]
|
||||
pub sponge_mode: u32,
|
||||
pub points: Vec<StrokePoint>,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user