Commit e3d8f03b authored by Benjamin Otte's avatar Benjamin Otte

cssvalue: Restructure RGBA transitions

Split out a function to make the code clearer for the changes ahead.
parent 8509a07a
......@@ -50,21 +50,29 @@ gtk_css_value_rgba_equal (const GtkCssValue *rgba1,
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 *
gtk_css_value_rgba_transition (GtkCssValue *start,
GtkCssValue *end,
guint property_id,
double progress)
{
GdkRGBA transition;
GdkRGBA result;
progress = CLAMP (progress, 0, 1);
transition.red = start->rgba.red + (end->rgba.red - start->rgba.red) * progress;
transition.green = start->rgba.green + (end->rgba.green - start->rgba.green) * progress;
transition.blue = start->rgba.blue + (end->rgba.blue - start->rgba.blue) * progress;
transition.alpha = start->rgba.alpha + (end->rgba.alpha - start->rgba.alpha) * progress;
result.alpha = transition (start->rgba.alpha, end->rgba.alpha, progress);
result.red = transition (start->rgba.red, end->rgba.red, progress);
result.green = transition (start->rgba.green, end->rgba.green, 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment