summaryrefslogtreecommitdiffstats
path: root/application/ColorCache.cpp
blob: e216b59784d981a7bed8b7dcbfcdc9fc688dc46a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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);
	}
}