[AdgStroke] Using adg_entity_apply_local_matrix()
[adg.git] / cpml / cpml-close.c
blobfe78728d1909cda964fa63f5d4133247e6cb3433
1 /* CPML - Cairo Path Manipulation Library
2 * Copyright (C) 2008, 2009 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 /**
22 * SECTION:close
23 * @Section_Id:CpmlClose
24 * @title: CpmlClose
25 * @short_description: Straigth line used to close cyclic segments
27 * The following functions manipulate %CAIRO_PATH_CLOSE_PATH
28 * #CpmlPrimitive. No validation is made on the input so use the
29 * following methods only when you are sure the
30 * <varname>primitive</varname> argument is effectively a close path.
32 * This primitive management is almost identical to straight lines,
33 * but taking properly start and end points.
34 **/
37 #include "cpml-close.h"
38 #include "cpml-pair.h"
39 #include "cpml-line.h"
42 /**
43 * cpml_close_type_get_npoints:
45 * Returns the number of points needed to properly specify a close primitive.
46 * This is a bit tricky: the close path primitive can be specified with
47 * a single point but it has an implicit second point, the start point
48 * of the source segment. This means retrieving a second point from a
49 * cairo path is a valid operation and must return the start point of
50 * the source segment.
52 * Return value: 2
53 **/
54 int
55 cpml_close_type_get_npoints(void)
57 return 2;
60 /**
61 * cpml_close_pair_at:
62 * @close: the #CpmlPrimitive close data
63 * @pair: the destination pair
64 * @pos: the position value
66 * Given the @close path virtual primitive, finds the coordinates
67 * at position @pos (where 0 is the start and 1 is the end) and
68 * stores the result in @pair.
70 * @pos can be less than 0 or greater than 1, in which case the
71 * coordinates are interpolated.
72 **/
73 void
74 cpml_close_pair_at(const CpmlPrimitive *close, CpmlPair *pair, double pos)
76 cpml_line_pair_at(close, pair, pos);
79 /**
80 * cpml_close_vector_at:
81 * @close: the #CpmlPrimitive close data
82 * @vector: the destination vector
83 * @pos: the position value
85 * Gets the slope on @close at the position @pos. Being the
86 * close a straight line, the vector is always the same, so
87 * @pos is not used.
88 **/
89 void
90 cpml_close_vector_at(const CpmlPrimitive *close,
91 CpmlVector *vector, double pos)
93 cpml_line_vector_at(close, vector, pos);
96 /**
97 * cpml_close_near_pos:
98 * @close: the #CpmlPrimitive close data
99 * @pair: the coordinates of the subject point
101 * Returns the pos value of the point on @close nearest to @pair.
102 * The returned value is always between 0 and 1.
104 * Return value: the pos value, always between 0 and 1
106 double
107 cpml_close_near_pos(const CpmlPrimitive *close, const CpmlPair *pair)
109 return cpml_line_near_pos(close, pair);
113 * cpml_close_offset:
114 * @close: the #CpmlPrimitive close data
115 * @offset: distance for the computed parallel close
117 * Given a close segment specified by the @close primitive data,
118 * computes the parallel close distant @offset from the original one
119 * and returns the result by changing @close.
121 void
122 cpml_close_offset(CpmlPrimitive *close, double offset)
124 cpml_line_offset(close, offset);