Additional tests of hex-conversions.

This commit is contained in:
2025-06-04 13:12:08 -05:00
parent 25d804ce79
commit 42e773b5a1

View File

@@ -5,6 +5,11 @@
#include <Color4.hpp> #include <Color4.hpp>
#include <Colors.hpp> #include <Colors.hpp>
std::string fmt_color(const Color4& c)
{
return std::format("{}hue:{} rgb: {},{},{} hex: {}", c.ToEscapeCode(), c.ToHSV().h, c.r, c.g, c.b, c.ToHex());
}
int main() int main()
{ {
#ifdef WIN32 #ifdef WIN32
@@ -21,6 +26,11 @@ int main()
mcolor::printAnsiColorTable(); mcolor::printAnsiColorTable();
mcolor::printRGBConsoleTest(); mcolor::printRGBConsoleTest();
std::cout << "Color construction from hex codes:" << std::endl;
std::cout << fmt_color(Color4::FromHex("#FFFFFF")) << std::endl;
std::cout << fmt_color(Color4::FromHex("#F0F0F0")) << std::endl;
std::cout << fmt_color(Color4::FromHex("#0F0F0F")) << std::endl;
std::cout << fmt_color(Color4::FromHex("#00AAFF")) << std::endl;
for (float i = 0; i < 360; i+=10.f) for (float i = 0; i < 360; i+=10.f)
{ {
@@ -28,7 +38,7 @@ int main()
Color4 c = Color4(hsva); Color4 c = Color4(hsva);
std::cout << std::format("{}hue:{} rgb: {},{},{}", toEscapeCode(c), i, c.r, c.g, c.b) << std::endl; std::cout << std::format("{}hue:{} rgb: {},{},{} hex: {}", c.ToEscapeCode(), i, c.r, c.g, c.b, c.ToHex()) << std::endl;
} }
return 0; return 0;