This commit is contained in:
Moritz Ruth 2024-02-01 16:21:53 +01:00
parent b5a7ab3c6b
commit ebb0552a13
Signed by: moritzruth
GPG key ID: C9BBAB79405EE56D
9 changed files with 186 additions and 36 deletions

View file

@ -24,7 +24,7 @@ fn parse_rgb8_from_hex_str(s: &str) -> Result<RGB8, ParsingError> {
}
fn fmt_rgb8_as_hex_string(v: &RGB8, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!("{:#04x}{:#04x}{:#04x}", v.r, v.g, v.b))
f.write_fmt(format_args!("#{:02x}{:02x}{:02x}", v.r, v.g, v.b))
}
fn parse_rgba8_from_hex_str(s: &str) -> Result<RGBA8, ParsingError> {
@ -42,7 +42,7 @@ fn parse_rgba8_from_hex_str(s: &str) -> Result<RGBA8, ParsingError> {
}
fn fmt_rgba8_as_hex_string(v: &RGBA8, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!("{:#04x}{:#04x}{:#04x}{:#04x}", v.r, v.g, v.b, v.a))
f.write_fmt(format_args!("#{:02x}{:02x}{:02x}{:02x}", v.r, v.g, v.b, v.a))
}
fn parse_rgb8_with_optional_alpha_from_hex_str(s: &str, fallback_alpha: u8) -> Result<RGBA8, ParsingError> {