summary refs log tree commit diff stats
path: root/palette.cpp
blob: 019d956ec50154f4ce24fec5b1974c17e0f21852 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "palette.h"

palette::palette(std::string colors)
{
  for (int i=0; i<256; i++)
  {
    std::string hexstr = colors.substr(i*6, 6);
    gradient_.push_back(Color::fromHex(hexstr.c_str()));
  }
}

Color palette::getShade(double c) const
{
  size_t sc = std::min(static_cast<size_t>(floor(c * 256.0)), 255);

  return gradient_.at(sc);
}