From dd94689f415e4d3049f3ba207ed81c40ed634a1e Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Wed, 4 Apr 2018 00:20:14 +0300 Subject: [PATCH] isDarkColor function has been added --- include/lrglobal.cpp | 9 +++++++++ include/lrglobal.h | 1 + limereport/lrglobal.cpp | 9 +++++++++ limereport/lrglobal.h | 1 + 4 files changed, 20 insertions(+) diff --git a/include/lrglobal.cpp b/include/lrglobal.cpp index b4eb854..55ab31b 100644 --- a/include/lrglobal.cpp +++ b/include/lrglobal.cpp @@ -76,4 +76,13 @@ QVector normalizeCaptures(const QRegExp& reg){ return result; } +bool isColorDark(QColor color){ + qreal darkness = 1-(0.299*color.red() + 0.587*color.green() + 0.114*color.blue())/255; + if(darkness<0.5){ + return false; + } else { + return true; + } +} + } //namespace LimeReport diff --git a/include/lrglobal.h b/include/lrglobal.h index 4ddad30..fdc35d4 100644 --- a/include/lrglobal.h +++ b/include/lrglobal.h @@ -101,6 +101,7 @@ namespace Const{ QString escapeSimbols(const QString& value); QString replaceHTMLSymbols(const QString &value); QVector normalizeCaptures(const QRegExp ®); + bool isColorDark(QColor color); enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols}; enum RenderPass {FirstPass = 1, SecondPass = 2}; diff --git a/limereport/lrglobal.cpp b/limereport/lrglobal.cpp index b4eb854..55ab31b 100644 --- a/limereport/lrglobal.cpp +++ b/limereport/lrglobal.cpp @@ -76,4 +76,13 @@ QVector normalizeCaptures(const QRegExp& reg){ return result; } +bool isColorDark(QColor color){ + qreal darkness = 1-(0.299*color.red() + 0.587*color.green() + 0.114*color.blue())/255; + if(darkness<0.5){ + return false; + } else { + return true; + } +} + } //namespace LimeReport diff --git a/limereport/lrglobal.h b/limereport/lrglobal.h index 4ddad30..fdc35d4 100644 --- a/limereport/lrglobal.h +++ b/limereport/lrglobal.h @@ -101,6 +101,7 @@ namespace Const{ QString escapeSimbols(const QString& value); QString replaceHTMLSymbols(const QString &value); QVector normalizeCaptures(const QRegExp ®); + bool isColorDark(QColor color); enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols}; enum RenderPass {FirstPass = 1, SecondPass = 2};