2017-01-02 21:07:43 -05:00
|
|
|
// Copyright (c) Charles J. Cliffe
|
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
|
2014-11-11 08:11:12 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class GradientColor {
|
|
|
|
public:
|
2014-11-12 21:55:11 -05:00
|
|
|
float r, g, b;
|
2014-11-11 08:11:12 -05:00
|
|
|
float w;
|
2014-11-12 21:55:11 -05:00
|
|
|
|
2020-01-04 15:20:36 -05:00
|
|
|
//should work with both float and double inputs
|
|
|
|
GradientColor(double r_in, double g_in, double b_in) :
|
|
|
|
r((float)r_in), g((float)g_in), b((float)b_in), w(1) {
|
2014-11-12 21:55:11 -05:00
|
|
|
}
|
2014-11-11 08:11:12 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class Gradient {
|
|
|
|
public:
|
2014-11-12 21:55:11 -05:00
|
|
|
Gradient();
|
2014-11-11 08:11:12 -05:00
|
|
|
|
2014-11-12 21:55:11 -05:00
|
|
|
void addColor(GradientColor c);
|
2014-11-11 08:11:12 -05:00
|
|
|
|
2019-09-23 01:24:04 -04:00
|
|
|
void clear();
|
|
|
|
|
|
|
|
void addColors(const std::vector<GradientColor>& color_list);
|
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
std::vector<float> &getRed();
|
2014-11-12 21:55:11 -05:00
|
|
|
std::vector<float> &getGreen();
|
|
|
|
std::vector<float> &getBlue();
|
2014-11-11 08:11:12 -05:00
|
|
|
|
2014-11-12 21:55:11 -05:00
|
|
|
void generate(unsigned int len);
|
2014-11-11 20:25:16 -05:00
|
|
|
|
2014-11-12 21:55:11 -05:00
|
|
|
~Gradient();
|
2014-11-11 08:11:12 -05:00
|
|
|
private:
|
|
|
|
std::vector<GradientColor> colors;
|
2014-11-11 20:25:16 -05:00
|
|
|
std::vector<float> r_val;
|
|
|
|
std::vector<float> g_val;
|
|
|
|
std::vector<float> b_val;
|
|
|
|
};
|