summary refs log tree commit diff stats
path: root/palette.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'palette.cpp')
-rw-r--r--palette.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/palette.cpp b/palette.cpp new file mode 100644 index 0000000..019d956 --- /dev/null +++ b/palette.cpp
@@ -0,0 +1,17 @@
1#include "palette.h"
2
3palette::palette(std::string colors)
4{
5 for (int i=0; i<256; i++)
6 {
7 std::string hexstr = colors.substr(i*6, 6);
8 gradient_.push_back(Color::fromHex(hexstr.c_str()));
9 }
10}
11
12Color palette::getShade(double c) const
13{
14 size_t sc = std::min(static_cast<size_t>(floor(c * 256.0)), 255);
15
16 return gradient_.at(sc);
17}