22 std::vector<RGBColor> ColorTools::gradient(
unsigned int n,
const RGBColor& low,
const RGBColor& high)
24 vector<RGBColor> colors(n);
25 for (
unsigned int i = 0; i < n - 1; ++i)
27 colors[i][0] = low[0] +
static_cast<unsigned int>(
29 static_cast<double>(i) * static_cast<double>(static_cast<int>(high[0]) - static_cast<int>(low[0]))
30 / static_cast<double>(n - 1)
33 colors[i][1] = low[1] +
static_cast<unsigned int>(
35 static_cast<double>(i) * static_cast<double>(static_cast<int>(high[1]) - static_cast<int>(low[1]))
36 / static_cast<double>(n - 1)
39 colors[i][2] = low[2] +
static_cast<unsigned int>(
41 static_cast<double>(i) * static_cast<double>(static_cast<int>(high[2]) - static_cast<int>(low[2]))
42 / static_cast<double>(n - 1)
54 unsigned int lower = n / 2;
55 unsigned int upper = n - lower;
56 vector<RGBColor> colors1 = gradient(lower, low, mid);
57 vector<RGBColor> colors2 = gradient(upper + 1, mid, high);
58 for (
size_t i = 1; i < colors2.size(); i++)
60 colors1.push_back(colors2[i]);
Describe a color according to its red, green and blue componants.