Bringing apdf from vendor into main branch.
[AROS-Contrib.git] / apdf / splash / SplashPath.h
blobe06d6de3f9c6cb0899394e7e340349d30ce878cf
1 //========================================================================
2 //
3 // SplashPath.h
4 //
5 //========================================================================
7 #ifndef SPLASHPATH_H
8 #define SPLASHPATH_H
10 #include <aconf.h>
12 #ifdef USE_GCC_PRAGMAS
13 #pragma interface
14 #endif
16 #include "SplashTypes.h"
18 //------------------------------------------------------------------------
19 // SplashPathPoint
20 //------------------------------------------------------------------------
22 struct SplashPathPoint {
23 SplashCoord x, y;
26 //------------------------------------------------------------------------
27 // SplashPath.flags
28 //------------------------------------------------------------------------
30 // first point on each subpath sets this flag
31 #define splashPathFirst 0x01
33 // last point on each subpath sets this flag
34 #define splashPathLast 0x02
36 // if the subpath is closed, its first and last points must be
37 // identical, and must set this flag
38 #define splashPathClosed 0x04
40 // curve control points set this flag
41 #define splashPathCurve 0x08
43 // clockwise arc center points set this flag
44 #define splashPathArcCW 0x10
46 //------------------------------------------------------------------------
47 // SplashPath
48 //------------------------------------------------------------------------
50 class SplashPath {
51 public:
53 // Create an empty path.
54 SplashPath();
56 // Copy a path.
57 SplashPath *copy() { return new SplashPath(this); }
59 ~SplashPath();
61 // Append <path> to <this>.
62 void append(SplashPath *path);
64 // Start a new subpath.
65 SplashError moveTo(SplashCoord x, SplashCoord y);
67 // Add a line segment to the last subpath.
68 SplashError lineTo(SplashCoord x, SplashCoord y);
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);
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);
81 // Close the last subpath, adding a line segment if necessary.
82 SplashError close();
84 // Add (<dx>, <dy>) to every point on this path.
85 void offset(SplashCoord dx, SplashCoord dy);
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]; }
92 // Get the current point.
93 GBool getCurPt(SplashCoord *x, SplashCoord *y);
95 private:
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; }
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
108 friend class SplashXPath;
109 friend class Splash;
112 #endif