12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- #ifndef LIBALMOND_GRADIENT_H
- #define LIBALMOND_GRADIENT_H
- #include <vector>
- #include <map>
- #include <string>
- #include "Color.h"
- #include "CubicSpline.h"
- #include <tuple>
- #include <cinttypes>
- #include <memory>
- namespace alm
- {
- class Gradient;
- }
- class alm::Gradient
- {
- std::vector<std::pair<RGBColor, float>> points;
- std::map<float, RGBColor, std::greater<float>> pointMap;
- ColorSpline colorSpline;
-
-
- std::vector<RGBColorf> colors;
- float max;
- bool repeat;
- public:
- Gradient(void);
- Gradient(std::vector<std::pair<RGBColor, float>> colors, bool repeat = true);
- Gradient(std::vector<std::pair<RGBColor, float>> colors, float maxValue, bool repeat = true);
- const std::vector<std::pair<RGBColor, float>>& getPoints(void) const;
- static Gradient defaultGradient(void);
- bool isRepeat(void) const;
-
-
-
-
-
-
-
- float getMax(void) const;
-
-
-
-
-
- RGBColor get(float x) const;
- RGBColor interpolate(float x) const;
- private:
- static RGBColorf lerpColors(RGBColorf a, RGBColorf b, float val);
- static RGBColor lerpColors(RGBColor a, RGBColor b, float val);
- std::tuple<RGBColor, RGBColor, float> getNeighbors(float x) const;
- };
- #endif
|