UI-1675: Preserve symbol tint when expanding effects

This commit is contained in:
dotCooCoo
2026-11-05 05:52:34 +07:00
committed by bflatastic
parent 632cb9d649
commit dcefceddf6
2 changed files with 24 additions and 1 deletions
+23
View File
@@ -52,6 +52,29 @@ fn expandable(s: &Session) -> bool {
s.commands().iter().find(|c| c.id == "effect.expandAppearance").unwrap().enabled
}
#[test]
fn symbol_instance_tint_survives_expanding_an_object_effect() {
let mut s = session();
square(&mut s);
let id = NodeId(run(&mut s, "symbol.new", json!({"name": "Tinted Square"}))["id"].as_u64().unwrap());
run(&mut s, "appearance.addFill", json!({"ids": [id.0]}));
let fill = node(&s, id).appearance.items.len() - 1;
run(&mut s, "appearance.setItem", json!({"ids": [id.0], "index": fill, "color": "#00ff00", "opacity": 50}));
run(&mut s, "effect.apply", json!({"ids": [id.0], "item": null, "effect": "path.offsetPath", "params": {"offset": 6}}));
assert!(matches!(node(&s, id).kind, NodeKind::SymbolInstance { .. }));
let before = render(&s);
assert_ne!(before.pixel(100, 100), [255, 255, 255, 255], "the symbol is visible");
assert_ne!(before.pixel(100, 100), [255, 0, 0, 255], "the instance fill tints the red symbol art");
assert!(expandable(&s));
run(&mut s, "effect.expandAppearance", json!({}));
let n = node(&s, id);
assert!(!matches!(n.kind, NodeKind::SymbolInstance { .. }));
n.walk(&mut |part| assert!(part.appearance.effects.is_empty()));
let after = render(&s);
assert!(differing(&before, &after, 8) < 200, "expanding changed {} pixels", differing(&before, &after, 8));
}
#[test]
fn two_fills_and_an_offset_stroke_become_three_paths_that_look_the_same() {
let mut s = session();