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
133
|
#ifndef SEEN_DISPLAY_CURVE_H
#define SEEN_DISPLAY_CURVE_H
/** \file
* Wrapper around an array of NArtBpath objects.
*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
*
* Copyright (C) 2000 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
* Copyright (C) 2002 Lauris Kaplinski
*
* Released under GNU GPL
*/
#include <glib/gtypes.h>
#include <glib/gslist.h>
#include "libnr/nr-forward.h"
#include "libnr/nr-point.h"
/// Wrapper around NArtBpath.
struct SPCurve {
gint refcount;
NArtBpath *bpath;
/// Index in bpath[] of NR_END element.
gint end;
/// Allocated size (i.e., capacity) of bpath[] array. Not to be confused
/// with the SP_CURVE_LENGTH macro, which returns the logical length of
/// the path (i.e., index of NR_END).
gint length;
/// Index in bpath[] of the start (i.e., moveto element) of the last
/// subpath in this path.
gint substart;
/// Previous moveto position.
/// \note This is used for coalescing moveto's, whereas if we're to
/// conform to the SVG spec then we mustn't coalesce movetos if we have
/// midpoint markers. Ref:
/// http://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes
/// (first subitem of the item about zero-length path segments)
NR::Point movePos;
/// True iff bpath points to read-only, static storage (see callers of
/// sp_curve_new_from_static_bpath), in which case we shouldn't free
/// bpath and shouldn't write through it.
bool sbpath : 1;
/// True iff current point is defined. Initially false for a new curve;
/// becomes true after moveto; becomes false on closepath. Curveto,
/// lineto etc. require hascpt; hascpt remains true after lineto/curveto.
bool hascpt : 1;
/// True iff previous was moveto.
bool posSet : 1;
/// True iff bpath end is moving.
bool moving : 1;
/// True iff all subpaths are closed.
bool closed : 1;
};
#define SP_CURVE_LENGTH(c) (((SPCurve const *)(c))->end)
#define SP_CURVE_BPATH(c) (((SPCurve const *)(c))->bpath)
#define SP_CURVE_SEGMENT(c,i) (((SPCurve const *)(c))->bpath + (i))
/* Constructors */
SPCurve *sp_curve_new();
SPCurve *sp_curve_new_sized(gint length);
SPCurve *sp_curve_new_from_bpath(NArtBpath *bpath);
SPCurve *sp_curve_new_from_static_bpath(NArtBpath const *bpath);
SPCurve *sp_curve_new_from_foreign_bpath(NArtBpath const bpath[]);
SPCurve *sp_curve_ref(SPCurve *curve);
SPCurve *sp_curve_unref(SPCurve *curve);
SPCurve *sp_curve_copy(SPCurve *curve);
SPCurve *sp_curve_concat(GSList const *list);
GSList *sp_curve_split(SPCurve const *curve);
void sp_curve_transform(SPCurve *curve, NR::Matrix const &);
void sp_curve_transform(SPCurve *curve, NR::translate const &);
void sp_curve_stretch_endpoints(SPCurve *curve, NR::Point const &, NR::Point const &);
void sp_curve_move_endpoints(SPCurve *curve, NR::Point const &,
NR::Point const &);
/* Methods */
void sp_curve_reset(SPCurve *curve);
void sp_curve_moveto(SPCurve *curve, NR::Point const &p);
void sp_curve_moveto(SPCurve *curve, gdouble x, gdouble y);
void sp_curve_lineto(SPCurve *curve, NR::Point const &p);
void sp_curve_lineto(SPCurve *curve, gdouble x, gdouble y);
void sp_curve_lineto_moving(SPCurve *curve, gdouble x, gdouble y);
void sp_curve_curveto(SPCurve *curve, NR::Point const &p0, NR::Point const &p1, NR::Point const &p2);
void sp_curve_curveto(SPCurve *curve, gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdouble y2);
void sp_curve_closepath(SPCurve *curve);
void sp_curve_closepath_current(SPCurve *curve);
SPCurve *sp_curve_append_continuous(SPCurve *c0, SPCurve const *c1, gdouble tolerance);
#define sp_curve_is_empty sp_curve_empty
bool sp_curve_empty(SPCurve *curve);
NArtBpath *sp_curve_last_bpath(SPCurve const *curve);
NArtBpath *sp_curve_first_bpath(SPCurve const *curve);
NR::Point sp_curve_first_point(SPCurve const *curve);
NR::Point sp_curve_last_point(SPCurve const *curve);
NR::Point sp_curve_second_point(SPCurve const *curve);
NR::Point sp_curve_penultimate_point(SPCurve const *curve);
void sp_curve_append(SPCurve *curve, SPCurve const *curve2, bool use_lineto);
SPCurve *sp_curve_reverse(SPCurve const *curve);
void sp_curve_backspace(SPCurve *curve);
#endif /* !SEEN_DISPLAY_CURVE_H */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
|