/////////////////////////////////////////////////////// Get the terrain color for the given elevation and moisture. ///////////////////////////////////////////////////////
| 194 | /// |
| 195 | //////////////////////////////////////////////////////////// |
| 196 | sf::Color getTerrainColor(float elevation, float moisture) |
| 197 | { |
| 198 | if (elevation < 0.11f) |
| 199 | return {0, 0, static_cast<std::uint8_t>(elevation / 0.11f * 74.f + 181.0f)}; |
| 200 | if (elevation < 0.14f) |
| 201 | return {static_cast<std::uint8_t>(std::pow((elevation - 0.11f) / 0.03f, 0.3f) * 48.f), |
| 202 | static_cast<std::uint8_t>(std::pow((elevation - 0.11f) / 0.03f, 0.3f) * 48.f), |
| 203 | 255}; |
| 204 | if (elevation < 0.16f) |
| 205 | return {static_cast<std::uint8_t>((elevation - 0.14f) * 128.f / 0.02f + 48.f), |
| 206 | static_cast<std::uint8_t>((elevation - 0.14f) * 128.f / 0.02f + 48.f), |
| 207 | static_cast<std::uint8_t>(127.0f + (0.16f - elevation) * 128.f / 0.02f)}; |
| 208 | if (elevation < 0.17f) |
| 209 | return {240, 230, 140}; |
| 210 | if (elevation < 0.4f) |
| 211 | return getLowlandsTerrainColor(moisture); |
| 212 | if (elevation < snowcapHeight) |
| 213 | return getHighlandsTerrainColor(elevation, moisture); |
| 214 | return getSnowcapTerrainColor(elevation, moisture); |
| 215 | } |
| 216 | |
| 217 | |
| 218 | //////////////////////////////////////////////////////////// |
no test coverage detected