diff options
author | Dodji Seketeli <dodji@src.gnome.org> | 2003-03-31 21:58:34 +0000 |
---|---|---|
committer | Dodji Seketeli <dodji@src.gnome.org> | 2003-03-31 21:58:34 +0000 |
commit | bbd278d70458559b8aa323e0494d2673898caf7d (patch) | |
tree | c5874255cbd3a43aca18ef31e011460c6bc82305 /src/cr-rgb.c | |
parent | f60e5d31e6e03bb0d75e4618b8f8adcde6dbc8ce (diff) | |
download | libcroco-bbd278d70458559b8aa323e0494d2673898caf7d.tar.gz |
started went forward on the test annotated tree building front.
started to write the non regression test launcher.
Dodji.
Diffstat (limited to 'src/cr-rgb.c')
-rw-r--r-- | src/cr-rgb.c | 67 |
1 files changed, 65 insertions, 2 deletions
diff --git a/src/cr-rgb.c b/src/cr-rgb.c index 2890585..58ac0f4 100644 --- a/src/cr-rgb.c +++ b/src/cr-rgb.c @@ -61,8 +61,8 @@ cr_rgb_new (void) *@return the newly built instance of #CRRgb. */ CRRgb * -cr_rgb_new_with_vals (glong a_red, glong a_green, - glong a_blue, gboolean a_is_percentage) +cr_rgb_new_with_vals (gulong a_red, gulong a_green, + gulong a_blue, gboolean a_is_percentage) { CRRgb *result = NULL ; @@ -152,6 +152,69 @@ cr_rgb_dump (CRRgb *a_this, FILE *a_fp) } /** + *Sets rgb values to the RGB. + *If the rgb values are percentages, make + *sure that the sum of the 3 values makes 100%. + *@param a_this the current instance of #CRRgb. + *@param a_red the red value. + *@param a_green the green value. + *@param a_blue the blue value. + *@return CR_OK upon successfull completion, an error code + *otherwise. + */ +enum CRStatus +cr_rgb_set (CRRgb *a_this, gulong a_red, + gulong a_green, gulong a_blue, + gboolean a_is_percentage) +{ + g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR) ; + if (a_is_percentage != FALSE) + { + g_return_val_if_fail (a_red <= 100 + && a_green <= 100 + && a_blue <= 100, + CR_BAD_PARAM_ERROR) ; + } + + a_this->is_percentage = a_is_percentage ; + + a_this->red = a_red ; + a_this->green = a_green ; + if (a_is_percentage != FALSE) + { + if (a_red + a_green >= 100) + { + a_green = 100 - a_red ; + } + a_this->blue = 100 - a_red - a_green ; + } + else + { + a_this->blue = a_blue ; + } + + return CR_OK ; +} + +/** + *Sets the rgb from an other one. + *@param a_this the current instance of #CRRgb. + *@param a_rgb the rgb to "copy" + *@return CR_OK upon successfull completion, an error code otherwise. + */ +enum CRStatus +cr_rgb_set_from_rgb (CRRgb *a_this, CRRgb *a_rgb) +{ + g_return_val_if_fail (a_this && a_rgb, + CR_BAD_PARAM_ERROR) ; + + cr_rgb_set (a_this, a_rgb->red, a_rgb->green, + a_rgb->blue, a_rgb->is_percentage) ; + + return CR_OK ; +} + +/** *Destructor of #CRRgb. *@param a_this the "this pointer" of the *current instance of #CRRgb. |