mirror of
https://github.com/WerWolv/ImHex-Patterns.git
synced 2026-03-27 23:37:04 -05:00
includes/type: Added new color types
This commit is contained in:
43
includes/type/color.pat
Normal file
43
includes/type/color.pat
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <std/io.pat>
|
||||
|
||||
namespace type {
|
||||
|
||||
struct RGBA8 {
|
||||
u8 r, g, b, a;
|
||||
} [[sealed, format("type::impl::format_color")]];
|
||||
|
||||
bitfield RGB565 {
|
||||
r : 5;
|
||||
g : 6;
|
||||
b : 5;
|
||||
} [[sealed, format("type::impl::format_color")]];
|
||||
|
||||
bitfield RGBA4 {
|
||||
r : 4;
|
||||
g : 4;
|
||||
b : 4;
|
||||
a : 4;
|
||||
} [[sealed, format("type::impl::format_color")]];
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_color(ref auto color) {
|
||||
if (!std::core::has_member(color, "a")) {
|
||||
return std::format("#{0:02X}{1:02X}{2:02X} | rgb({0}, {1}, {2})",
|
||||
color.r,
|
||||
color.g,
|
||||
color.b);
|
||||
} else {
|
||||
return std::format("#{0:02X}{1:02X}{2:02X}{3:02X} | rgba({0}, {1}, {2}, {3})",
|
||||
color.r,
|
||||
color.g,
|
||||
color.b,
|
||||
color.a);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user