[chronojump] Better ColorIsDark formula
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Better ColorIsDark formula
- Date: Tue, 14 Apr 2020 10:22:34 +0000 (UTC)
commit 740e528a3a8fac4d1b6e89f43d5b6c6ff3116007
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Apr 14 12:21:20 2020 +0200
Better ColorIsDark formula
src/utilGtk.cs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/src/utilGtk.cs b/src/utilGtk.cs
index a7a3b1fd..5de9f4d7 100644
--- a/src/utilGtk.cs
+++ b/src/utilGtk.cs
@@ -498,7 +498,10 @@ public class UtilGtk
{
//LogB.Information(string.Format("color red: {0}, green: {1}, blue: {2}", color.Red,
color.Green, color.Blue));
//3 components come in ushort (0-65535)
- return (color.Red + color.Green + color.Blue < 3 * 65535 / 2.0);
+ //return (color.Red + color.Green + color.Blue < 3 * 65535 / 2.0);
+
+
//https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color
+ return (color.Red * 0.299 + color.Green * 0.587 + color.Blue * 0.114 < 186 * 256);
}
public static bool ColorIsDark(string colorString)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]