diff --git a/Userland/Libraries/LibGfx/Color.cpp b/Userland/Libraries/LibGfx/Color.cpp index 4bdf4fdcad..5c538aa368 100644 --- a/Userland/Libraries/LibGfx/Color.cpp +++ b/Userland/Libraries/LibGfx/Color.cpp @@ -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 parse_rgb_color(StringView string) diff --git a/Userland/Libraries/LibGfx/Color.h b/Userland/Libraries/LibGfx/Color.h index b26c00a7d2..d0526bdb26 100644 --- a/Userland/Libraries/LibGfx/Color.h +++ b/Userland/Libraries/LibGfx/Color.h @@ -356,6 +356,9 @@ public: return m_value == other.m_value; } + String to_string() const; + String to_string_without_alpha() const; + DeprecatedString to_deprecated_string() const; DeprecatedString to_deprecated_string_without_alpha() const; static Optional from_string(StringView);