From 1b75342fdec4f58aecb35869588a247e9ddc066a Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Sun, 17 Jan 2016 20:50:07 +0100 Subject: ColorScale: minor update to color sampling and generation algorithms. --- colorscale.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'colorscale.h') diff --git a/colorscale.h b/colorscale.h index 1be315f..5974cef 100644 --- a/colorscale.h +++ b/colorscale.h @@ -19,6 +19,7 @@ public: void setExtents(float min, float max); float min() const { return m_min; } float max() const { return m_max; } + int numColors() const { return m_colors.size(); } template void sample(int samples, OutputIterator it) const; @@ -37,11 +38,11 @@ void ColorScale::sample(int samples, OutputIterator it) const float step = (max() - min()) / samples; qreal r, g, b; - for (float t = min(); t < max(); t += step) { + for (float t = min(); samples-- > 0; t += step) { color(t).getRgbF(&r, &g, &b); - *it = r; it++; - *it = g; it++; - *it = b; it++; + *it++ = r; + *it++ = g; + *it++ = b; } } -- cgit v1.2.3