summaryrefslogtreecommitdiff
path: root/util.hpp
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2020-09-05 21:05:52 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2020-09-05 21:05:52 -0400
commitde482d6cb7a57c804e771d14dcb1c592b5f07402 (patch)
treefa86e2bd69e95e7c4909d4c70053e166920fe66d /util.hpp
parent7d41206a198495c2355e16512391a3aa0483d0ca (diff)
downloadabaddon-portaudio-de482d6cb7a57c804e771d14dcb1c592b5f07402.tar.gz
abaddon-portaudio-de482d6cb7a57c804e771d14dcb1c592b5f07402.zip
add int -> color to util
Diffstat (limited to 'util.hpp')
-rw-r--r--util.hpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/util.hpp b/util.hpp
index 48cd73c..f192835 100644
--- a/util.hpp
+++ b/util.hpp
@@ -4,6 +4,9 @@
#include <vector>
#include <functional>
#include <iterator>
+#include <sstream>
+#include <string>
+#include <iomanip>
template<typename T>
inline void AlphabeticalSort(typename T start, typename T end, std::function<std::string(const typename std::iterator_traits<T>::value_type &)> get_string) {
@@ -29,3 +32,14 @@ inline void AlphabeticalSort(typename T start, typename T end, std::function<std
return ac[0] || ac[5];
});
}
+
+inline std::string IntToCSSColor(int color) {
+ int r = (color & 0xFF0000) >> 16;
+ int g = (color & 0x00FF00) >> 8;
+ int b = (color & 0x0000FF) >> 0;
+ std::stringstream ss;
+ ss << std::hex << std::setw(2) << std::setfill('0') << r
+ << std::hex << std::setw(2) << std::setfill('0') << g
+ << std::hex << std::setw(2) << std::setfill('0') << b;
+ return ss.str();
+}