From 704289ff1f487989138e85ebe8a77e92cdf30e14 Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 10 May 2021 20:06:05 +0800 Subject: ... --- src/platform/Color.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/platform/Color.cpp') diff --git a/src/platform/Color.cpp b/src/platform/Color.cpp index d1c60217..fe512715 100644 --- a/src/platform/Color.cpp +++ b/src/platform/Color.cpp @@ -19,10 +19,10 @@ std::string Color::ToUtf8String() const { }; std::string result = "#"; - result.append(to_two_hex_digit(alpha)); result.append(to_two_hex_digit(red)); result.append(to_two_hex_digit(green)); result.append(to_two_hex_digit(blue)); + result.append(to_two_hex_digit(alpha)); return result; } @@ -36,10 +36,10 @@ std::u16string Color::ToString() const { }; std::u16string result = u"#"; - result.append(to_two_hex_digit(alpha)); result.append(to_two_hex_digit(red)); result.append(to_two_hex_digit(green)); result.append(to_two_hex_digit(blue)); + result.append(to_two_hex_digit(alpha)); return result; } @@ -86,14 +86,14 @@ std::optional Color::Parse(std::u16string_view string, gsl::narrow_cast(*b)); } else if (string_size == 9) { if (string[0] != u'#') return std::nullopt; - auto a = get_num_for_two_digit(string.substr(1, 2)); - if (!a) return std::nullopt; - auto r = get_num_for_two_digit(string.substr(3, 2)); + auto r = get_num_for_two_digit(string.substr(1, 2)); if (!r) return std::nullopt; - auto g = get_num_for_two_digit(string.substr(5, 2)); + auto g = get_num_for_two_digit(string.substr(3, 2)); if (!g) return std::nullopt; - auto b = get_num_for_two_digit(string.substr(7, 2)); + auto b = get_num_for_two_digit(string.substr(5, 2)); if (!b) return std::nullopt; + auto a = get_num_for_two_digit(string.substr(7, 2)); + if (!a) return std::nullopt; return Color( gsl::narrow_cast(*r), gsl::narrow_cast(*g), gsl::narrow_cast(*b), gsl::narrow_cast(*a)); -- cgit v1.2.3