Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

Symbol Stainer: stained type keeps no link to a global swatch

dotCooCooab821a776bcc
diff --git a/crates/brush/src/colorize.rs b/crates/brush/src/colorize.rs
index 80d302b66..9ef049f86 100644
--- a/crates/brush/src/colorize.rs
+++ b/crates/brush/src/colorize.rs
@@ -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));
}
}
}
diff --git a/crates/brush/src/tests.rs b/crates/brush/src/tests.rs
index 8c04e102b..5a665809f 100644
--- a/crates/brush/src/tests.rs
+++ b/crates/brush/src/tests.rs
@@ -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]