summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-11-25 23:00:58 -0500
committerMatthias Clasen <mclasen@redhat.com>2020-11-25 23:02:14 -0500
commitb96dedd4316f766ca8262a29d9c924c3fb3fce66 (patch)
tree6b6cfc8ea84069e3220cfd782e986d0107c890d9
parent0cdfd7959616e426f945340cdc807991ad36fb94 (diff)
downloadgtk+-b96dedd4316f766ca8262a29d9c924c3fb3fce66.tar.gz
path: Implement gsk_circle_contour_get_bounds
Add tight bounding boxes for arcs.
-rw-r--r--gsk/gskpath.c47
1 files changed, 41 insertions, 6 deletions
diff --git a/gsk/gskpath.c b/gsk/gskpath.c
index b20ad2528c..c5bd85d8bb 100644
--- a/gsk/gskpath.c
+++ b/gsk/gskpath.c
@@ -531,12 +531,47 @@ gsk_circle_contour_get_bounds (const GskContour *contour,
{
const GskCircleContour *self = (const GskCircleContour *) contour;
- /* XXX: handle partial circles */
- graphene_rect_init (rect,
- self->center.x - self->radius,
- self->center.y - self->radius,
- 2 * self->radius,
- 2 * self->radius);
+ if (fabs (self->start_angle - self->end_angle) >= 360)
+ graphene_rect_init (rect,
+ self->center.x - self->radius,
+ self->center.y - self->radius,
+ 2 * self->radius,
+ 2 * self->radius);
+ else
+ {
+ graphene_point_t p;
+
+ p = 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_rect_init (rect, p.x, p.y, 0, 0);
+
+ p = 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);
+
+ graphene_rect_expand (rect, &p, rect);
+
+ if (self->start_angle <= 0 && self->end_angle >= 0)
+ {
+ p = GRAPHENE_POINT_INIT (self->center.x + self->radius, self->center.y);
+ graphene_rect_expand (rect, &p, rect);
+ }
+ if (self->start_angle <= 90 && self->end_angle >= 90)
+ {
+ p = GRAPHENE_POINT_INIT (self->center.x, self->center.y + self->radius);
+ graphene_rect_expand (rect, &p, rect);
+ }
+ if (self->start_angle <= 180 && self->end_angle >= 180)
+ {
+ p = GRAPHENE_POINT_INIT (self->center.x - self->radius, self->center.y);
+ graphene_rect_expand (rect, &p, rect);
+ }
+ if (self->start_angle <= 270 && self->end_angle >= 270)
+ {
+ p = GRAPHENE_POINT_INIT (self->center.x, self->center.y - self->radius);
+ graphene_rect_expand (rect, &p, rect);
+ }
+ }
return TRUE;
}