mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 21:21:21 +00:00
snapshot: Add gsk_snapshot_append_conic_gradient()
This commit is contained in:
parent
55a242bd81
commit
8706d69e60
@ -4329,6 +4329,7 @@ gtk_snapshot_append_color
|
||||
gtk_snapshot_append_layout
|
||||
gtk_snapshot_append_linear_gradient
|
||||
gtk_snapshot_append_repeating_linear_gradient
|
||||
gtk_snapshot_append_conic_gradient
|
||||
gtk_snapshot_append_border
|
||||
gtk_snapshot_append_inset_shadow
|
||||
gtk_snapshot_append_outset_shadow
|
||||
|
@ -2249,6 +2249,66 @@ gtk_snapshot_append_repeating_linear_gradient (GtkSnapshot *snapshot,
|
||||
gtk_snapshot_append_node_internal (snapshot, node);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_snapshot_append_conic_gradient:
|
||||
* @snapshot: a #GtkSnapshot
|
||||
* @bounds: the rectangle to render the gradient into
|
||||
* @center: the center point of the conic gradient
|
||||
* @rotation: the clockwise rotation in degrees of the starting angle. 0 means the
|
||||
* starting angle is the top.
|
||||
* @stops: (array length=n_stops): a pointer to an array of #GskColorStop defining the gradient
|
||||
* @n_stops: the number of elements in @stops
|
||||
*
|
||||
* Appends a conic gradient node with the given stops to @snapshot.
|
||||
*/
|
||||
void
|
||||
gtk_snapshot_append_conic_gradient (GtkSnapshot *snapshot,
|
||||
const graphene_rect_t *bounds,
|
||||
const graphene_point_t *center,
|
||||
float rotation,
|
||||
const GskColorStop *stops,
|
||||
gsize n_stops)
|
||||
{
|
||||
GskRenderNode *node;
|
||||
graphene_rect_t real_bounds;
|
||||
float dx, dy;
|
||||
const GdkRGBA *first_color;
|
||||
gboolean need_gradient = FALSE;
|
||||
int i;
|
||||
|
||||
g_return_if_fail (snapshot != NULL);
|
||||
g_return_if_fail (center != NULL);
|
||||
g_return_if_fail (stops != NULL);
|
||||
g_return_if_fail (n_stops > 1);
|
||||
|
||||
gtk_snapshot_ensure_translate (snapshot, &dx, &dy);
|
||||
graphene_rect_offset_r (bounds, dx, dy, &real_bounds);
|
||||
|
||||
first_color = &stops[0].color;
|
||||
for (i = 0; i < n_stops; i ++)
|
||||
{
|
||||
if (!gdk_rgba_equal (first_color, &stops[i].color))
|
||||
{
|
||||
need_gradient = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (need_gradient)
|
||||
node = gsk_conic_gradient_node_new (&real_bounds,
|
||||
&GRAPHENE_POINT_INIT(
|
||||
center->x + dx,
|
||||
center->y + dy
|
||||
),
|
||||
rotation,
|
||||
stops,
|
||||
n_stops);
|
||||
else
|
||||
node = gsk_color_node_new (first_color, &real_bounds);
|
||||
|
||||
gtk_snapshot_append_node_internal (snapshot, node);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_snapshot_append_radial_gradient:
|
||||
* @snapshot: a #GtkSnapshot
|
||||
|
@ -191,6 +191,13 @@ void gtk_snapshot_append_repeating_radial_gradient (GtkSnapshot
|
||||
const GskColorStop *stops,
|
||||
gsize n_stops);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_snapshot_append_conic_gradient (GtkSnapshot *snapshot,
|
||||
const graphene_rect_t *bounds,
|
||||
const graphene_point_t *center,
|
||||
float rotation,
|
||||
const GskColorStop *stops,
|
||||
gsize n_stops);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_snapshot_append_border (GtkSnapshot *snapshot,
|
||||
const GskRoundedRect *outline,
|
||||
const float border_width[4],
|
||||
|
Loading…
Reference in New Issue
Block a user