Gradient.h 476 B

1234567891011121314151617181920212223242526
  1. #ifndef GRADIENT_H
  2. #define GRADIENT_H
  3. #include <vector>
  4. #include "Color.h"
  5. #include <tuple>
  6. #include <cinttypes>
  7. class Gradient
  8. {
  9. std::vector<std::pair<RGBColor, float>> colors;
  10. float max;
  11. public:
  12. Gradient();
  13. void addColor(RGBColor c, float value);
  14. RGBColor get(float x) const;
  15. private:
  16. static RGBColor lerpColors(RGBColor a, RGBColor b, float val);
  17. std::tuple<RGBColor, RGBColor, float> getNeighbors(float x) const;
  18. };
  19. #endif // GRADIENT_H