From 01bc618dcc8371e943c51b511701936dcf726689 Mon Sep 17 00:00:00 2001 From: hexyoungs Date: Mon, 28 Sep 2020 10:24:21 +0800 Subject: [PATCH] refactor: ColorUtils::colorIsDark make it more clear --- src/utils/colorutils.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/utils/colorutils.cpp b/src/utils/colorutils.cpp index 225c2e4b..d246a422 100644 --- a/src/utils/colorutils.cpp +++ b/src/utils/colorutils.cpp @@ -24,11 +24,8 @@ inline qreal getColorLuma(const QColor& c) bool ColorUtils::colorIsDark(const QColor& c) { - bool isWhite = false; - if (getColorLuma(c) <= 0.60) { - isWhite = true; - } - return !isWhite; + // when luma <= 0.5, we considor it as a dark color + return getColorLuma(c) <= 0.5; } QColor ColorUtils::contrastColor(const QColor& c)