[gtk/matthiasc/lottie2: 15/24] path: Fix serialization for circles
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/lottie2: 15/24] path: Fix serialization for circles
- Date: Thu, 26 Nov 2020 14:19:30 +0000 (UTC)
commit 0eef60236ad51501d756dae1ac8cf658e2b41712
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Nov 24 02:20:09 2020 -0500
path: Fix serialization for circles
The svg A can not do a full circle, since it is
a two point parametrization - if the start and
end point are the same, it draws nothing.
So, use two arcs.
gsk/gskpath.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/gsk/gskpath.c b/gsk/gskpath.c
index d1e19fd470..dbf46c7e9e 100644
--- a/gsk/gskpath.c
+++ b/gsk/gskpath.c
@@ -505,17 +505,22 @@ 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_printf (string, "M %g %g A %g %g 0 %u %u %g %g",
- self->center.x + start.x, self->center.y + start.y,
- self->radius, self->radius,
- fabs (self->start_angle - self->end_angle) > 180 ? 1 : 0,
- self->start_angle < self->end_angle ? 0 : 1,
- self->center.x + end.x, self->center.y + end.y);
+ double mid_angle = (self->end_angle - self->start_angle) / 2;
+ 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 mid = GRAPHENE_POINT_INIT (self->center.x + cos (DEG_TO_RAD (mid_angle)) * self->radius,
+ self->center.y + sin (DEG_TO_RAD (mid_angle)) *
self->radius);
+ graphene_point_t end = GRAPHENE_POINT_INIT (self->center.x + cos (DEG_TO_RAD (self->end_angle)) *
self->radius,
+ self->center.y + sin (DEG_TO_RAD (self->end_angle)) *
self->radius);
+
+ g_string_append_printf (string, "M %g %g ", start.x, start.y);
+ g_string_append_printf (string, "A %g %g 0 1 0 %g %g ",
+ self->radius, self->radius, mid.x, mid.y);
+ g_string_append_printf (string, "A %g %g 0 1 0 %g %g ",
+ self->radius, self->radius, end.x, end.y);
+
+ if (fabs (self->start_angle - self->end_angle) >= 360)
+ g_string_append (string, "Z");
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]