summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-09-11 23:50:25 -0400
committerTimm Bäder <mail@baedert.org>2020-09-18 15:39:04 +0200
commit66d16049c38be502642fe28e834a6bd528cb57b7 (patch)
treefa43176cd462484784fd296dff57802fc2212ff6 /gtk
parent0c6226c20b2b3dcf3bc77595edcd28b0d4626dfb (diff)
downloadgtk+-66d16049c38be502642fe28e834a6bd528cb57b7.tar.gz
snapshot: Add api for radial gradients
These are the equivalents of the linear gradient apis.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtksnapshot.c76
-rw-r--r--gtk/gtksnapshot.h20
2 files changed, 96 insertions, 0 deletions
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index 7de6594167..123bfcd773 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -1967,6 +1967,82 @@ gtk_snapshot_append_repeating_linear_gradient (GtkSnapshot *snapshot,
gtk_snapshot_append_node_internal (snapshot, node);
}
+void
+gtk_snapshot_append_radial_gradient (GtkSnapshot *snapshot,
+ const graphene_rect_t *bounds,
+ const graphene_point_t *center,
+ float radius,
+ float scale,
+ float start,
+ float end,
+ const GskColorStop *stops,
+ gsize n_stops)
+{
+ GskRenderNode *node;
+ graphene_rect_t real_bounds;
+ graphene_point_t real_center;
+ float scale_x, scale_y, dx, dy;
+
+ 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_affine (snapshot, &scale_x, &scale_y, &dx, &dy);
+ gtk_graphene_rect_scale_affine (bounds, scale_x, scale_y, dx, dy, &real_bounds);
+ real_center.x = scale_x * center->x + dx;
+ real_center.y = scale_y * center->y + dy;
+
+ node = gsk_radial_gradient_node_new (&real_bounds,
+ &real_center,
+ radius,
+ scale,
+ start,
+ end,
+ stops,
+ n_stops);
+
+ gtk_snapshot_append_node_internal (snapshot, node);
+}
+
+void
+gtk_snapshot_append_repeating_radial_gradient (GtkSnapshot *snapshot,
+ const graphene_rect_t *bounds,
+ const graphene_point_t *center,
+ float radius,
+ float scale,
+ float start,
+ float end,
+ const GskColorStop *stops,
+ gsize n_stops)
+{
+ GskRenderNode *node;
+ graphene_rect_t real_bounds;
+ graphene_point_t real_center;
+ float scale_x, scale_y, dx, dy;
+
+ 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_affine (snapshot, &scale_x, &scale_y, &dx, &dy);
+ gtk_graphene_rect_scale_affine (bounds, scale_x, scale_y, dx, dy, &real_bounds);
+ real_center.x = scale_x * center->x + dx;
+ real_center.y = scale_y * center->y + dy;
+
+ node = gsk_repeating_radial_gradient_node_new (&real_bounds,
+ &real_center,
+ radius,
+ scale,
+ start,
+ end,
+ stops,
+ n_stops);
+
+ gtk_snapshot_append_node_internal (snapshot, node);
+}
+
/**
* gtk_snapshot_append_border:
* @snapshot: a #GtkSnapshot
diff --git a/gtk/gtksnapshot.h b/gtk/gtksnapshot.h
index 406a02da58..9be3382a52 100644
--- a/gtk/gtksnapshot.h
+++ b/gtk/gtksnapshot.h
@@ -165,6 +165,26 @@ void gtk_snapshot_append_repeating_linear_gradient (GtkSnapshot
const GskColorStop *stops,
gsize n_stops);
GDK_AVAILABLE_IN_ALL
+void gtk_snapshot_append_radial_gradient (GtkSnapshot *snapshot,
+ const graphene_rect_t *bounds,
+ const graphene_point_t *center,
+ float radius,
+ float scale,
+ float start,
+ float end,
+ const GskColorStop *stops,
+ gsize n_stops);
+GDK_AVAILABLE_IN_ALL
+void gtk_snapshot_append_repeating_radial_gradient (GtkSnapshot *snapshot,
+ const graphene_rect_t *bounds,
+ const graphene_point_t *center,
+ float radius,
+ float scale,
+ float start,
+ float end,
+ 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],