mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-26 02:37:01 -06:00
Merge pull request #3682 from Taha-Mahmoodi/fix/dither-stroke-null-swatch
Gradients: paint.setStroke refuses a dithered gradient when "swatch" is null
This commit is contained in:
@@ -403,8 +403,9 @@ fn set_paint(s: &mut Session, p: &Value, fill: bool) -> Result<Value> {
|
||||
}
|
||||
check_keep_model(p, cmd)?;
|
||||
let paint = paint_from(s, p)?.ok_or_else(|| bad(cmd, "give color, none, swatch or gradient"))?;
|
||||
// As `paint.editGradient`: a `dither` given applies to gradient fills only.
|
||||
if !fill && matches!(&paint, Paint::Gradient(g) if g.gradient.dither) && p.get("swatch").is_none() {
|
||||
// As `paint.editGradient`: a `dither` given applies to gradient fills only. A gradient swatch
|
||||
// (named) keeps its own dither; `"swatch": null` names none.
|
||||
if !fill && matches!(&paint, Paint::Gradient(g) if g.gradient.dither) && p.get("swatch").and_then(Value::as_str).is_none() {
|
||||
return Err(bad(cmd, "`dither` applies to gradient fills (paint.setFill)"));
|
||||
}
|
||||
apply_paint(s, p, paint, fill)
|
||||
|
||||
@@ -441,6 +441,7 @@ fn dither_is_a_fill_gradient_option_that_saves_and_loads() {
|
||||
let before = node(&s, id).appearance.clone();
|
||||
assert!(s.execute("paint.editGradient", &json!({"dither": true, "stroke": true})).is_err());
|
||||
assert!(s.execute("paint.setStroke", &json!({"gradient": {"dither": true}})).is_err());
|
||||
assert!(s.execute("paint.setStroke", &json!({"swatch": null, "gradient": {"dither": true}})).is_err(), "a null swatch names none");
|
||||
assert!(s.execute("paint.editGradient", &json!({"dither": "yes"})).is_err());
|
||||
assert!(s.execute("paint.setFill", &json!({"gradient": {"dither": 1}})).is_err());
|
||||
assert_eq!(node(&s, id).appearance, before);
|
||||
|
||||
Reference in New Issue
Block a user