summaryrefslogtreecommitdiff
path: root/gsk/gskcontourprivate.h
blob: cf5bf5493c0cbaffba9c700cbf7ef8dd6a2c4566 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
 * Copyright © 2020 Benjamin Otte
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors: Benjamin Otte <otte@gnome.org>
 */


#ifndef __GSK_CONTOUR_PRIVATE_H__
#define __GSK_CONTOUR_PRIVATE_H__

#include <gskpath.h>

#include "gskpathopprivate.h"

G_BEGIN_DECLS

/* A path is flat if it contains no cubic or conic segments.
 * A path is closed if all its contours end with a GSK_PATH_CLOSE
 * operation.
 */
typedef enum
{
  GSK_PATH_FLAT,
  GSK_PATH_CLOSED
} GskPathFlags;

typedef struct _GskContour GskContour;

GskContour *            gsk_rect_contour_new                    (const graphene_rect_t  *rect);
GskContour *            gsk_circle_contour_new                  (const graphene_point_t *center,
                                                                 float                   radius,
                                                                 float                   start_angle,
                                                                 float                   end_angle);
GskContour *            gsk_standard_contour_new                (GskPathFlags            flags,
                                                                 const graphene_point_t *points,
                                                                 gsize                   n_points,
                                                                 const gskpathop        *ops,
                                                                 gsize                   n_ops,
                                                                 gssize                  offset);

void                    gsk_contour_copy                        (GskContour *            dest,
                                                                 const GskContour       *src);
GskContour *            gsk_contour_dup                         (const GskContour       *src);

GskContour *            gsk_contour_reverse                     (const GskContour       *src);

gsize                   gsk_contour_get_size                    (const GskContour       *self);
GskPathFlags            gsk_contour_get_flags                   (const GskContour       *self);
void                    gsk_contour_print                       (const GskContour       *self,
                                                                 GString                *string);
gboolean                gsk_contour_get_bounds                  (const GskContour       *self,
                                                                 graphene_rect_t        *bounds);
gpointer                gsk_contour_init_measure                (const GskContour       *self,
                                                                 float                   tolerance,
                                                                 float                  *out_length);
void                    gsk_contour_free_measure                (const GskContour       *self,
                                                                 gpointer                data);
gboolean                gsk_contour_foreach                     (const GskContour       *self,
                                                                 float                   tolerance,
                                                                 GskPathForeachFunc      func,
                                                                 gpointer                user_data);
void                    gsk_contour_get_start_end               (const GskContour       *self,
                                                                 graphene_point_t       *start,
                                                                 graphene_point_t       *end);
void                    gsk_contour_get_point                   (const GskContour       *self,
                                                                 gpointer                measure_data,
                                                                 float                   distance,
                                                                 graphene_point_t       *pos,
                                                                 graphene_vec2_t        *tangent);
float                   gsk_contour_get_curvature               (const GskContour       *self,
                                                                 gpointer                measure_data,
                                                                 float                   distance,
                                                                 graphene_point_t       *center);
gboolean                gsk_contour_get_closest_point           (const GskContour       *self,
                                                                 gpointer                measure_data,
                                                                 float                   tolerance,
                                                                 const graphene_point_t *point,
                                                                 float                   threshold,
                                                                 float                  *out_distance,
                                                                 graphene_point_t       *out_pos,
                                                                 float                  *out_offset,
                                                                 graphene_vec2_t        *out_tangent);
int                     gsk_contour_get_winding                 (const GskContour       *self,
                                                                 gpointer                measure_data,
                                                                 const graphene_point_t *point,
                                                                 gboolean               *on_edge);
void                    gsk_contour_add_segment                 (const GskContour       *self,
                                                                 GskPathBuilder         *builder,
                                                                 gpointer                measure_data,
                                                                 gboolean                emit_move_to,
                                                                 float                   start,
                                                                 float                   end);
gboolean                gsk_contour_get_stroke_bounds           (const GskContour       *self,
                                                                 const GskStroke        *stroke,
                                                                 graphene_rect_t        *bounds);
void                    gsk_contour_add_stroke                  (const GskContour       *contour,
                                                                 GskPathBuilder         *builder,
                                                                 GskStroke              *stroke);
void                    gsk_contour_default_add_stroke          (const GskContour       *contour,
                                                                 GskPathBuilder         *builder,
                                                                 GskStroke              *stroke);

void                    gsk_contour_offset                      (const GskContour       *contour,
                                                                 GskPathBuilder         *builder,
                                                                 float                   distance,
                                                                 GskLineJoin             line_join,
                                                                 float                   miter_limit);
void                    gsk_contour_default_offset              (const GskContour       *contour,
                                                                 GskPathBuilder         *builder,
                                                                 float                   distance,
                                                                 GskLineJoin             line_join,
                                                                 float                   miter_limit);

gboolean                gsk_contour_is_convex                   (const GskContour       *contour);

G_END_DECLS

#endif /* __GSK_CONTOUR_PRIVATE_H__ */