hsla: Add _gtk_hsla_shade()

We use it in multiple places, so better split it out.
This commit is contained in:
Benjamin Otte 2012-11-25 03:24:47 +01:00
parent 4f9a8e6b3d
commit 9aac4dffc5
3 changed files with 23 additions and 6 deletions

View File

@ -184,12 +184,7 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
*dependencies = _gtk_css_dependencies_union (*dependencies, 0);
_gtk_hsla_init_from_rgba (&hsla, _gtk_css_rgba_value_get_rgba (val));
hsla.lightness *= color->sym_col.shade.factor;
hsla.lightness = CLAMP (hsla.lightness, 0.0, 1.0);
hsla.saturation *= color->sym_col.shade.factor;
hsla.saturation = CLAMP (hsla.saturation, 0.0, 1.0);
_gtk_hsla_shade (&hsla, &hsla, color->sym_col.shade.factor);
_gdk_rgba_init_from_hsla (&shade, &hsla);

View File

@ -183,3 +183,21 @@ _gdk_rgba_init_from_hsla (GdkRGBA *rgba,
}
}
void
_gtk_hsla_shade (GtkHSLA *dest,
const GtkHSLA *src,
double factor)
{
g_return_if_fail (dest != NULL);
g_return_if_fail (src != NULL);
dest->hue = src->hue;
dest->lightness = src->lightness * factor;
dest->lightness = CLAMP (dest->lightness, 0.0, 1.0);
dest->saturation = src->saturation * factor;
dest->saturation = CLAMP (dest->saturation, 0.0, 1.0);
dest->alpha = src->alpha;
}

View File

@ -42,6 +42,10 @@ void _gtk_hsla_init_from_rgba (GtkHSLA *hsla,
void _gdk_rgba_init_from_hsla (GdkRGBA *rgba,
const GtkHSLA *hsla);
void _gtk_hsla_shade (GtkHSLA *dest,
const GtkHSLA *src,
double factor);
G_END_DECLS
#endif /* __GTK_HSLA_PRIVATE_H__ */