diff options
author | crupest <crupest@outlook.com> | 2021-05-10 20:06:05 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-05-10 20:06:05 +0800 |
commit | 704289ff1f487989138e85ebe8a77e92cdf30e14 (patch) | |
tree | 9585ef1147159df3d28717b35177a9b95ac8528a /src/platform/Color.cpp | |
parent | 32e7c37fdf831de5b3c7f2acbbadd697989f0fab (diff) | |
download | cru-704289ff1f487989138e85ebe8a77e92cdf30e14.tar.gz cru-704289ff1f487989138e85ebe8a77e92cdf30e14.tar.bz2 cru-704289ff1f487989138e85ebe8a77e92cdf30e14.zip |
...
Diffstat (limited to 'src/platform/Color.cpp')
-rw-r--r-- | src/platform/Color.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
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> Color::Parse(std::u16string_view string, gsl::narrow_cast<std::uint8_t>(*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<std::uint8_t>(*r), gsl::narrow_cast<std::uint8_t>(*g), gsl::narrow_cast<std::uint8_t>(*b), gsl::narrow_cast<std::uint8_t>(*a)); |