mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-26 10:47:11 -06:00
Symbol Stainer: stained type keeps no link to a global swatch
The Symbol Stainer mixed the color of type characters painted with a global swatch but kept the swatch name and tint, so the characters' paint named a swatch whose color it no longer had, and a later edit of the swatch could put the unstained color back. Their fill and stroke now become plain colors, as a path's paint does.
This commit is contained in:
@@ -119,7 +119,7 @@ pub fn tint_node(n: &mut Node, color: &Color, amount: f32) {
|
||||
for r in &mut t.runs {
|
||||
for p in [&mut r.style.fill, &mut r.style.stroke] {
|
||||
if let Paint::Solid { color: c, .. } = p {
|
||||
*c = c.lerp(color, amount);
|
||||
*p = Paint::solid(c.lerp(color, amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,6 +363,12 @@ fn stain_mixes_type_strokes_too() {
|
||||
let mut art = type_art(red.clone(), red);
|
||||
tint_node(&mut art, &blue, 1.0);
|
||||
assert_eq!(run_paints(&[art]), [(Paint::solid(blue), Paint::solid(blue))]);
|
||||
// Characters painted with a global swatch lose the link, as a path's paint does: the mixed color
|
||||
// is not the swatch's color.
|
||||
let linked = Paint::Solid { color: Color::rgb(1.0, 0.0, 0.0), swatch: Some("Red".into()), tint: 0.5 };
|
||||
let mut art = type_art(linked.clone(), linked);
|
||||
tint_node(&mut art, &blue, 1.0);
|
||||
assert_eq!(run_paints(&[art]), [(Paint::solid(blue), Paint::solid(blue))]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user