[hyena/gtk3] GtkUtilities: Port ColorBlend from Gdk.Color to Gdk.RGBA
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hyena/gtk3] GtkUtilities: Port ColorBlend from Gdk.Color to Gdk.RGBA
- Date: Fri, 15 Jul 2011 18:25:01 +0000 (UTC)
commit 16f96d4c51da8c47fb2e0dbe52b69ca316a8675c
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date: Fri Jul 15 20:12:27 2011 +0200
GtkUtilities: Port ColorBlend from Gdk.Color to Gdk.RGBA
As the colors are used for drawing, it's much easier to have them as
Gdk.RGBA anyway.
Hyena.Gui/Hyena.Gui/GtkUtilities.cs | 21 ++++++++-------------
1 files changed, 8 insertions(+), 13 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Gui/GtkUtilities.cs b/Hyena.Gui/Hyena.Gui/GtkUtilities.cs
index c5b9d34..d480e09 100644
--- a/Hyena.Gui/Hyena.Gui/GtkUtilities.cs
+++ b/Hyena.Gui/Hyena.Gui/GtkUtilities.cs
@@ -88,7 +88,7 @@ namespace Hyena.Gui
}
}
- public static Gdk.Color ColorBlend (Gdk.Color a, Gdk.Color b)
+ public static Gdk.RGBA ColorBlend (Gdk.RGBA a, Gdk.RGBA b)
{
// at some point, might be nice to allow any blend?
double blend = 0.5;
@@ -99,23 +99,18 @@ namespace Hyena.Gui
double blendRatio = 1.0 - blend;
- int aR = a.Red >> 8;
- int aG = a.Green >> 8;
- int aB = a.Blue >> 8;
-
- int bR = b.Red >> 8;
- int bG = b.Green >> 8;
- int bB = b.Blue >> 8;
-
- double mR = aR + bR;
- double mG = aG + bG;
- double mB = aB + bB;
+ double mR = a.Red + b.Red;
+ double mG = a.Green + b.Green;
+ double mB = a.Blue + b.Blue;
double blR = mR * blendRatio;
double blG = mG * blendRatio;
double blB = mB * blendRatio;
- Gdk.Color color = new Gdk.Color ((byte)blR, (byte)blG, (byte)blB);
+ Gdk.RGBA color = new Gdk.RGBA ();
+ color.Red = blR;
+ color.Green = blG;
+ color.Blue = blB;
return color;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]