1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 06:04:57 +00:00

LibGfx: Add formatters for Gfx::Color's different representations

This makes debugging these values a bit easier
This commit is contained in:
Matthew Olsson 2024-03-02 13:42:16 -07:00 committed by Alexander Kalenik
parent 1f88ca2a03
commit 29b70485fc
2 changed files with 30 additions and 0 deletions

View file

@ -375,3 +375,18 @@ ErrorOr<void> AK::Formatter<Gfx::Color>::format(FormatBuilder& builder, Gfx::Col
{
return Formatter<StringView>::format(builder, value.to_byte_string());
}
ErrorOr<void> AK::Formatter<Gfx::YUV>::format(FormatBuilder& builder, Gfx::YUV value)
{
return Formatter<FormatString>::format(builder, "{} {} {}"sv, value.y, value.u, value.v);
}
ErrorOr<void> AK::Formatter<Gfx::HSV>::format(FormatBuilder& builder, Gfx::HSV value)
{
return Formatter<FormatString>::format(builder, "{} {} {}"sv, value.hue, value.saturation, value.value);
}
ErrorOr<void> AK::Formatter<Gfx::Oklab>::format(FormatBuilder& builder, Gfx::Oklab value)
{
return Formatter<FormatString>::format(builder, "{} {} {}"sv, value.L, value.a, value.b);
}

View file

@ -626,6 +626,21 @@ struct Formatter<Gfx::Color> : public Formatter<StringView> {
ErrorOr<void> format(FormatBuilder&, Gfx::Color);
};
template<>
struct Formatter<Gfx::YUV> : public Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder&, Gfx::YUV);
};
template<>
struct Formatter<Gfx::HSV> : public Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder&, Gfx::HSV);
};
template<>
struct Formatter<Gfx::Oklab> : public Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder&, Gfx::Oklab);
};
}
namespace IPC {