cssvalue: Restructure RGBA transitions
Split out a function to make the code clearer for the changes ahead.
This commit is contained in:
@ -50,21 +50,29 @@ gtk_css_value_rgba_equal (const GtkCssValue *rgba1,
|
|||||||
return gdk_rgba_equal (&rgba1->rgba, &rgba2->rgba);
|
return gdk_rgba_equal (&rgba1->rgba, &rgba2->rgba);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline double
|
||||||
|
transition (double start,
|
||||||
|
double end,
|
||||||
|
double progress)
|
||||||
|
{
|
||||||
|
return start + (end - start) * progress;
|
||||||
|
}
|
||||||
|
|
||||||
static GtkCssValue *
|
static GtkCssValue *
|
||||||
gtk_css_value_rgba_transition (GtkCssValue *start,
|
gtk_css_value_rgba_transition (GtkCssValue *start,
|
||||||
GtkCssValue *end,
|
GtkCssValue *end,
|
||||||
guint property_id,
|
guint property_id,
|
||||||
double progress)
|
double progress)
|
||||||
{
|
{
|
||||||
GdkRGBA transition;
|
GdkRGBA result;
|
||||||
|
|
||||||
progress = CLAMP (progress, 0, 1);
|
progress = CLAMP (progress, 0, 1);
|
||||||
transition.red = start->rgba.red + (end->rgba.red - start->rgba.red) * progress;
|
result.alpha = transition (start->rgba.alpha, end->rgba.alpha, progress);
|
||||||
transition.green = start->rgba.green + (end->rgba.green - start->rgba.green) * progress;
|
result.red = transition (start->rgba.red, end->rgba.red, progress);
|
||||||
transition.blue = start->rgba.blue + (end->rgba.blue - start->rgba.blue) * progress;
|
result.green = transition (start->rgba.green, end->rgba.green, progress);
|
||||||
transition.alpha = start->rgba.alpha + (end->rgba.alpha - start->rgba.alpha) * progress;
|
result.blue = transition (start->rgba.blue, end->rgba.blue, progress);
|
||||||
|
|
||||||
return _gtk_css_rgba_value_new_from_rgba (&transition);
|
return _gtk_css_rgba_value_new_from_rgba (&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user