#ifndef GRADIENT_H #define GRADIENT_H #include #include #include "Color.h" #include #include class Gradient { /// the colors of this gradient stored in linear RGB format /// so they can be easily interpolated std::vector colors; float max; bool repeat; public: Gradient(void); Gradient(const std::vector>&, bool repeat = false, int precalcSteps = 10000); static Gradient defaultGradient(void); static Gradient readXml(const QString& xml); /*! * \brief get a color at a specific position in this gradient * \param x the position * \return the color in sRGB format */ RGBColor get(float x) const; private: static RGBColor lerpColors(RGBColor a, RGBColor b, float val); std::tuple getNeighbors(float x) const; }; #endif // GRADIENT_H