diff --git a/crates/engine/src/cmd/brushsym/symbols.rs b/crates/engine/src/cmd/brushsym/symbols.rs index d9183d0169..4338da1bf5 100644 --- a/crates/engine/src/cmd/brushsym/symbols.rs +++ b/crates/engine/src/cmd/brushsym/symbols.rs @@ -1008,7 +1008,7 @@ pub(super) fn symbol_spray(s: &mut Session, p: &Value) -> Result { if modes.screen && let Some(m) = near { - n.opacity = (m.opacity as f32).clamp(0.05, 1.0); + n.opacity = (m.opacity as f32).clamp(0.0, 1.0); } // The stain and the style are both the instance's fill: the style, set last, replaces // the stain, an averaged one too when the instances under the brush have a fill. @@ -1254,7 +1254,8 @@ pub(super) fn symbol_adjust(s: &mut Session, p: &Value) -> Result { _ => { let step = (0.1 * w * share) as f32; n.opacity = match &avg { - Some((t, _)) => (n.opacity + ((t.opacity - f64::from(n.opacity)) * w.min(1.0)) as f32).clamp(0.05, 1.0), + // The mean may be below the 5% the Screener otherwise stops at. + Some((t, _)) => (n.opacity + ((t.opacity - f64::from(n.opacity)) * w.min(1.0)) as f32).clamp(0.0, 1.0), None if alt => (n.opacity + step).min(1.0), None => (n.opacity - step).max(0.05), }; diff --git a/crates/engine/src/tests/symbolism_options.rs b/crates/engine/src/tests/symbolism_options.rs index 9fa03745ed..65ce6f8242 100644 --- a/crates/engine/src/tests/symbolism_options.rs +++ b/crates/engine/src/tests/symbolism_options.rs @@ -119,6 +119,30 @@ fn average_brings_the_instances_under_the_brush_toward_their_mean() { assert!(pa > oa && pb < 1.0 && (pa - pb).abs() < (1.0 - oa) / 2.0, "{pa} {pb} from {oa}"); } +/// Average opacities below the Symbol Screener's least opacity (5%) stay below it: with the Screener +/// the instances meet at their mean, and a sprayed instance takes the mean of those under the brush. +#[test] +fn average_keeps_opacities_below_the_screeners_least() { + let mut s = session(); + let set = NodeId(s.execute("symbol.spray", &json!({"name": "Dot", "points": [[200, 150]], "radius": 4})).unwrap()["id"].as_u64().unwrap()); + let a = members(&s, set)[0]; + let b = dot(&mut s, 220.0, 150.0); + for (id, opacity) in [(a, 0), (b, 2)] { + s.select(|_, sel| sel.set([id])).unwrap(); + s.execute("transparency.set", &json!({"opacity": opacity})).unwrap(); + } + s.select(|_, sel| sel.set([set])).unwrap(); + // A new instance beside the invisible one takes its opacity. + s.execute("symbol.spray", &json!({"name": "Dot", "points": [[185, 150]], "radius": 20})).unwrap(); + let sprayed = *members(&s, set).last().unwrap(); + assert_eq!(node(&s, sprayed).opacity, 0.0); + // The Screener with Average brings 0% and 2% toward 1%, not up to 5%. + s.select(|_, sel| sel.clear()).unwrap(); + adjust(&mut s, json!({"tool": "screen", "points": [[210, 150]], "radius": 40, "intensity": 10, "method": "average"})); + let (pa, pb) = (node(&s, a).opacity, node(&s, b).opacity); + assert!(pa > 0.0 && pa < 0.02 && pb < 0.02 && pb > 0.0, "{pa} {pb}"); +} + /// Average over instances that already have the mean, or a stroke over no instance, changes /// nothing and adds no undo step. #[test] diff --git a/docs/mcp.md b/docs/mcp.md index 869c228683..209069983b 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3427,7 +3427,10 @@ already walks Image Trace. Short agent entry points: Scruncher its distance from their middle toward their mean distance, the Sizer the geometric mean of their sizes, the Spinner their mean direction, the Stainer and the Styler their mean amount, the Screener their mean opacity. `alt` does not reverse it. An instance already at the mean is left as it is, and no undo step is added when - no instance changes. + no instance changes. The Screener's average, and the opacity a sprayed instance takes as its average, can be + below the 5% that the Screener otherwise stops at. + - With `userDefined` the Styler gives each instance under the brush the whole style, whatever the intensity or the + pen pressure; `random` scales each instance's share by the brush strength there. - With `proportional` false a drag resizes along its own direction (a level drag the width, an upright one the height) and one point resizes both. With `affectsDensity` an instance also moves away from the point as it grows and toward it as it shrinks.