diff options
author | Petr Mrázek <peterix@gmail.com> | 2015-08-20 01:49:03 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-08-20 01:49:03 +0200 |
commit | d0e88011dc025a1e68964a9363cece66c677969f (patch) | |
tree | c8f2701fb0c959ba4fc63c0e447ee71722002096 /application/ColorCache.cpp | |
parent | 6858f1dd6294a93c1e1ec8007cb0434b53646488 (diff) | |
download | PrismLauncher-d0e88011dc025a1e68964a9363cece66c677969f.tar.gz PrismLauncher-d0e88011dc025a1e68964a9363cece66c677969f.tar.bz2 PrismLauncher-d0e88011dc025a1e68964a9363cece66c677969f.zip |
GH-1197 finish color stuff
Diffstat (limited to 'application/ColorCache.cpp')
-rw-r--r-- | application/ColorCache.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/application/ColorCache.cpp b/application/ColorCache.cpp new file mode 100644 index 00000000..e216b597 --- /dev/null +++ b/application/ColorCache.cpp @@ -0,0 +1,35 @@ +#include "ColorCache.h" + + +/** + * Blend the color with the front color, adapting to the back color + */ +QColor ColorCache::blend(QColor color) +{ + if (Rainbow::luma(m_front) > Rainbow::luma(m_back)) + { + // for dark color schemes, produce a fitting color first + color = Rainbow::tint(m_front, color, 0.5); + } + // adapt contrast + return Rainbow::mix(m_front, color, m_bias); +} + +/** + * Blend the color with the back color + */ +QColor ColorCache::blendBackground(QColor color) +{ + // adapt contrast + return Rainbow::mix(m_back, color, m_bias); +} + +void ColorCache::recolorAll() +{ + auto iter = m_colors.begin(); + while(iter != m_colors.end()) + { + iter->front = blend(iter->original); + iter->back = blendBackground(iter->original); + } +} |