diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-09-05 23:04:11 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-09-05 23:04:11 -0400 |
commit | af82a8df8e469739765918b1627de20948186eb4 (patch) | |
tree | 4c9f93c9e917d54f9928deae77cc98bd3a322942 /util.hpp | |
parent | de482d6cb7a57c804e771d14dcb1c592b5f07402 (diff) | |
download | abaddon-portaudio-af82a8df8e469739765918b1627de20948186eb4.tar.gz abaddon-portaudio-af82a8df8e469739765918b1627de20948186eb4.zip |
better member list, role color, some fixes
Diffstat (limited to 'util.hpp')
-rw-r--r-- | util.hpp | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -43,3 +43,19 @@ inline std::string IntToCSSColor(int color) { << std::hex << std::setw(2) << std::setfill('0') << b; return ss.str(); } + +// https://www.compuphase.com/cmetric.htm +inline double ColorDistance(int c1, int c2) { + int r1 = (c1 & 0xFF0000) >> 16; + int g1 = (c1 & 0x00FF00) >> 8; + int b1 = (c1 & 0x0000FF) >> 0; + int r2 = (c2 & 0xFF0000) >> 16; + int g2 = (c2 & 0x00FF00) >> 8; + int b2 = (c2 & 0x0000FF) >> 0; + + int rmean = (r1 - r2) / 2; + int r = r1 - r2; + int g = g1 - g2; + int b = b1 - b2; + return sqrt((((512 + rmean) * r * r) >> 8) + 4 * g * g + (((767 - rmean) * b * b) >> 8)); +} |