summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@gnome.org>2004-03-06 23:33:10 +0000
committerDodji Seketeli <dodji@src.gnome.org>2004-03-06 23:33:10 +0000
commit0d19a60f90378964a7e034dabe62f99cf0d306bd (patch)
tree6a185e30a2f951e4eb291aa27566f1ecf1d823ea
parent9fd0686e5a84f3c62e3a3ce4c11777e4f2050cb7 (diff)
downloadlibcroco-0d19a60f90378964a7e034dabe62f99cf0d306bd.tar.gz
added this new convenience function.
2004-03-07 Dodji Seketeli <dodji@gnome.org> * src/cr-rgb.[ch]: (cr_rgb_compute_from_percentage): added this new convenience function.
-rw-r--r--ChangeLog5
-rw-r--r--src/cr-rgb.c20
-rw-r--r--src/cr-rgb.h35
3 files changed, 39 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index cbaa322..ab88143 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-03-07 Dodji Seketeli <dodji@gnome.org>
+
+ * src/cr-rgb.[ch]:
+ (cr_rgb_compute_from_percentage): added this new convenience
+ function.
2004-03-06 Dodji <dodji@gnome.org>
* src/cr-tknzr.c:
diff --git a/src/cr-rgb.c b/src/cr-rgb.c
index b235d9b..d1c1c38 100644
--- a/src/cr-rgb.c
+++ b/src/cr-rgb.c
@@ -303,6 +303,26 @@ cr_rgb_dump (CRRgb *a_this, FILE *a_fp)
}
/**
+ *If the rgb values are expressed in percentage,
+ *compute their real value.
+ *@param a_this the current instance of #CRRgb
+ *@return
+ */
+enum CRStatus
+cr_rgb_compute_from_percentage (CRRgb *a_this)
+{
+ g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR) ;
+
+ if (a_this->is_percentage == FALSE)
+ return CR_OK ;
+ a_this->red = a_this->red * 255 / 100 ;
+ a_this->green = a_this->green * 255 / 100 ;
+ a_this->blue = a_this->blue * 255 / 100 ;
+ a_this->is_percentage = FALSE ;
+ return CR_OK ;
+}
+
+/**
*Sets rgb values to the RGB.
*@param a_this the current instance of #CRRgb.
*@param a_red the red value.
diff --git a/src/cr-rgb.h b/src/cr-rgb.h
index 8c8e4b8..9a11e6c 100644
--- a/src/cr-rgb.h
+++ b/src/cr-rgb.h
@@ -49,35 +49,28 @@ struct _CRRgb
gboolean is_percentage ;
} ;
-CRRgb *
-cr_rgb_new (void) ;
+CRRgb * cr_rgb_new (void) ;
-CRRgb *
-cr_rgb_new_with_vals (gulong a_red, gulong a_green,
- gulong a_blue, gboolean a_is_percentage) ;
+CRRgb * cr_rgb_new_with_vals (gulong a_red, gulong a_green,
+ gulong a_blue, gboolean a_is_percentage) ;
-enum CRStatus
-cr_rgb_set (CRRgb *a_this, gulong a_red,
- gulong a_green, gulong a_blue,
- gboolean a_is_percentage) ;
+enum CRStatus cr_rgb_compute_from_percentage (CRRgb *a_this) ;
+
+enum CRStatus cr_rgb_set (CRRgb *a_this, gulong a_red,
+ gulong a_green, gulong a_blue,
+ gboolean a_is_percentage) ;
-enum CRStatus
-cr_rgb_set_from_rgb (CRRgb *a_this, CRRgb *a_rgb) ;
+enum CRStatus cr_rgb_set_from_rgb (CRRgb *a_this, CRRgb *a_rgb) ;
-enum CRStatus
-cr_rgb_set_from_name (CRRgb *a_this, const guchar *a_color_name) ;
+enum CRStatus cr_rgb_set_from_name (CRRgb *a_this, const guchar *a_color_name) ;
-enum CRStatus
-cr_rgb_set_from_hex_str (CRRgb *a_this, const guchar * a_hex_value) ;
+enum CRStatus cr_rgb_set_from_hex_str (CRRgb *a_this, const guchar * a_hex_value) ;
-guchar *
-cr_rgb_to_string (CRRgb *a_this) ;
+guchar * cr_rgb_to_string (CRRgb *a_this) ;
-void
-cr_rgb_dump (CRRgb *a_this, FILE *a_fp) ;
+void cr_rgb_dump (CRRgb *a_this, FILE *a_fp) ;
-void
-cr_rgb_destroy (CRRgb *a_this) ;
+void cr_rgb_destroy (CRRgb *a_this) ;
G_END_DECLS