aboutsummaryrefslogtreecommitdiff
path: root/colorscale.h
blob: af74b5c9cf472b6205c6b2572db7d43fd3e61b0e (plain)
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
27
28
#ifndef COLORSCALE_H
#define COLORSCALE_H

#include <initializer_list>
#include <QColor>
#include <QList>

class ColorScale
{
public:
    ColorScale(const QColor &firstColor, const QColor &lastColor);
    ColorScale(std::initializer_list<QColor> colors);
    ColorScale(const QList<QColor> &colors);
    virtual ~ColorScale();

    QColor operator ()(float t) const { return color(t); }
    virtual QColor color(float t) const;

    void setExtents(float min, float max);
    float min() const { return m_min; }
    float max() const { return m_max; }

protected:
    float m_min, m_max;
    QList<QColor> m_colors;
};

#endif // COLORSCALE_H