1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 00:27:43 +00:00

LibGfx: Add String variants of Color::to_string*()

This commit is contained in:
Shannon Booth 2023-11-20 20:31:39 +13:00 committed by Andreas Kling
parent 6aff55d655
commit 6c9fffc4c1
2 changed files with 15 additions and 2 deletions

View file

@ -18,14 +18,24 @@
namespace Gfx {
String Color::to_string() const
{
return MUST(String::formatted("#{:02x}{:02x}{:02x}{:02x}", red(), green(), blue(), alpha()));
}
String Color::to_string_without_alpha() const
{
return MUST(String::formatted("#{:02x}{:02x}{:02x}", red(), green(), blue()));
}
DeprecatedString Color::to_deprecated_string() const
{
return DeprecatedString::formatted("#{:02x}{:02x}{:02x}{:02x}", red(), green(), blue(), alpha());
return to_string().to_deprecated_string();
}
DeprecatedString Color::to_deprecated_string_without_alpha() const
{
return DeprecatedString::formatted("#{:02x}{:02x}{:02x}", red(), green(), blue());
return to_string_without_alpha().to_deprecated_string();
}
static Optional<Color> parse_rgb_color(StringView string)