mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibGfx: Add String variants of Color::to_string*()
This commit is contained in:
parent
6aff55d655
commit
6c9fffc4c1
Notes:
sideshowbarker
2024-07-16 22:34:39 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/6c9fffc4c1 Pull-request: https://github.com/SerenityOS/serenity/pull/21997 Reviewed-by: https://github.com/AtkinsSJ ✅
2 changed files with 15 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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<Color> from_string(StringView);
|
||||
|
|
Loading…
Reference in a new issue