Symbolism: the Symbol Styler applies the style by the brush's strength

Without Shift, the Symbol Styler gave each instance under the brush the
style in full (and Random a fixed share of it), whatever the intensity,
the pen pressure or the instance's distance from the brush's center. It
now applies the style gradually, as it does the stain: by the brush's
strength at the instance, in full only at the center at intensity 10 or
full pressure. Random gives each instance its share of that amount.
This commit is contained in:
dotCooCoo
2026-11-15 21:55:27 -08:00
parent 11942b04d6
commit 0e1592d76a
3 changed files with 36 additions and 5 deletions
+4 -2
View File
@@ -1265,9 +1265,11 @@ pub(super) fn symbol_adjust(s: &mut Session, p: &Value) -> Result<Value> {
continue;
}
let cur = n.appearance.fill().filter(|f| f.paint == paint).map(|f| f.opacity).unwrap_or(0.0);
// The style goes on gradually, by the brush's strength there: in
// full at the center at full intensity or pressure.
let step = match (tool.as_str(), method) {
("style", Method::Random) => (share / 2.0) as f32,
("style", _) => 1.0,
("style", Method::Random) => (w * share / 2.0) as f32,
("style", _) => w as f32,
_ => (0.15 * w * share) as f32,
};
(paint, if alt { cur - step } else { cur + step })
@@ -666,3 +666,31 @@ fn set_density_refuses_bad_densities_and_objects_without_a_set() {
assert!(matches!(&r, Err(EngineError::Other(msg)) if msg == "no symbol set selected"), "{r:?}");
assert!(state(&s) == before);
}
/// The Symbol Styler applies the style gradually, by the brush's strength at the instance: the pen
/// pressure with Use Pressure Pen, else the intensity, less toward the brush's edge. Random gives
/// each instance a share of that amount.
#[test]
fn the_styler_applies_the_style_by_the_brushs_strength() {
let styled = |extra: Value, x: f64| {
let mut s = session();
let a = dot(&mut s, 100.0, 150.0);
let id = s.execute("shape.rectangle", &json!({"x": 300, "y": 250, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap();
s.execute("paint.setFill", &json!({"color": "#0000ff"})).unwrap();
s.execute("graphicStyle.new", &json!({"name": "Blue", "id": id})).unwrap();
s.select(|_, sel| sel.clear()).unwrap();
let mut p = json!({"tool": "style", "points": [[x, 150]], "radius": 10, "style": "Blue"});
p.as_object_mut().unwrap().extend(extra.as_object().unwrap().clone());
adjust(&mut s, p);
node(&s, a).appearance.fill().map_or(0.0, |f| f.opacity)
};
let near = |a: f32, b: f32| (a - b).abs() < 1e-6;
assert!(near(styled(json!({"intensity": 10}), 100.0), 1.0), "full strength at the center");
assert!(near(styled(json!({"intensity": 5}), 100.0), 0.5));
assert!(near(styled(json!({"intensity": 10}), 105.0), 0.5), "half way to the edge");
assert!(near(styled(json!({"usePressure": true, "points": [[100, 150, 0.25]]}), 100.0), 0.25));
assert!(near(styled(json!({"usePressure": true, "points": [[100, 150, 1.0]]}), 100.0), 1.0));
assert_eq!(styled(json!({"usePressure": true, "points": [[100, 150, 0.0]]}), 100.0), 0.0, "no pressure, no style");
let random = styled(json!({"usePressure": true, "points": [[100, 150, 0.25]], "method": "random"}), 100.0);
assert!(random <= 0.25 + 1e-6, "{random}");
}
+4 -3
View File
@@ -3417,9 +3417,10 @@ already walks Image Trace. Short agent entry points:
[the archived manual](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=118)):
`symbol.adjust` takes `method` (`userDefined`, `average` or `random`; not used by `shift`), `usePressure` with
`points` as `[x, y, pressure]` (each point's pen pressure, 0..1, is the intensity there), and for `size`
`proportional` (true) and `affectsDensity` (false). With `tool: style`, a `style` name the document has no graphic style
for counts as none (the document's first style after the default one). The Symbol Styler sends the style last
clicked into the Graphic Styles panel's selection. `tool.setOption` on a symbolism tool refuses a `method` or
`proportional` (true) and `affectsDensity` (false). With `tool: style`, the style goes on by the brush's strength at
each instance, in full only at the brush's center at intensity 10 or full pressure, and a `style` name the document
has no graphic style for counts as none (the document's first style after the default one). The Symbol Styler sends
the style last clicked into the Graphic Styles panel's selection. `tool.setOption` on a symbolism tool refuses a `method` or
Symbol Sprayer option that is not one of its names, a non-number `diameter`, `intensity` or `density`, a
non-boolean switch, and a `symbol` or `style` that is neither a name nor null, and sets none of the values.
`symbol.spray` takes `attributes`