1 // SPDX-License-Identifier: GPL-2.0-or-later
2 #ifndef INKSCAPE_HELPER_PATH_STROKE_H
3 #define INKSCAPE_HELPER_PATH_STROKE_H
4 
5 /* Authors:
6  *   Liam P. White
7  *   Tavmjong Bah
8  *
9  * Copyright (C) 2014-2015 Authors
10  *
11  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
12  */
13 
14 #include <2geom/path.h>
15 #include <2geom/pathvector.h>
16 
17 namespace Inkscape {
18 
19 enum LineJoinType {
20     JOIN_BEVEL,
21     JOIN_ROUND,
22     JOIN_MITER,
23     JOIN_MITER_CLIP,
24     JOIN_EXTRAPOLATE,
25     JOIN_EXTRAPOLATE1,
26     JOIN_EXTRAPOLATE2,
27     JOIN_EXTRAPOLATE3,
28 };
29 
30 enum LineCapType {
31     BUTT_FLAT,
32     BUTT_ROUND,
33     BUTT_SQUARE,
34     BUTT_PEAK, // This is not a line ending supported by the SVG standard.
35 };
36 
37 /**
38  * Strokes the path given by @a input.
39  * Joins may behave oddly if the width is negative.
40  *
41  * @param[in] input Input path.
42  * @param[in] width Stroke width.
43  * @param[in] miter Miter limit. Only used when @a join is one of JOIN_MITER, JOIN_MITER_CLIP, and JOIN_EXTRAPOLATE.
44  * @param[in] join  Line join type used during offset. Member of LineJoinType enum.
45  * @param[in] cap   Line cap type used during stroking. Member of LineCapType enum.
46  * @param[in] tolerance Tolerance, values smaller than 0 lead to automatic tolerance depending on width.
47  *
48  * @return Stroked path.
49  *         If the input path is closed, the resultant vector will contain two paths.
50  *         Otherwise, there should be only one in the output.
51  */
52 Geom::PathVector outline(
53         Geom::Path const& input,
54         double width,
55         double miter,
56         LineJoinType join = JOIN_BEVEL,
57         LineCapType cap = BUTT_FLAT,
58         double tolerance = -1);
59 
60 /**
61  * Offset the input path by @a width.
62  * Joins may behave oddly if the width is negative.
63  *
64  * @param[in] input Input path.
65  * @param[in] width Amount to offset.
66  * @param[in] miter Miter limit. Only used when @a join is one of JOIN_MITER, JOIN_MITER_CLIP, and JOIN_EXTRAPOLATE.
67  * @param[in] join  Line join type used during offset. Member of LineJoinType enum.
68  * @param[in] tolerance Tolerance, values smaller than 0 lead to automatic tolerance depending on width.
69  *
70  * @return Offsetted output.
71  */
72 Geom::Path half_outline(
73         Geom::Path const& input,
74         double width,
75         double miter,
76         LineJoinType join = JOIN_BEVEL,
77         double tolerance = -1);
78 
79 /**
80  * Builds a join on the provided path.
81  * Joins may behave oddly if the width is negative.
82  *
83  * @param[inout] res      The path to build the join on.
84  *                        The outgoing path (or a portion thereof) will be appended after the join is created.
85  *                        Previous segments may be modified as an optimization, beware!
86  *
87  * @param[in]    outgoing The segment to append on the outgoing portion of the join.
88  * @param[in]    in_tang  The end tangent to consider on the input path.
89  * @param[in]    out_tang The begin tangent to consider on the output path.
90  * @param[in]    width
91  * @param[in]    miter
92  * @param[in]    join
93  */
94 void outline_join(Geom::Path &res, Geom::Path const& outgoing, Geom::Point in_tang, Geom::Point out_tang, double width, double miter, LineJoinType join);
95 
96 } // namespace Inkscape
97 
98 #endif // INKSCAPE_HELPER_PATH_STROKE_H
99 
100 /*
101   Local Variables:
102   mode:c++
103   c-file-style:"stroustrup"
104   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
105   indent-tabs-mode:nil
106   fill-column:99
107   End:
108 */
109 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :
110