1 /* CPML - Cairo Path Manipulation Library
2 * Copyright (C) 2007-2021 Nicola Fontana <ntd at entidi.it>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 #ifndef __CPML_PRIMITIVE_PRIVATE_H__
22 #define __CPML_PRIMITIVE_PRIVATE_H__
28 * _CpmlPrimitiveClass:
29 * @name: descriptive name of the primitive type. This name
30 * will be used for debugging purpose and while
31 * dumping the primitive data.
32 * @n_points: exact number of points needed to properly define
33 * a primitive of this class type.
34 * @get_length: gets the length of a primitive.
35 * @put_extents: gets the bounding box of a primitive.
36 * @put_pair_at: gets the coordinates of a point on the primitive at
38 * @put_vector_at: gets the vector of a point on the primitive at a
40 * @get_closest_pos: gets the factor of the point on a primitive closest
41 * to another given point.
42 * @put_intersections: gets the intersection points between a primitive of
43 * this type and a primitive of any type. The number
44 * of returned intersections can be explicitely limited.
45 * @offset: creates a new primitive of tha same type parallel
46 * to the original one with a given distance.
47 * @join: join two primitives (the first one of this class type)
48 * by modifying the end point of the first one and the
49 * start point of the second one.
51 * Any primitive type must implement an instance of this class as a
52 * global variable. This will abstract the primitives and allows to
53 * access them through the cpml_primitive_...() APIs.
55 typedef struct __CpmlPrimitiveClass _CpmlPrimitiveClass
;
57 struct __CpmlPrimitiveClass
{
61 double (*get_length
) (const CpmlPrimitive
*primitive
);
62 void (*put_extents
) (const CpmlPrimitive
*primitive
,
63 CpmlExtents
*extents
);
64 void (*put_pair_at
) (const CpmlPrimitive
*primitive
,
67 void (*put_vector_at
) (const CpmlPrimitive
*primitive
,
70 double (*get_closest_pos
) (const CpmlPrimitive
*primitive
,
71 const CpmlPair
*pair
);
72 size_t (*put_intersections
) (const CpmlPrimitive
*primitive
,
73 const CpmlPrimitive
*primitive2
,
76 void (*offset
) (CpmlPrimitive
*primitive
,
78 int (*join
) (CpmlPrimitive
*primitive
,
79 CpmlPrimitive
*primitive2
);
83 const _CpmlPrimitiveClass
* _cpml_line_get_class (void);
84 const _CpmlPrimitiveClass
* _cpml_arc_get_class (void);
85 const _CpmlPrimitiveClass
* _cpml_curve_get_class (void);
86 const _CpmlPrimitiveClass
* _cpml_close_get_class (void);
92 #endif /* __CPML_PRIMITIVE_PRIVATE_H__ */