[chronojump] UtilGtk.GetColorShifted() to get a darker or lighter color



commit 21c6c03aff036bfeaaca821c3c6fe122fdc780c6
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Jun 17 22:36:57 2020 +0200

    UtilGtk.GetColorShifted() to get a darker or lighter color

 src/utilGtk.cs | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/src/utilGtk.cs b/src/utilGtk.cs
index 623db166..12367e20 100644
--- a/src/utilGtk.cs
+++ b/src/utilGtk.cs
@@ -509,6 +509,22 @@ public class UtilGtk
                return ColorIsDark(ColorParse(colorString));
        }
 
+
+       //darker or clearer
+       public static Gdk.Color GetColorShifted (Gdk.Color color, bool darker)
+       {
+               if(darker)
+                       return new Gdk.Color(
+                                       (byte) Convert.ToDouble(.25 * color.Red),
+                                       (byte) Convert.ToDouble(.25 * color.Green),
+                                       (byte) Convert.ToDouble(.25 * color.Blue) );
+               else
+                       return new Gdk.Color(
+                                       (byte) Convert.ToDouble(.25 * (65535 - color.Red)),
+                                       (byte) Convert.ToDouble(.25 * (65535 - color.Green)),
+                                       (byte) Convert.ToDouble(.25 * (65535 - color.Blue)) );
+       }
+
        //if color is too white or too yellow, it will not be ok
        public static bool ColorIsOkWithLogoTransparent (Gdk.Color color)
        {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]