[gtk/path-work-rebased: 33/118] path: Add GSK_CIRCLE_POINT_INIT() to initialize points on the circle
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/path-work-rebased: 33/118] path: Add GSK_CIRCLE_POINT_INIT() to initialize points on the circle
- Date: Sat, 4 Dec 2021 07:28:35 +0000 (UTC)
commit 982ef87c600fea2b031e5f4857388a026ae29341
Author: Benjamin Otte <otte redhat com>
Date: Sat Nov 28 07:23:19 2020 +0100
path: Add GSK_CIRCLE_POINT_INIT() to initialize points on the circle
This is just splitting out a commonly done operation into a macro.
gsk/gskpath.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/gsk/gskpath.c b/gsk/gskpath.c
index 68ae1246d2..3519f14a6d 100644
--- a/gsk/gskpath.c
+++ b/gsk/gskpath.c
@@ -547,24 +547,24 @@ gsk_circle_contour_get_flags (const GskContour *contour)
return 0;
}
+#define GSK_CIRCLE_POINT_INIT(self, angle) \
+ GRAPHENE_POINT_INIT ((self)->center.x + cos (DEG_TO_RAD (angle)) * self->radius, \
+ (self)->center.y + sin (DEG_TO_RAD (angle)) * self->radius)
+
static void
gsk_circle_contour_print (const GskContour *contour,
GString *string)
{
const GskCircleContour *self = (const GskCircleContour *) contour;
- graphene_point_t start = GRAPHENE_POINT_INIT (cos (DEG_TO_RAD (self->start_angle)) * self->radius,
- sin (DEG_TO_RAD (self->start_angle)) * self->radius);
- graphene_point_t end = GRAPHENE_POINT_INIT (cos (DEG_TO_RAD (self->end_angle)) * self->radius,
- sin (DEG_TO_RAD (self->end_angle)) * self->radius);
g_string_append (string, "M ");
- _g_string_append_point (string, &GRAPHENE_POINT_INIT (self->center.x + start.x, self->center.y + start.y));
+ _g_string_append_point (string, &GSK_CIRCLE_POINT_INIT (self, self->start_angle));
g_string_append (string, " A ");
_g_string_append_point (string, &GRAPHENE_POINT_INIT (self->radius, self->radius));
g_string_append_printf (string, " 0 %u %u ",
fabs (self->start_angle - self->end_angle) > 180 ? 1 : 0,
self->start_angle < self->end_angle ? 0 : 1);
- _g_string_append_point (string, &GRAPHENE_POINT_INIT (self->center.x + end.x, self->center.y + end.y));
+ _g_string_append_point (string, &GSK_CIRCLE_POINT_INIT (self, self->end_angle));
if (fabs (self->start_angle - self->end_angle >= 360))
g_string_append (string, " z");
}
@@ -621,8 +621,7 @@ gsk_circle_contour_foreach (const GskContour *contour,
gpointer user_data)
{
const GskCircleContour *self = (const GskCircleContour *) contour;
- graphene_point_t start = GRAPHENE_POINT_INIT (self->center.x + cos (DEG_TO_RAD (self->start_angle)) *
self->radius,
- self->center.y + sin (DEG_TO_RAD (self->start_angle)) *
self->radius);
+ graphene_point_t start = GSK_CIRCLE_POINT_INIT (self, self->start_angle);
if (!func (GSK_PATH_MOVE, &start, 1, user_data))
return FALSE;
@@ -676,8 +675,7 @@ gsk_circle_contour_get_point (const GskContour *contour,
float angle = self->start_angle + distance/length * delta;
graphene_point_t p;
- p = GRAPHENE_POINT_INIT (self->center.x + cos (DEG_TO_RAD (angle)) * self->radius,
- self->center.y + sin (DEG_TO_RAD (angle)) * self->radius);
+ p = GSK_CIRCLE_POINT_INIT (self, angle);
if (pos)
*pos = p;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]