[gtk/wip/otte/lottie: 2492/2503] path: Add gsk_path_builder_add_ellipse()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/lottie: 2492/2503] path: Add gsk_path_builder_add_ellipse()
- Date: Tue, 13 Jul 2021 04:28:09 +0000 (UTC)
commit 67532107ff5a17e6a4d8a0cfd8b6a1f2c4be2480
Author: Benjamin Otte <otte redhat com>
Date: Fri Dec 25 21:31:06 2020 +0100
path: Add gsk_path_builder_add_ellipse()
gsk/gskpathbuilder.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
gsk/gskpathbuilder.h | 4 ++++
2 files changed, 50 insertions(+)
---
diff --git a/gsk/gskpathbuilder.c b/gsk/gskpathbuilder.c
index c5e9533686..3b578627a0 100644
--- a/gsk/gskpathbuilder.c
+++ b/gsk/gskpathbuilder.c
@@ -457,6 +457,52 @@ gsk_path_builder_add_circle (GskPathBuilder *builder,
gsk_path_builder_add_contour (builder, contour);
}
+/**
+ * gsk_path_builder_add_ellipse:
+ * @builder: a #GskPathBuilder
+ * @center: the center point of the ellipse
+ * @radius: the radius of the ellipse in x/y direction
+ *
+ * Adds an ellipse with the given @center and the @radius in
+ * x/y direction.
+ **/
+void
+gsk_path_builder_add_ellipse (GskPathBuilder *self,
+ const graphene_point_t *center,
+ const graphene_size_t *radius)
+{
+ const float weight = sqrt(0.5f);
+ graphene_point_t pts[8];
+
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (center != NULL);
+ g_return_if_fail (radius != NULL);
+
+ pts[0] = GRAPHENE_POINT_INIT (center->x + radius->width / 2,
+ center->y);
+ pts[1] = GRAPHENE_POINT_INIT (center->x + radius->width / 2,
+ center->y + radius->height / 2);
+ pts[2] = GRAPHENE_POINT_INIT (center->x,
+ center->y + radius->height / 2);
+ pts[3] = GRAPHENE_POINT_INIT (center->x - radius->width / 2,
+ center->y + radius->height / 2);
+ pts[4] = GRAPHENE_POINT_INIT (center->x - radius->width / 2,
+ center->y);
+ pts[5] = GRAPHENE_POINT_INIT (center->x - radius->width / 2,
+ center->y - radius->height / 2);
+ pts[6] = GRAPHENE_POINT_INIT (center->x,
+ center->y - radius->height / 2);
+ pts[7] = GRAPHENE_POINT_INIT (center->x + radius->width / 2,
+ center->y - radius->height / 2);
+
+ gsk_path_builder_move_to (self, pts[0].x, pts[0].y);
+ gsk_path_builder_conic_to (self, pts[1].x, pts[1].y, pts[2].x, pts[2].y, weight);
+ gsk_path_builder_conic_to (self, pts[3].x, pts[3].y, pts[4].x, pts[4].y, weight);
+ gsk_path_builder_conic_to (self, pts[5].x, pts[5].y, pts[6].x, pts[6].y, weight);
+ gsk_path_builder_conic_to (self, pts[7].x, pts[7].y, pts[0].x, pts[0].y, weight);
+ gsk_path_builder_close (self);
+}
+
/**
* gsk_path_builder_move_to:
* @builder: a #GskPathBuilder
diff --git a/gsk/gskpathbuilder.h b/gsk/gskpathbuilder.h
index 750f8133b8..0a4024b60e 100644
--- a/gsk/gskpathbuilder.h
+++ b/gsk/gskpathbuilder.h
@@ -62,6 +62,10 @@ GDK_AVAILABLE_IN_ALL
void gsk_path_builder_add_circle (GskPathBuilder *builder,
const graphene_point_t *center,
float radius);
+GDK_AVAILABLE_IN_ALL
+void gsk_path_builder_add_ellipse (GskPathBuilder *self,
+ const graphene_point_t *center,
+ const graphene_size_t *radius);
/* next function implemented in gskpathmeasure.c */
GDK_AVAILABLE_IN_ALL
void gsk_path_builder_add_segment (GskPathBuilder *builder,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]