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};