mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
New nodes: RGBA to Color, HSVA to Color, Hex to Color, and Read Gradient (#3838)
* New nodes: RGBA to Color, HSVA to Color, Hex to Color, and Read Gradient * Simplify
This commit is contained in:
@@ -297,15 +297,12 @@ impl TaggedValue {
|
||||
fn to_color(input: &str) -> Option<Color> {
|
||||
// String syntax (e.g. "000000ff")
|
||||
if input.starts_with('"') && input.ends_with('"') {
|
||||
let color = input.trim().trim_matches('"').trim().trim_start_matches('#');
|
||||
match color.len() {
|
||||
6 => return Color::from_rgb_str(color),
|
||||
8 => return Color::from_rgba_str(color),
|
||||
_ => {
|
||||
log::error!("Invalid default value color string: {input}");
|
||||
return None;
|
||||
}
|
||||
let hex = input.trim().trim_matches('"').trim().trim_start_matches('#');
|
||||
let color = Color::from_hex_str(hex);
|
||||
if color.is_none() {
|
||||
log::error!("Invalid default value color string: {input}");
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
// Color constant syntax (e.g. Color::BLACK)
|
||||
|
||||
Reference in New Issue
Block a user