Added ave and craig

This commit is contained in:
2023-08-01 23:06:47 -07:00
parent 24ab09b451
commit 9fd31edc4a
8 changed files with 75 additions and 8 deletions

View File

@ -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 {};

View File

@ -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) {