mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
Pressure for Opacity also drops the preset's opacity Minimum, keeps its jitter
This commit is contained in:
1 parent
c2b8313335
commit
304330205f
2 files changed
+17
-3
No files matched your search
@@ -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))
|
||||
};
|
||||
|
||||
@@ -91,3 +91,16 @@ fn mouse_strokes_keep_full_size_and_opacity() {
|
||||
let d: Vec<f32> = 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<f32> = 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)]);
|
||||
}
|
||||
Reference in new issue
Block a user