mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 02:48:12 +08:00
Add a "Use Tint" toggle to the 'Black & White' node and give its tint the Luminosity blend's clipping (#4540)
* Add a 'Use Tint' toggle to the 'Black & White' node and give its tint the Luminosity blend's clipping * Fix the Black & White migration for a wired tint and gray out the tint when unused
This commit is contained in:
@@ -644,9 +644,8 @@ impl TaggedValue {
|
||||
});
|
||||
}
|
||||
|
||||
// Hex syntax (e.g. "000000ff"), which a string literal default reaches here without its quotes
|
||||
let hex = input.trim().trim_matches('"').trim().trim_start_matches('#');
|
||||
let color = SRGBA8::from_hex_str(hex).map(Color::from);
|
||||
// Hex syntax (e.g. "#1cd1ad", or "#1cd1ad70" with alpha), which a string literal default reaches here without its quotes
|
||||
let color = input.trim().trim_matches('"').trim().strip_prefix('#').and_then(SRGBA8::from_hex_str).map(Color::from);
|
||||
if color.is_none() {
|
||||
log::error!("Invalid default value color string: {input}");
|
||||
}
|
||||
@@ -654,7 +653,7 @@ impl TaggedValue {
|
||||
}
|
||||
|
||||
fn to_gradient(input: &str) -> Option<Gradient> {
|
||||
// String syntax: (e.g. "000000ff, ff0000ff")
|
||||
// String syntax: (e.g. "#000000ff, #ff0000ff")
|
||||
let stops = input.split(',').filter_map(|s| to_color(s.trim())).collect::<Vec<_>>();
|
||||
match stops.len() {
|
||||
0 => {
|
||||
@@ -1039,16 +1038,17 @@ mod paint_default_parsing {
|
||||
);
|
||||
}
|
||||
|
||||
/// A hex string default reaches the parser without the quotes its literal had in the node signature, and must still parse.
|
||||
/// A hex string default reaches the parser without the quotes its literal had in the node signature, and must carry its hash prefix.
|
||||
#[test]
|
||||
fn hex_string_color_default_parses_without_quotes() {
|
||||
fn hex_string_color_default_requires_its_hash_prefix() {
|
||||
let tint = Some(TaggedValue::Color(Color::from(SRGBA8::new(225, 211, 179, 255))));
|
||||
assert_eq!(TaggedValue::from_primitive_string("e1d3b3", &item!(Color)), tint, "a bare hex default should resolve");
|
||||
assert_eq!(
|
||||
TaggedValue::from_primitive_string("\"#e1d3b3\"", &item!(Color)),
|
||||
tint,
|
||||
"a quoted, hash-prefixed hex default should resolve"
|
||||
);
|
||||
assert_eq!(TaggedValue::from_primitive_string("#e1d3b3ff", &item!(Color)), tint, "an alpha-suffixed hex default should resolve");
|
||||
assert_eq!(TaggedValue::from_primitive_string("e1d3b3", &item!(Color)), None, "a bare hex default should be rejected");
|
||||
}
|
||||
|
||||
/// Table-era documents stored the red-slash "no paint" fill as an empty color table, which must keep
|
||||
|
||||
Reference in New Issue
Block a user