summary refs log tree commit diff stats
path: root/palette.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-08-15 18:45:29 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-08-15 18:45:29 -0400
commit0baed246b6f287e1c03519536011f34e87d19920 (patch)
treed9eb44f28d8ad5edf7e78f47e3bdb830114a7432 /palette.cpp
parentd7fbb904d0dc70d1eada1dbb5f57f2ee9e5b399f (diff)
downloadinfinite-0baed246b6f287e1c03519536011f34e87d19920.tar.gz
infinite-0baed246b6f287e1c03519536011f34e87d19920.tar.bz2
infinite-0baed246b6f287e1c03519536011f34e87d19920.zip
Started to modernize bot (this is completely broken) modern
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}