Debian Codegraph @

texk/ps2pk/paths.h

raw
1 /* $XConsortium: paths.h,v 1.2 91/10/10 11:18:50 rws Exp $ */
2 /* Copyright International Business Machines, Corp. 1991
3 * All Rights Reserved
4 * Copyright Lexmark International, Inc. 1991
5 * All Rights Reserved
6 *
7 * License to use, copy, modify, and distribute this software and its
8 * documentation for any purpose and without fee is hereby granted,
9 * provided that the above copyright notice appear in all copies and that
10 * both that copyright notice and this permission notice appear in
11 * supporting documentation, and that the name of IBM or Lexmark not be
12 * used in advertising or publicity pertaining to distribution of the
13 * software without specific, written prior permission.
14 *
15 * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
16 * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
17 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
18 * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
19 * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
20 * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
21 * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
22 * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
23 * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
24 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
25 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
26 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
27 * THIS SOFTWARE.
28 */
29 /*SHARED*/
30
31 #include "types.h"
32
33 #define Loc(S,x,y) t1_Loc(S,(DOUBLE)x,(DOUBLE)y)
34 #define ILoc(S,x,y) t1_ILoc(S,x,y)
35 #define Line(P) t1_Line(P)
36 #define Join(p1,p2) t1_Join(p1,p2)
37 #define ClosePath(p) t1_ClosePath(p,0)
38 #define CloseLastSubPath(p) t1_ClosePath(p,1)
39 #define Conic(B,C,s) t1_Conic(B,C,(DOUBLE)s)
40 #define RoundConic(M,C,r) t1_RoundConic(M,C,(DOUBLE)r)
41 #define ArcP3(S,P2,P3) t1_ArcP3(S,P2,P3)
42 #define ArcCA(S,C,d) t1_ArcCA(S,C,(DOUBLE)d)
43 #define Bezier(B,C,D) t1_Bezier(B,C,D)
44 #define Hint(S,r,w,o,h,a,d,l) t1_Hint(S,r,w,o,h,a,d,l)
45 #define Reverse(p) t1_Reverse(p)
46 #define ReverseSubPaths(p) t1_ReverseSubPaths(p)
47 #define AddLoc(p1,p2) t1_Join(p1,p2)
48 #if 0
49 #define SubLoc(p1,p2) t1_SubLoc(p1,p2)
50 #endif
51 #define DropSegment(p) t1_DropSegment(p)
52 #define HeadSegment(p) t1_HeadSegment(p)
53 #define QueryLoc(P,S,x,y) t1_QueryLoc(P,S,x,y)
54 #define QueryPath(p,t,B,C,D,r) t1_QueryPath(p,t,B,C,D,r)
55 #define QueryBounds(p,S,x1,y1,x2,y2) t1_QueryBounds(p,S,x1,y1,x2,y2)
56
57
58 struct segment *t1_Loc(struct XYspace *, DOUBLE, DOUBLE);
59 /* create a location object (or "move" segment) */
60 struct segment *t1_ILoc(struct XYspace *, int, int);
61 /* integer argument version of same */
62 struct segment *t1_Line(struct segment *); /* straight line path segment */
63 struct segment *t1_Join(struct segment *, struct segment *);
64 /* join two paths or regions together */
65 struct segment *t1_ClosePath(struct segment *, int);
66 /* close a path or path set */
67 struct conicsegment *t1_Conic(); /* conic curve path segment */
68 struct conicsegment *t1_RoundConic(); /* ditto, specified another way */
69 struct conicsegment *t1_ArcP3(); /* circular path segment with three points */
70 struct conicsegment *t1_ArcCA(); /* ditto, with center point and angle */
71 struct beziersegment *t1_Bezier(struct segment *, struct segment *,
72 struct segment *); /* Bezier third order curve path segment */
73 struct hintsegment *t1_Hint(struct XYspace *, float, float, char,
74 char, char, char, int); /* produce a font 'hint' path segment */
75 struct segment *t1_Reverse(struct segment *);
76 /* reverse the complete order of paths */
77 struct segment *t1_ReverseSubPaths(struct segment *);
78 /* reverse only sub-paths; moves unchanged */
79 struct segment *t1_DropSegment(struct segment *);
80 /* Drop the first segment in a path */
81 struct segment *t1_HeadSegment(struct segment *);
82 /* return the first segment in a path */
83 void t1_QueryLoc(struct segment *, struct XYspace *, DOUBLE *, DOUBLE *);
84 /* Query location; return its (x,y) */
85 void t1_QueryPath(struct segment *, int *typeP, struct segment **,
86 struct segment **, struct segment **, DOUBLE *);
87 /* Query segment at head of a path */
88 void t1_QueryBounds(struct segment *, struct XYspace *, DOUBLE *, DOUBLE *,
89 DOUBLE *, DOUBLE *); /* Query the bounding box of a path */
90
91 /*END SHARED*/
92 /*SHARED*/
93
94 #define CopyPath(p) t1_CopyPath(p)
95 #define KillPath(p) t1_KillPath(p)
96 #define PathTransform(p,m) t1_PathXform(p,m)
97 #define PathDelta(p,pt) t1_PathDelta(p,pt)
98 #define BoundingBox(h,w) t1_BoundingBox(h,w)
99 #define PathSegment(t,x,y) t1_PathSegment(t,(fractpel)x,(fractpel)y)
100 #define JoinSegment(b,t,x,y,a) t1_JoinSegment(b,t,(fractpel)x,(fractpel)y,a)
101 #define Hypoteneuse(dx,dy) t1_Hypoteneuse(dx,dy)
102 #define BoxPath(S,h,w) t1_BoxPath(S,h,w)
103
104 struct segment *t1_CopyPath(struct segment *); /* duplicate a path */
105 void t1_KillPath(struct segment *); /* destroy a path */
106 struct segment *t1_PathXform(struct segment *, struct XYspace *);
107 /* transform a path arbitrarily */
108 void t1_PathDelta(struct segment *, struct fractpoint *);
109 /* calculate the ending point of a path */
110 struct segment *t1_BoundingBox(pel, pel); /* produce a Bounding Box Path */
111 struct segment *t1_PathSegment(int, fractpel, fractpel);
112 /* produce a MOVE or LINE segment */
113 struct segment *t1_JoinSegment(struct segment *, int, fractpel, fractpel,
114 struct segment *); /* join a MOVE or LINE segment to a path */
115 DOUBLE t1_Hypoteneuse(); /* returns the length of a line */
116 struct segment *t1_BoxPath(struct XYspace *, int, int);
117 /* returns a rectangular path */
118
119 /*END SHARED*/
120 /*SHARED*/
121
122 #define ConsumePath(p) MAKECONSUME(p,KillPath(p))
123 #define UniquePath(p) MAKEUNIQUE(p,CopyPath(p))
124
125 /*END SHARED*/
126 /*SHARED*/
127
128 struct segment {
129 XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
130 unsigned char size; /* size of the structure */
131 unsigned char context; /* index to device context */
132 struct segment *link; /* pointer to next structure in linked list */
133 struct segment *last; /* pointer to last structure in list */
134 struct fractpoint dest; /* relative ending location of path segment */
135 } ;
136
137 #define ISCLOSED(flag) ((flag)&0x80) /* subpath is closed */
138 #define LASTCLOSED(flag) ((flag)&0x40) /* last segment in closed subpath */
139
140 /*
141 NOTE: The ISCLOSED flag is set on the MOVETYPE segment before the
142 subpath proper; the LASTCLOSED flag is set on the last segment (LINETYPE)
143 in the subpath
144
145 We define the ISPATHANCHOR predicate to test that a path handle
146 passed by the user is valid:
147 */
148
149 #define ISPATHANCHOR(p) (ISPATHTYPE(p->type)&&p->last!=NULL)
150
151 /*
152 For performance reasons, a user's "location" object is identical to
153 a path whose only segment is a move segment. We define a predicate
154 to test for this case. See also :hdref refid=location..
155 */
156
157 #define ISLOCATION(p) ((p)->type == MOVETYPE && (p)->link == NULL)
158
159 /*END SHARED*/
160 /*SHARED*/
161
162 struct conicsegment {
163 XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
164 /* type = CONICTYPE */
165 unsigned char size; /* as with any 'segment' type */
166 unsigned char context; /* as with any 'segment' type */
167 struct segment *link; /* as with any 'segment' type */
168 struct segment *last; /* as with any 'segment' type */
169 struct fractpoint dest; /* Ending point (C point) */
170 struct fractpoint M; /* "midpoint" of conic explained above */
171 float roundness; /* explained above */
172 } ;
173 /*END SHARED*/
174 /*SHARED*/
175
176 struct beziersegment {
177 XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
178 /* type = BEZIERTYPE */
179 unsigned char size; /* as with any 'segment' type */
180 unsigned char context; /* as with any 'segment' type */
181 struct segment *link; /* as with any 'segment' type */
182 struct segment *last; /* as with any 'segment' type */
183 struct fractpoint dest; /* ending point (D) */
184 struct fractpoint B; /* control point B */
185 struct fractpoint C; /* control point C */
186 } ;
187
188 /*END SHARED*/
189 /*SHARED*/
190
191 struct hintsegment {
192 XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
193 /* type = HINTTYPE */
194 unsigned char size; /* size of the structure */
195 unsigned char context; /* device context */
196 struct segment *link; /* pointer to next structure in linked list */
197 struct segment *last; /* pointer to last structure in list */
198 struct fractpoint dest; /* ALWAYS 0,0 */
199 struct fractpoint ref;
200 struct fractpoint width;
201 char orientation;
202 char hinttype;
203 char adjusttype;
204 char direction;
205 int label;
206 } ;
207
208 /*END SHARED*/
209 /*SHARED*/
210
211 /*
212 CONCAT links the 'p2' path chain on the end of the 'p1' chain. (This macro
213 is also used by the STROKES module.)
214 */
215 #define CONCAT(p1, p2) { \
216 p1->last->link = p2; /* link p2 on end of p1 */ \
217 p1->last = p2->last; /* last of new is last of p2 */ \
218 p2->last = NULL; } /* only first segment has non-NULL "last" */
219
220 /*END SHARED*/