made edges white in dark backgrounds

Sun, 02 Feb 2020 00:50:57 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 02 Feb 2020 00:50:57 +0200
changeset 43
08dc62e03a6d
parent 42
1d03dc1173cd
child 44
c6114b3af3a6

made edges white in dark backgrounds

src/colors.cpp file | annotate | diff | comparison | revisions
src/colors.h file | annotate | diff | comparison | revisions
src/gl/compiler.cpp file | annotate | diff | comparison | revisions
--- 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();
+}
--- 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);
--- 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
 	{

mercurial