[gtkmm] Gdk::RGBA: Add alpha parameter to set_hsv() and set_hsl()



commit 717b01cd55d1a7e50c80f041feedf342f4eea975
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Fri Mar 3 15:32:49 2017 +0100

    Gdk::RGBA: Add alpha parameter to set_hsv() and set_hsl()

 gdk/src/rgba.ccg |   20 ++++++++++----------
 gdk/src/rgba.hg  |    7 ++++---
 2 files changed, 14 insertions(+), 13 deletions(-)
---
diff --git a/gdk/src/rgba.ccg b/gdk/src/rgba.ccg
index 2ea3003..fd29289 100644
--- a/gdk/src/rgba.ccg
+++ b/gdk/src/rgba.ccg
@@ -65,7 +65,7 @@ void RGBA::set_rgba(double red_, double green_, double blue_, double alpha_)
   gobject_->alpha = alpha_;
 }
 
-void RGBA::set_hsv(double h, double s, double v)
+void RGBA::set_hsv(double h, double s, double v, double alpha)
 {
   // The HSV color space is described in a long Wikipedia article,
   // http://en.wikipedia.org/wiki/HSV_color_space
@@ -89,26 +89,26 @@ void RGBA::set_hsv(double h, double s, double v)
   switch(i)
   {
     case 0:
-      set_rgba(v, t, p);
+      set_rgba(v, t, p, alpha);
       break;
     case 1:
-      set_rgba(q, v, p);
+      set_rgba(q, v, p, alpha);
       break;
     case 2:
-      set_rgba(p, v, t);
+      set_rgba(p, v, t, alpha);
       break;
     case 3:
-      set_rgba(p, q, v);
+      set_rgba(p, q, v, alpha);
       break;
     case 4:
-      set_rgba(t, p, v);
+      set_rgba(t, p, v, alpha);
       break;
     default:
-      set_rgba(v, p, q);
+      set_rgba(v, p, q, alpha);
   }
 }
 
-void RGBA::set_hsl(double h, double s, double l)
+void RGBA::set_hsl(double h, double s, double l, double alpha)
 {
   // The HSL color space is described in a long Wikipedia article,
   // http://en.wikipedia.org/wiki/HSV_color_space
@@ -124,7 +124,7 @@ void RGBA::set_hsl(double h, double s, double l)
   // http://www.w3.org/TR/css3-color/#hsl-color
 
   if(s == 0.0)
-    set_grey(l);
+    set_grey(l, alpha);
   else
   {
     double t2 = (l < 0.5) ? l * (1.0 + s) : l + s - l * s;
@@ -162,7 +162,7 @@ void RGBA::set_hsl(double h, double s, double l)
     else if (tb < 2.0/3.0)
       b = t1+(t2-t1)*(2.0/3.0 - tb) * 6.0;
 
-    set_rgba(r, g, b);
+    set_rgba(r, g, b, alpha);
   }
 }
 
diff --git a/gdk/src/rgba.hg b/gdk/src/rgba.hg
index c6c5942..8a3a049 100644
--- a/gdk/src/rgba.hg
+++ b/gdk/src/rgba.hg
@@ -79,20 +79,21 @@ public:
    */
   void set_rgba(double red_, double green_, double blue_, double alpha_ = 1.0);
 
-  //TODO: Add alpha parameter?
   /** Set the color, by specifying hue, saturation, and value (brightness).
    * @param h Hue, in the range 0..360 degrees.
    * @param s Saturation, in the range 0..1.
    * @param v Value (a.k.a. brightness), in the range 0..1.
+   * @param alpha The alpha component of the color, in the range 0..1.
    */
-  void set_hsv(double h, double s, double v);
+  void set_hsv(double h, double s, double v, double alpha = 1.0);
 
   /** Set the color, by specifying hue, saturation, and lightness.
    * @param h Hue, in the range 0..360 degrees.
    * @param s Saturation, in the range 0..1.
    * @param l Lightness, in the range 0..1.
+   * @param alpha The alpha component of the color, in the range 0..1.
    */
-  void set_hsl(double h, double s, double l);
+  void set_hsl(double h, double s, double l, double alpha = 1.0);
 
   _WRAP_METHOD(bool set(const Glib::ustring& spec), gdk_rgba_parse)
 


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