Added ave and craig
This commit is contained in:
@ -34,6 +34,28 @@ struct Color Color::fromString(std::string str) {
|
||||
return COLOR_BLUE;
|
||||
}
|
||||
|
||||
// Hex code?
|
||||
|
||||
// Split by comma
|
||||
auto splitByComma = stringSplit(str, ",");
|
||||
if(splitByComma.size() == 3) {
|
||||
// RGB
|
||||
return {
|
||||
(float_t)std::stof(splitByComma[0]),
|
||||
(float_t)std::stof(splitByComma[1]),
|
||||
(float_t)std::stof(splitByComma[2]),
|
||||
1.0f
|
||||
};
|
||||
} else if(splitByComma.size() == 4) {
|
||||
// RGBA
|
||||
return {
|
||||
(float_t)std::stof(splitByComma[0]),
|
||||
(float_t)std::stof(splitByComma[1]),
|
||||
(float_t)std::stof(splitByComma[2]),
|
||||
(float_t)std::stof(splitByComma[3])
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: Parse other kinds of colors
|
||||
assertUnreachable("Failed to find a color match for " + str);
|
||||
return {};
|
||||
|
@ -124,7 +124,7 @@ namespace Dawn {
|
||||
};
|
||||
|
||||
static inline std::string colorParser(std::string v, std::string *error) {
|
||||
return rawParser(v, error);
|
||||
return "Color::fromString(" + stringParser(v, error) + ")";
|
||||
}
|
||||
|
||||
static inline std::function<std::string(std::string, std::string*)> parserFromTypeName(std::string type) {
|
||||
|
Reference in New Issue
Block a user