1 /*
2 * LivarotDefs.h
3 * nlivarot
4 *
5 * Created by fred on Tue Jun 17 2003.
6 *
7 */
9 #ifndef my_defs
10 #define my_defs
12 #if defined(WIN32) || defined(__WIN32__)
13 # include <inttypes.h>
14 #endif
16 #ifdef HAVE_CONFIG_H
17 # include "config.h"
18 #endif
20 #ifdef HAVE_INTTYPES_H
21 # include <inttypes.h>
22 #else
23 # ifdef HAVE_STDINT_H
24 # include <stdint.h>
25 # endif
26 #endif
28 // error codes (mostly obsolete)
29 enum
30 {
31 avl_no_err = 0, // 0 is the error code for "everything OK"
32 avl_bal_err = 1,
33 avl_rm_err = 2,
34 avl_ins_err = 3,
35 shape_euler_err = 4, // computations result in a non-eulerian graph, thus the function cannot do a proper polygon
36 // despite the rounding sheme, this still happen with uber-complex graphs
37 // note that coordinates are stored in double => double precision for the computation is not even
38 // enough to get exact results (need quadruple precision, i think).
39 shape_input_err = 5 // the function was given an incorrect input (not a polygon, or not eulerian)
40 };
42 // return codes for the find function in the AVL tree (private)
43 enum
44 {
45 not_found = 0,
46 found_exact = 1,
47 found_on_left = 2,
48 found_on_right = 3,
49 found_between = 4
50 };
52 // boolean operation
53 enum bool_op
54 {
55 bool_op_union, // A OR B
56 bool_op_inters, // A AND B
57 bool_op_diff, // A \ B
58 bool_op_symdiff, // A XOR B
59 bool_op_cut, // coupure (pleines)
60 bool_op_slice // coupure (contour)
61 };
62 typedef enum bool_op BooleanOp;
64 // types of cap for stroking polylines
65 enum butt_typ
66 {
67 butt_straight, // straight line
68 butt_square, // half square
69 butt_round, // half circle
70 butt_pointy // a little pointy hat
71 };
72 // types of joins for stroking paths
73 enum join_typ
74 {
75 join_straight, // a straight line
76 join_round, // arc of circle (in fact, one or two quadratic bezier curve chunks)
77 join_pointy // a miter join (uses the miter parameter)
78 };
79 typedef enum butt_typ ButtType;
80 typedef enum join_typ JoinType;
82 enum fill_typ
83 {
84 fill_oddEven = 0,
85 fill_nonZero = 1,
86 fill_positive = 2,
87 fill_justDont = 3
88 };
89 typedef enum fill_typ FillRule;
91 // stupid version of dashes: in dash x is plain, dash x+1 must be empty, so the gap field is extremely redundant
92 typedef struct one_dash
93 {
94 bool gap;
95 double length;
96 }
97 one_dash;
99 // color definition structures for the rasterizations primitives (not present here)
100 typedef struct std_color
101 {
102 uint32_t uCol;
103 uint16_t iColA, iColR, iColG, iColB;
104 double fColA, fColR, fColG, fColB;
105 uint32_t iColATab[256];
106 }
107 std_color;
109 typedef struct grad_stop
110 {
111 double at;
112 double ca, cr, cg, cb;
113 double iSize;
114 }
115 grad_stop;
117 // linear gradient for filling polygons
118 typedef struct lin_grad
119 {
120 int type; // 0= gradient appears once
121 // 1= repeats itself start-end/start-end/start-end...
122 // 2= repeats itself start-end/end-start/start-end...
123 double u, v, w; // u*x+v*y+w = position in the gradient (clipped to [0;1])
124 // double caa,car,cag,cab; // color at gradient position 0
125 // double cba,cbr,cbg,cbb; // color at gradient position 1
126 int nbStop;
127 grad_stop stops[2];
128 }
129 lin_grad;
131 // radial gradient (color is funciton of r^2, need to be corrected with a sqrt() to be r)
132 typedef struct rad_grad
133 {
134 int type; // 0= gradient appears once
135 // 1= repeats itself start-end/start-end/start-end...
136 // 2= repeats itself start-end/end-start/start-end...
137 double mh, mv; // center
138 double rxx, rxy, ryx, ryy; // 1/radius
139 int nbStop;
140 grad_stop stops[2];
141 }
142 rad_grad;
144 // functions types for an arbitrary filling shader
145 typedef void (*InitColorFunc) (int ph, int pv, void *); // init for position ph,pv; the last parameter is a pointer
146 // on the gen_color structure
147 typedef void (*NextPixelColorFunc) (void *); // go to next pixel and update the color
148 typedef void (*NextLigneColorFunc) (void *); // go to next line (the h-coordinate must be the ph passed in
149 // the InitColorFunc)
150 typedef void (*GotoPixelColorFunc) (int ph, void *); // move to h-coordinate ph
151 typedef void (*GotoLigneColorFunc) (int pv, void *); // move to v-coordinate pv (the h-coordinate must be the ph passed
152 // in the InitColorFunc)
154 // an arbitrary shader
155 typedef struct gen_color
156 {
157 double colA, colR, colG, colB;
158 InitColorFunc iFunc;
159 NextPixelColorFunc npFunc;
160 NextLigneColorFunc nlFunc;
161 GotoPixelColorFunc gpFunc;
162 GotoLigneColorFunc glFunc;
163 }
164 gen_color;
166 // info for a run of pixel to fill
167 typedef struct raster_info {
168 int startPix,endPix; // start and end pixel from the polygon POV
169 int sth,stv; // coordinates for the first pixel in the run, in (possibly another) POV
170 uint32_t* buffer; // pointer to the first pixel in the run
171 } raster_info;
172 typedef void (*RasterInRunFunc) (raster_info &dest,void *data,int nst,float vst,int nen,float ven); // init for position ph,pv; the last parameter is a pointer
175 enum Side {
176 LEFT = 0,
177 RIGHT = 1
178 };
180 enum FirstOrLast {
181 FIRST = 0,
182 LAST = 1
183 };
185 #endif