aboutsummaryrefslogtreecommitdiff
path: root/colorscale.cpp
diff options
context:
space:
mode:
authorSamuel Fadel <samuelfadel@gmail.com>2015-12-19 12:25:39 +0100
committerSamuel Fadel <samuelfadel@gmail.com>2015-12-19 12:25:39 +0100
commit044eb56f2a332ef10927a8539ab1450b53add6b5 (patch)
tree83affa8c6f45d1f2cc25216e61878f9eeb42def4 /colorscale.cpp
parenta184000e2086c0d86d5aef20d715f5e884a63ff3 (diff)
ColorScale: updated API to use float.
The old qreal is only used internally now.
Diffstat (limited to 'colorscale.cpp')
-rw-r--r--colorscale.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/colorscale.cpp b/colorscale.cpp
index 85c036d..e4e2063 100644
--- a/colorscale.cpp
+++ b/colorscale.cpp
@@ -22,7 +22,7 @@ ColorScale::~ColorScale()
{
}
-void ColorScale::setExtents(qreal min, qreal max)
+void ColorScale::setExtents(float min, float max)
{
if (min >= max) {
return;
@@ -32,10 +32,11 @@ void ColorScale::setExtents(qreal min, qreal max)
m_max = max;
}
-static QColor lerp(const QColor &c1, const QColor &c2, qreal t)
+static QColor lerp(const QColor &c1, const QColor &c2, float _t)
{
qreal r1, g1, b1, a1;
qreal r2, g2, b2, a2;
+ qreal t = _t;
c1.getRgbF(&r1, &g1, &b1, &a1);
c2.getRgbF(&r2, &g2, &b2, &a2);
@@ -47,7 +48,7 @@ static QColor lerp(const QColor &c1, const QColor &c2, qreal t)
return color;
}
-QColor ColorScale::color(qreal t) const
+QColor ColorScale::color(float t) const
{
if (t < m_min || t > m_max) {
return QColor();
@@ -62,8 +63,8 @@ QColor ColorScale::color(qreal t) const
}
// find which colors in the scale are adjacent to ours
- qreal step = 1.0 / m_colors.size();
- int i = (int) (t / step);
+ float step = 1.0 / m_colors.size();
+ int i = int(t / step);
int j = i + 1;
if (i >= m_colors.size() - 1) {