1 /* $XConsortium: paths.h,v 1.2 91/10/10 11:18:50 rws Exp $ */
2 /* Copyright International Business Machines, Corp. 1991
4 * Copyright Lexmark International, Inc. 1991
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.
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
31 #define Loc(S,x,y) t1_Loc(S,(double)x,(double)y)
32 #define ILoc(S,x,y) t1_ILoc(S,x,y)
33 #define Line(P) t1_Line(P)
34 #define Join(p1,p2) t1_Join(p1,p2)
35 #define ClosePath(p) t1_ClosePath(p,0)
36 #define CloseLastSubPath(p) t1_ClosePath(p,1)
37 #define Conic(B,C,s) t1_Conic(B,C,(double)s)
38 #define RoundConic(M,C,r) t1_RoundConic(M,C,(double)r)
39 #define ArcP3(S,P2,P3) t1_ArcP3(S,P2,P3)
40 #define ArcCA(S,C,d) t1_ArcCA(S,C,(double)d)
41 #define Bezier(B,C,D) t1_Bezier(B,C,D)
42 #define Hint(S,r,w,o,h,a,d,l) t1_Hint(S,r,w,o,h,a,d,l)
43 #define Reverse(p) t1_Reverse(p)
44 #define ReverseSubPaths(p) t1_ReverseSubPaths(p)
45 #define AddLoc(p1,p2) t1_Join(p1,p2)
46 #define SubLoc(p1,p2) t1_SubLoc(p1,p2)
47 #define DropSegment(p) t1_DropSegment(p)
48 #define HeadSegment(p) t1_HeadSegment(p)
49 #define QueryLoc(P,S,x,y) t1_QueryLoc(P,S,x,y)
50 #define QueryPath(p,t,B,C,D,r) t1_QueryPath(p,t,B,C,D,r)
51 #define QueryBounds(p,S,x1,y1,x2,y2) t1_QueryBounds(p,S,x1,y1,x2,y2)
54 struct segment *t1_Loc(); /* create a location object (or "move" segment) */
55 struct segment *t1_ILoc(); /* integer argument version of same */
56 struct segment *t1_Line(); /* straight line path segment */
57 struct segment *t1_Join(); /* join two paths or regions together */
58 struct segment *t1_ClosePath(); /* close a path or path set */
59 struct conicsegment *t1_Conic(); /* conic curve path segment */
60 struct conicsegment *t1_RoundConic(); /* ditto, specified another way */
61 struct conicsegment *t1_ArcP3(); /* circular path segment with three points */
62 struct conicsegment *t1_ArcCA(); /* ditto, with center point and angle */
63 struct beziersegment *t1_Bezier(); /* Bezier third order curve path segment */
64 struct hintsegment *t1_Hint(); /* produce a font 'hint' path segment */
65 struct segment *t1_Reverse(); /* reverse the complete order of paths */
66 struct segment *t1_ReverseSubPaths(); /* reverse only sub-paths; moves unchanged */
67 struct segment *t1_SubLoc(); /* subtract two location objects */
68 struct segment *t1_DropSegment(); /* Drop the first segment in a path */
69 struct segment *t1_HeadSegment(); /* return the first segment in a path */
70 void t1_QueryLoc(); /* Query location; return its (x,y) */
71 void t1_QueryPath(); /* Query segment at head of a path */
72 void t1_QueryBounds(); /* Query the bounding box of a path */
77 #define CopyPath(p) t1_CopyPath(p)
78 #define KillPath(p) t1_KillPath(p)
79 #define PathTransform(p,m) t1_PathXform(p,m)
80 #define PathDelta(p,pt) t1_PathDelta(p,pt)
81 #define BoundingBox(h,w) t1_BoundingBox(h,w)
82 #define PathSegment(t,x,y) t1_PathSegment(t,(fractpel)x,(fractpel)y)
83 #define JoinSegment(b,t,x,y,a) t1_JoinSegment(b,t,(fractpel)x,(fractpel)y,a)
84 #define Hypoteneuse(dx,dy) t1_Hypoteneuse(dx,dy)
85 #define BoxPath(S,h,w) t1_BoxPath(S,h,w)
87 struct segment *t1_CopyPath(); /* duplicate a path */
88 void t1_KillPath(); /* destroy a path */
89 struct segment *t1_PathXform(); /* transform a path arbitrarily */
90 void t1_PathDelta(); /* calculate the ending point of a path */
91 struct segment *t1_PathSegment(); /* produce a MOVE or LINE segment */
92 struct segment *t1_JoinSegment(); /* join a MOVE or LINE segment to a path */
93 double t1_Hypoteneuse(); /* returns the length of a line */
94 struct segment *t1_BoxPath(); /* returns a rectangular path */
99 #define ConsumePath(p) MAKECONSUME(p,KillPath(p))
100 #define UniquePath(p) MAKEUNIQUE(p,CopyPath(p))
106 XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
107 unsigned char size; /* size of the structure */
108 unsigned char context; /* index to device context */
109 struct segment *link; /* pointer to next structure in linked list */
110 struct segment *last; /* pointer to last structure in list */
111 struct fractpoint dest; /* relative ending location of path segment */
114 #define ISCLOSED(flag) ((flag)&0x80) /* subpath is closed */
115 #define LASTCLOSED(flag) ((flag)&0x40) /* last segment in closed subpath */
118 NOTE: The ISCLOSED flag is set on the MOVETYPE segment before the
119 subpath proper; the LASTCLOSED flag is set on the last segment (LINETYPE)
122 We define the ISPATHANCHOR predicate to test that a path handle
123 passed by the user is valid:
126 #define ISPATHANCHOR(p) (ISPATHTYPE(p->type)&&p->last!=NULL)
129 For performance reasons, a user's "location" object is identical to
130 a path whose only segment is a move segment. We define a predicate
131 to test for this case. See also :hdref refid=location..
134 #define ISLOCATION(p) ((p)->type == MOVETYPE && (p)->link == NULL)
139 struct conicsegment {
140 XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
141 /* type = CONICTYPE */
142 unsigned char size; /* as with any 'segment' type */
143 unsigned char context; /* as with any 'segment' type */
144 struct segment *link; /* as with any 'segment' type */
145 struct segment *last; /* as with any 'segment' type */
146 struct fractpoint dest; /* Ending point (C point) */
147 struct fractpoint M; /* "midpoint" of conic explained above */
148 float roundness; /* explained above */
153 struct beziersegment {
154 XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
155 /* type = BEZIERTYPE */
156 unsigned char size; /* as with any 'segment' type */
157 unsigned char context; /* as with any 'segment' type */
158 struct segment *link; /* as with any 'segment' type */
159 struct segment *last; /* as with any 'segment' type */
160 struct fractpoint dest; /* ending point (D) */
161 struct fractpoint B; /* control point B */
162 struct fractpoint C; /* control point C */
169 XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
170 /* type = HINTTYPE */
171 unsigned char size; /* size of the structure */
172 unsigned char context; /* device context */
173 struct segment *link; /* pointer to next structure in linked list */
174 struct segment *last; /* pointer to last structure in list */
175 struct fractpoint dest; /* ALWAYS 0,0 */
176 struct fractpoint ref;
177 struct fractpoint width;
189 CONCAT links the 'p2' path chain on the end of the 'p1' chain. (This macro
190 is also used by the STROKES module.)
192 #define CONCAT(p1, p2) { \
193 p1->last->link = p2; /* link p2 on end of p1 */ \
194 p1->last = p2->last; /* last of new is last of p2 */ \
195 p2->last = NULL; } /* only first segment has non-NULL "last" */