Add initial token theming.

This commit is contained in:
jmsgrogan 2023-01-17 13:01:59 +00:00
parent 3d37a7244b
commit 1f85954e98
34 changed files with 406 additions and 253 deletions

View file

@ -9,6 +9,26 @@ Color::Color(unsigned char r, unsigned char g, unsigned char b, double a)
}
Color::Color(const std::string& hexString)
{
if (hexString.size() < 7)
{
return;
}
if (hexString[0] != '#')
{
return;
}
mR = toDecimal(hexString.substr(1, 2));
mG = toDecimal(hexString.substr(3, 2));
mB = toDecimal(hexString.substr(5, 2));
}
unsigned char Color::toDecimal(const std::string& hex) const
{
return static_cast<unsigned char>(std::stoul("0x" + hex, nullptr, 16));
}
std::unique_ptr<Color> Color::Create(unsigned char r, unsigned char g, unsigned char b, double a )
{
return std::make_unique<Color>(r, g, b, a);

View file

@ -7,6 +7,8 @@
class Color
{
public:
Color(const std::string& hexString);
Color(unsigned char r = 0, unsigned char g = 0, unsigned char b = 0, double a = 1.0);
static std::unique_ptr<Color> Create(unsigned char r, unsigned char g, unsigned char b, double a = 1.0);
@ -37,6 +39,8 @@ public:
}
private:
unsigned char toDecimal(const std::string& hex) const;
unsigned char mR{0};
unsigned char mG{0};
unsigned char mB{0};