blob: 8812c93d77d3c64d4a7cb69a6dc31de6683d37b5 (
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
|
#include "Colors.h"
/**
* Blend the color with the front color, adapting to the back color
*/
QColor Color::blend(QColor front, QColor back, QColor color, uchar ratio)
{
Q_ASSERT(front.isValid());
Q_ASSERT(back.isValid());
if (Rainbow::luma(front) > Rainbow::luma(back))
{
// for dark color schemes, produce a fitting color first
color = Rainbow::tint(front, color, 0.5);
}
// adapt contrast
return Rainbow::mix(front, color, float(ratio) / float(0xff));
}
/**
* Blend the color with the back color
*/
QColor Color::blendBackground(QColor back, QColor color, uchar ratio)
{
// adapt contrast
return Rainbow::mix(back, color, float(ratio) / float(0xff));
}
|