[gtkmm/wip/dboles/rgba-construct-doubles-4: 2/2] Gdk::RGBA: Add constructor taking doubles r, g, b, a
- From: Daniel Boles <dboles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm/wip/dboles/rgba-construct-doubles-4: 2/2] Gdk::RGBA: Add constructor taking doubles r, g, b, a
- Date: Sun, 16 Dec 2018 20:15:39 +0000 (UTC)
commit a1405ef4e9377d9e524b2614bfdc28359303b613
Author: Daniel Boles <dboles src gmail com>
Date: Mon Dec 10 16:38:08 2018 +0000
Gdk::RGBA: Add constructor taking doubles r,g,b,a
Enable constructing Gdk::RGBAs directly with the desired components as
fractions, sparing the user from having to do a verbose and error-prone
2-step 'construction' and also making it far nicer to declare e.g. a
std::vector<Gdk::RGBA> for use as a palette of colours in an application
https://gitlab.gnome.org/GNOME/gtkmm/issues/40
gdk/src/rgba.ccg | 6 ++++++
gdk/src/rgba.hg | 8 ++++++++
2 files changed, 14 insertions(+)
---
diff --git a/gdk/src/rgba.ccg b/gdk/src/rgba.ccg
index e8bede6b..e17daa42 100644
--- a/gdk/src/rgba.ccg
+++ b/gdk/src/rgba.ccg
@@ -35,6 +35,12 @@ RGBA::RGBA(const Glib::ustring& value)
set(value);
}
+RGBA::RGBA(double red_, double green_, double blue_, double alpha_)
+: RGBA()
+{
+ set_rgba(red_, green_, blue_, alpha_);
+}
+
void RGBA::set_grey_u(gushort value, gushort alpha)
{
gobject_->red = gobject_->green = gobject_->blue = (value / MULTIPLIER);
diff --git a/gdk/src/rgba.hg b/gdk/src/rgba.hg
index 1668e480..e9f8c8fd 100644
--- a/gdk/src/rgba.hg
+++ b/gdk/src/rgba.hg
@@ -68,6 +68,14 @@ public:
explicit RGBA(const Glib::ustring& value);
_IGNORE(gdk_rgba_parse)
+ /** Construct a Gdk::RGBA, by specifying red, green, and blue color component values, as fractions.
+ * @param red_ The red component of the color, as a fraction.
+ * @param green_ The green component of the color, as a fraction.
+ * @param blue_ The blue component of the color, as a fraction.
+ * @param alpha_ The alpha component of the color, as a fraction.
+ */
+ RGBA(double red_, double green_, double blue_, double alpha_ = 1.0);
+
/** Set a grey color, by using the same value for all color components.
* @param value The value to be used for the red, green, and blue components, in the range 0..65535.
* @param alpha The alpha component of the color, in the range 0..65535.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]