mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
improved encoding for formating
This commit is contained in:
@@ -174,13 +174,30 @@ struct std::formatter<omath::Color> // NOLINT(*-dcl58-cpp)
|
||||
{
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
template<class FormatContext>
|
||||
[[nodiscard]]
|
||||
static auto format(const omath::Color& col, std::format_context& ctx)
|
||||
static auto format(const omath::Color& col, FormatContext& ctx)
|
||||
{
|
||||
return std::format_to(ctx.out(), "[r:{}, g:{}, b:{}, a:{}]",
|
||||
static_cast<int>(col.x * 255.f),
|
||||
static_cast<int>(col.y * 255.f),
|
||||
static_cast<int>(col.z * 255.f),
|
||||
static_cast<int>(col.w * 255.f));
|
||||
if constexpr (std::is_same_v<std::format_context::char_type, char>)
|
||||
return std::format_to(ctx.out(), "[r:{}, g:{}, b:{}, a:{}]",
|
||||
static_cast<int>(col.x * 255.f),
|
||||
static_cast<int>(col.y * 255.f),
|
||||
static_cast<int>(col.z * 255.f),
|
||||
static_cast<int>(col.w * 255.f));
|
||||
if constexpr (std::is_same_v<std::format_context::char_type, wchar_t>)
|
||||
return std::format_to(ctx.out(), L"[r:{}, g:{}, b:{}, a:{}]",
|
||||
static_cast<int>(col.x * 255.f),
|
||||
static_cast<int>(col.y * 255.f),
|
||||
static_cast<int>(col.z * 255.f),
|
||||
static_cast<int>(col.w * 255.f));
|
||||
|
||||
if constexpr (std::is_same_v<std::format_context::char_type, char8_t>)
|
||||
return std::format_to(ctx.out(), u8"[r:{}, g:{}, b:{}, a:{}]",
|
||||
static_cast<int>(col.x * 255.f),
|
||||
static_cast<int>(col.y * 255.f),
|
||||
static_cast<int>(col.z * 255.f),
|
||||
static_cast<int>(col.w * 255.f));
|
||||
std::unreachable();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user