From 0baed246b6f287e1c03519536011f34e87d19920 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 15 Aug 2018 18:45:29 -0400 Subject: Started to modernize bot (this is completely broken) --- palette.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 palette.cpp (limited to 'palette.cpp') diff --git a/palette.cpp b/palette.cpp new file mode 100644 index 0000000..019d956 --- /dev/null +++ b/palette.cpp @@ -0,0 +1,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(floor(c * 256.0)), 255); + + return gradient_.at(sc); +} -- cgit 1.4.1