source: trunk/poppler/mypoppler/splash/SplashPath.h @ 2

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 15 years ago

First import

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