31 double _interpolatedOpacity(
const core::Vector2ds& controlPointsSorted,
const double x)
33 const auto& firstPoint = controlPointsSorted.front();
34 if (x <= firstPoint.x)
37 for (
size_t i = 1; i < controlPointsSorted.size(); ++i)
39 const auto& current = controlPointsSorted[i];
40 const auto& previous = controlPointsSorted[i - 1];
43 const auto t = (x - previous.x) / (current.x - previous.x);
44 return (1.0 - t) * previous.y + t * current.y;
48 const auto& lastPoint = controlPointsSorted.back();
64 colors = {{0, 0, 0}, {1, 1, 1}};
75 _controlPoints = {{0, 0}, {1, 1}};
76 _valuesRange = {0, 255};
82 constexpr
size_t numSamples = 256;
83 constexpr
double dx = 1. / (numSamples - 1);
86 std::sort(tfPoints.begin(), tfPoints.end(), [](
auto a,
auto b) { return a.x < b.x; });
89 opacities.reserve(numSamples);
90 for (
size_t i = 0; i < numSamples; ++i)
91 opacities.push_back(_interpolatedOpacity(tfPoints, i * dx));
void markModified(const bool triggerCallback=true)
floats calculateInterpolatedOpacities() const
const Vector2ds & getControlPoints() const
std::vector< Vector2d > Vector2ds
bool operator==(const ColorMap &rhs) const