hsla: Add _gtk_hsla_shade()
We use it in multiple places, so better split it out.
This commit is contained in:
@ -184,12 +184,7 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
|
|||||||
*dependencies = _gtk_css_dependencies_union (*dependencies, 0);
|
*dependencies = _gtk_css_dependencies_union (*dependencies, 0);
|
||||||
|
|
||||||
_gtk_hsla_init_from_rgba (&hsla, _gtk_css_rgba_value_get_rgba (val));
|
_gtk_hsla_init_from_rgba (&hsla, _gtk_css_rgba_value_get_rgba (val));
|
||||||
|
_gtk_hsla_shade (&hsla, &hsla, color->sym_col.shade.factor);
|
||||||
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);
|
|
||||||
|
|
||||||
_gdk_rgba_init_from_hsla (&shade, &hsla);
|
_gdk_rgba_init_from_hsla (&shade, &hsla);
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
@ -42,6 +42,10 @@ void _gtk_hsla_init_from_rgba (GtkHSLA *hsla,
|
|||||||
void _gdk_rgba_init_from_hsla (GdkRGBA *rgba,
|
void _gdk_rgba_init_from_hsla (GdkRGBA *rgba,
|
||||||
const GtkHSLA *hsla);
|
const GtkHSLA *hsla);
|
||||||
|
|
||||||
|
void _gtk_hsla_shade (GtkHSLA *dest,
|
||||||
|
const GtkHSLA *src,
|
||||||
|
double factor);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GTK_HSLA_PRIVATE_H__ */
|
#endif /* __GTK_HSLA_PRIVATE_H__ */
|
||||||
|
Reference in New Issue
Block a user