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