# HG changeset patch # User Teemu Piippo # Date 1580597457 -7200 # Node ID 08dc62e03a6deeef171f2a2db884149576922f0a # Parent 1d03dc1173cd299efa2522489313eb2de400d2dd made edges white in dark backgrounds diff -r 1d03dc1173cd -r 08dc62e03a6d src/colors.cpp --- a/src/colors.cpp Sun Feb 02 00:49:32 2020 +0200 +++ b/src/colors.cpp Sun Feb 02 00:50:57 2020 +0200 @@ -82,3 +82,12 @@ } } } + +/* + * Calculates the luma-value for the given color. + * c.f. https://en.wikipedia.org/wiki/Luma_(video) + */ +double luma(const QColor& color) +{ + return 0.2126 * color.redF() + 0.7152 * color.greenF() + 0.0722 * color.blueF(); +} diff -r 1d03dc1173cd -r 08dc62e03a6d src/colors.h --- a/src/colors.h Sun Feb 02 00:49:32 2020 +0200 +++ b/src/colors.h Sun Feb 02 00:50:57 2020 +0200 @@ -90,3 +90,5 @@ static constexpr Color mainColor {16}; static constexpr Color edgeColor {24}; } + +double luma(const QColor& color); diff -r 1d03dc1173cd -r 08dc62e03a6d src/gl/compiler.cpp --- a/src/gl/compiler.cpp Sun Feb 02 00:49:32 2020 +0200 +++ b/src/gl/compiler.cpp Sun Feb 02 00:50:57 2020 +0200 @@ -224,7 +224,7 @@ else if (polygon.color == ldraw::edgeColor) { // Edge color is black, unless we have a dark background, in which case lines need to be bright. - color = Qt::black; //luma(config::backgroundColor()) > 40 ? Qt::black : Qt::white; + color = luma(preferences.backgroundColor) > (40.0 / 256.0) ? Qt::black : Qt::white; } else {