From 304330205f69bbaf21b22b21f86ac95e6ee33eed Mon Sep 17 00:00:00 2001 From: qvest-ssels <214787280+qvest-ssels@users.noreply.github.com> Date: Mon, 30 Nov 2026 08:52:33 +0100 Subject: [PATCH] Pressure for Opacity also drops the preset's opacity Minimum, keeps its jitter --- crates/paint/src/dynamics.rs | 7 ++++--- crates/paint/src/pressure_toggle_override_tests.rs | 13 +++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/crates/paint/src/dynamics.rs b/crates/paint/src/dynamics.rs index 9a9db6bd6bb..4a93860f460 100644 --- a/crates/paint/src/dynamics.rs +++ b/crates/paint/src/dynamics.rs @@ -737,9 +737,10 @@ impl DabBuilder { let (mut opacity, mut flow) = (1.0, b.flow); if tr.enabled { // Pressure for Opacity overrides the preset's Opacity Control and its Minimum - // (#17766); the Opacity Jitter still applies. - opacity = if b.pressure_opacity { - scalar(&Dynamic { control: Control::Off, ..tr.opacity.clone() }, s, r(stream::OPACITY)) + // (#17766); the Opacity Jitter still applies. With the control Off the preset is + // read as before. + opacity = if b.pressure_opacity && tr.opacity.control != Control::Off { + scalar(&Dynamic { control: Control::Off, minimum: 0.0, ..tr.opacity.clone() }, s, r(stream::OPACITY)) } else { scalar(&tr.opacity, s, r(stream::OPACITY)) }; diff --git a/crates/paint/src/pressure_toggle_override_tests.rs b/crates/paint/src/pressure_toggle_override_tests.rs index 7f9c517c0ce..032651bea51 100644 --- a/crates/paint/src/pressure_toggle_override_tests.rs +++ b/crates/paint/src/pressure_toggle_override_tests.rs @@ -91,3 +91,16 @@ fn mouse_strokes_keep_full_size_and_opacity() { let d: Vec = dabs(&Stroke { brush: b, points: points.to_vec() }).iter().map(|d| 2.0 * d.radius).collect(); assert!(d.iter().all(|d| (*d - 41.0).abs() < 0.01), "a mouse stroke keeps the full 41 px: {:?}", &d[..d.len().min(6)]); } + +#[test] +fn opacity_jitter_still_varies_the_overridden_opacity() { + // A Minimum of 100 % would pin every dab at full opacity; with the toggle on it is ignored, + // so the preset's Opacity Jitter still varies the dabs below the pen's pressure. + let mut b = pencil(); + b.transfer = Transfer { enabled: true, opacity: Dynamic { jitter: 1.0, ..controlled(Control::PenPressure, 1.0) }, ..Default::default() }; + b.pressure_opacity = true; + let points = [StrokePoint::new(50.0, 100.0, 0.5), StrokePoint::new(450.0, 100.0, 0.5)]; + let opacities: Vec = dabs(&Stroke { brush: b, points: points.to_vec() }).iter().map(|d| d.opacity).collect(); + assert!(opacities.iter().all(|o| *o <= 0.5 + 1e-6), "never above the pressure: {:?}", &opacities[..opacities.len().min(8)]); + assert!(opacities.iter().any(|o| *o < 0.45), "the jitter varies them: {:?}", &opacities[..opacities.len().min(8)]); +}