-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorMap.cpp
More file actions
26 lines (18 loc) · 741 Bytes
/
Copy pathColorMap.cpp
File metadata and controls
26 lines (18 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "ColorMap.h"
////////////////////////////////////////////////////////////
ColorMap::ColorMap(const std::map<double, sf::Color>& t_colorLimits, const sf::Color& t_defCol) :
m_colorLimits{ t_colorLimits }, m_defaultColor{ t_defCol }{}
////////////////////////////////////////////////////////////
ColorMap& ColorMap::setNextColor(double t_heightLim, const sf::Color& t_color) {
m_colorLimits.emplace(t_heightLim, t_color);
return *this;
}
////////////////////////////////////////////////////////////
const sf::Color& ColorMap::getColor(double t_height) const {
for (auto it{ m_colorLimits.cbegin() }; it != m_colorLimits.cend(); it++) {
if (t_height <= it->first) {
return it->second;
}
}
return m_defaultColor;
}