xref: /plan9/sys/src/cmd/gs/src/gxline.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1995, 1996, 1998, 1999 Aladdin Enterprises.  All rights reserved.
2 
3   This software is provided AS-IS with no warranty, either express or
4   implied.
5 
6   This software is distributed under license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 /* $Id: gxline.h,v 1.7 2005/08/17 14:40:11 igor Exp $ */
18 /* Private line parameter definitions */
19 
20 #ifndef gxline_INCLUDED
21 #  define gxline_INCLUDED
22 
23 #include "gslparam.h"
24 #include "gsmatrix.h"
25 
26 /* Line parameter structures */
27 /* gx_dash_params are never instantiated by themselves. */
28 typedef struct gx_dash_params_s {
29     float *pattern;
30     uint pattern_size;
31     float offset;
32     bool adapt;
33     /* The rest of the parameters are computed from the above */
34     float pattern_length;	/* total of all pattern elements */
35     bool init_ink_on;		/* true if ink is initially on */
36     int init_index;		/* initial index in pattern */
37     float init_dist_left;
38 } gx_dash_params;
39 
40 #define gx_dash_params_initial\
41   NULL, 0, 0.0, 0/*false*/, 0.0, 1/*true*/, 0, 0.0
42 typedef struct gx_line_params_s {
43     float half_width;		/* one-half line width */
44     gs_line_cap cap;
45     gs_line_join join;
46     int curve_join;		/* <0 means use join between segments of */
47 				/* flattened curves, >=0 means use this join */
48     float miter_limit;
49     float miter_check;		/* computed from miter limit, */
50 				/* see gx_set_miter_limit and gs_stroke */
51     float dot_length;
52     bool dot_length_absolute;	/* if true, dot_length is 1/72" units */
53     gs_matrix dot_orientation;	/* dot length is aligned with (1,0); */
54 				/* must be xxyy or xyyx */
55     gx_dash_params dash;
56 } gx_line_params;
57 
58 #define gx_set_line_width(plp, wid)\
59   ((plp)->half_width = (wid) / 2)
60 #define gx_current_line_width(plp)\
61   ((plp)->half_width * 2)
62 int gx_set_miter_limit(gx_line_params *, floatp);
63 
64 #define gx_current_miter_limit(plp)\
65   ((plp)->miter_limit)
66 int gx_set_dash(gx_dash_params *, const float *, uint, floatp, gs_memory_t *);
67 
68 #define gx_set_dash_adapt(pdp, adpt) ((pdp)->adapt = (adpt))
69 int gx_set_dot_length(gx_line_params *, floatp, bool);
70 
71 /* See gsline.c for the computation of miter_check. */
72 #define gx_line_params_initial\
73  0.0, gs_cap_butt, gs_join_miter, -1,\
74  10.0, (float)0.20305866, 0.0, 0/*false*/,\
75   { identity_matrix_body }, { gx_dash_params_initial }
76 
77 #endif /* gxline_INCLUDED */
78