]> git.ipfire.org Git - thirdparty/cups.git/blob - pdftops/SplashPath.h
0e6fffbb76332244de48fdc496aa0745ef128995
[thirdparty/cups.git] / pdftops / SplashPath.h
1 //========================================================================
2 //
3 // SplashPath.h
4 //
5 //========================================================================
6
7 #ifndef SPLASHPATH_H
8 #define SPLASHPATH_H
9
10 #include <config.h>
11
12 #ifdef USE_GCC_PRAGMAS
13 #pragma interface
14 #endif
15
16 #include "SplashTypes.h"
17
18 //------------------------------------------------------------------------
19 // SplashPathPoint
20 //------------------------------------------------------------------------
21
22 struct SplashPathPoint {
23 SplashCoord x, y;
24 };
25
26 //------------------------------------------------------------------------
27 // SplashPath.flags
28 //------------------------------------------------------------------------
29
30 // first point on each subpath sets this flag
31 #define splashPathFirst 0x01
32
33 // last point on each subpath sets this flag
34 #define splashPathLast 0x02
35
36 // if the subpath is closed, its first and last points must be
37 // identical, and must set this flag
38 #define splashPathClosed 0x04
39
40 // curve control points set this flag
41 #define splashPathCurve 0x08
42
43 // clockwise arc center points set this flag
44 #define splashPathArcCW 0x10
45
46 //------------------------------------------------------------------------
47 // SplashPath
48 //------------------------------------------------------------------------
49
50 class SplashPath {
51 public:
52
53 // Create an empty path.
54 SplashPath();
55
56 // Copy a path.
57 SplashPath *copy() { return new SplashPath(this); }
58
59 ~SplashPath();
60
61 // Append <path> to <this>.
62 void append(SplashPath *path);
63
64 // Start a new subpath.
65 SplashError moveTo(SplashCoord x, SplashCoord y);
66
67 // Add a line segment to the last subpath.
68 SplashError lineTo(SplashCoord x, SplashCoord y);
69
70 // Add a third-order (cubic) Bezier curve segment to the last
71 // subpath.
72 SplashError curveTo(SplashCoord x1, SplashCoord y1,
73 SplashCoord x2, SplashCoord y2,
74 SplashCoord x3, SplashCoord y3);
75
76 // Add a clockwise circular arc with center (xc, yc) and endpoint
77 // (x1, y1).
78 SplashError arcCWTo(SplashCoord x1, SplashCoord y1,
79 SplashCoord xc, SplashCoord yc);
80
81 // Close the last subpath, adding a line segment if necessary.
82 SplashError close();
83
84 // Add (<dx>, <dy>) to every point on this path.
85 void offset(SplashCoord dx, SplashCoord dy);
86
87 // Get the points on the path.
88 int getLength() { return length; }
89 void getPoint(int i, double *x, double *y, Guchar *f)
90 { *x = pts[i].x; *y = pts[i].y; *f = flags[i]; }
91
92 // Get the current point.
93 GBool getCurPt(SplashCoord *x, SplashCoord *y);
94
95 private:
96
97 SplashPath(SplashPath *path);
98 void grow(int nPts);
99 GBool noCurrentPoint() { return curSubpath == length; }
100 GBool onePointSubpath() { return curSubpath == length - 1; }
101 GBool openSubpath() { return curSubpath < length - 1; }
102
103 SplashPathPoint *pts; // array of points
104 Guchar *flags; // array of flags
105 int length, size; // length/size of the pts and flags arrays
106 int curSubpath; // index of first point in last subpath
107
108 friend class SplashXPath;
109 friend class Splash;
110 };
111
112 #endif