59 std::vector<RGBColor> ColorTools::gradient(
unsigned int n,
const RGBColor& low,
const RGBColor& high)
61 vector<RGBColor> colors(n);
62 for (
unsigned int i = 0; i < n - 1; ++i)
64 colors[i][0] = low[0] +
static_cast<unsigned int>(
66 static_cast<double>(i) *
static_cast<double>(
static_cast<int>(high[0]) -
static_cast<int>(low[0]))
67 /
static_cast<double>(n - 1)
70 colors[i][1] = low[1] +
static_cast<unsigned int>(
72 static_cast<double>(i) *
static_cast<double>(
static_cast<int>(high[1]) -
static_cast<int>(low[1]))
73 /
static_cast<double>(n - 1)
76 colors[i][2] = low[2] +
static_cast<unsigned int>(
78 static_cast<double>(i) *
static_cast<double>(
static_cast<int>(high[2]) -
static_cast<int>(low[2]))
79 /
static_cast<double>(n - 1)
91 unsigned int lower = n / 2;
92 unsigned int upper = n - lower;
93 vector<RGBColor> colors1 = gradient(lower, low, mid);
94 vector<RGBColor> colors2 = gradient(upper + 1, mid, high);
95 for (
size_t i = 1; i < colors2.size(); i++)
97 colors1.push_back(colors2[i]);
Describe a color according to its red, green and blue componants.