| 72 | } |
| 73 | |
| 74 | osg::Vec4f Map::getColour(std::string_view fall) |
| 75 | { |
| 76 | const std::string_view sum = getString(fall); |
| 77 | |
| 78 | if (!sum.empty()) |
| 79 | { |
| 80 | std::vector<std::string> ret; |
| 81 | Misc::StringUtils::split(sum, ret, ","); |
| 82 | |
| 83 | if (ret.size() == 3) |
| 84 | { |
| 85 | const auto r = Misc::StringUtils::toNumeric<float>(ret[0]); |
| 86 | const auto g = Misc::StringUtils::toNumeric<float>(ret[1]); |
| 87 | const auto b = Misc::StringUtils::toNumeric<float>(ret[2]); |
| 88 | |
| 89 | if (r.has_value() && g.has_value() && b.has_value()) |
| 90 | { |
| 91 | return osg::Vec4f(*r / 255.0f, *g / 255.0f, *b / 255.0f, 1.0f); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | Log(Debug::Error) << "Error: '" << fall << "' setting value (" << sum |
| 96 | << ") is not a valid color, using middle gray as a fallback"; |
| 97 | } |
| 98 | |
| 99 | return osg::Vec4f(0.5f, 0.5f, 0.5f, 1.f); |
| 100 | } |
| 101 | } |