From 6858f1dd6294a93c1e1ec8007cb0434b53646488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Wed, 19 Aug 2015 02:06:32 +0200 Subject: GH-1197 add console log color adaptation rainbow library was part of KDE - KGuiAddons --- application/Colors.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 application/Colors.cpp (limited to 'application/Colors.cpp') diff --git a/application/Colors.cpp b/application/Colors.cpp new file mode 100644 index 00000000..8812c93d --- /dev/null +++ b/application/Colors.cpp @@ -0,0 +1,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)); +} -- cgit v1.2.3