Implement Color3::FromHex()
This commit is contained in:
@@ -16,4 +16,10 @@ namespace JGL
|
||||
float Color3::GreenChannelNormalized() const { return static_cast<float>(g) / 255.f;}
|
||||
|
||||
Color3::Color3(u8 R, u8 G, u8 B) : r(R), g(G), b(B) {}
|
||||
|
||||
Color3 Color3::FromHex(const std::string &hexCode) {
|
||||
u8 r, g, b;
|
||||
std::sscanf(hexCode.c_str(), "#%02x%02x%02x", &r, &g, &b);
|
||||
return {r, g, b};
|
||||
}
|
||||
}
|
@@ -24,4 +24,9 @@ namespace JGL
|
||||
float Color4::BlueChannelNormalized() const {return static_cast<float>(b/255.f); }
|
||||
|
||||
float Color4::AlphaChannelNormalized() const {return static_cast<float>(a/255.f); }
|
||||
JGL::Color4 JGL::Color4::FromHex(const std::string &hexCode, u8 alpha) {
|
||||
u8 r, g, b;
|
||||
std::sscanf(hexCode.c_str(), "#%02x%02x%02x", &r, &g, &b);
|
||||
return {r, g, b, alpha};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user