Code

Split SPCanvasItem and SPCanvasGroup to individual .h files. Pruned forward header.
[inkscape.git] / src / livarot / LivarotDefs.h
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   shape_nothing_to_do = 6               // the function had nothing to do (zero offset, etc)
41 };
43 // return codes for the find function in the AVL tree (private)
44 enum
45 {
46   not_found = 0,
47   found_exact = 1,
48   found_on_left = 2,
49   found_on_right = 3,
50   found_between = 4
51 };
53 // boolean operation
54 enum bool_op
55 {
56   bool_op_union,                // A OR B
57   bool_op_inters,               // A AND B
58   bool_op_diff,                 // A \ B
59   bool_op_symdiff,  // A XOR B
60   bool_op_cut,      // coupure (pleines)
61   bool_op_slice     // coupure (contour)
62 };
63 typedef enum bool_op BooleanOp;
65 // types of cap for stroking polylines
66 enum butt_typ
67 {
68   butt_straight,                // straight line
69   butt_square,                  // half square
70   butt_round,                   // half circle
71   butt_pointy                   // a little pointy hat
72 };
73 // types of joins for stroking paths
74 enum join_typ
75 {
76   join_straight,                // a straight line
77   join_round,                   // arc of circle (in fact, one or two quadratic bezier curve chunks)
78   join_pointy                   // a miter join (uses the miter parameter)
79 };
80 typedef enum butt_typ ButtType;
81 typedef enum join_typ JoinType;
83 enum fill_typ
84 {
85   fill_oddEven   = 0,
86   fill_nonZero   = 1,
87   fill_positive  = 2,
88   fill_justDont = 3
89 };
90 typedef enum fill_typ FillRule;
92 // stupid version of dashes: in dash x is plain, dash x+1 must be empty, so the gap field is extremely redundant
93 typedef struct one_dash
94 {
95   bool gap;
96   double length;
97 }
98 one_dash;
100 // color definition structures for the rasterizations primitives (not present here)
101 typedef struct std_color
103   uint32_t uCol;
104   uint16_t iColA, iColR, iColG, iColB;
105   double fColA, fColR, fColG, fColB;
106   uint32_t iColATab[256];
108 std_color;
110 typedef struct grad_stop
112   double at;
113   double ca, cr, cg, cb;
114   double iSize;
116 grad_stop;
118 // linear gradient for filling polygons
119 typedef struct lin_grad
121   int type;                     // 0= gradient appears once
122   // 1= repeats itself start-end/start-end/start-end...
123   // 2= repeats itself start-end/end-start/start-end...
124   double u, v, w;               // u*x+v*y+w = position in the gradient (clipped to [0;1])
125 //      double       caa,car,cag,cab; // color at gradient position 0
126 //      double       cba,cbr,cbg,cbb; // color at gradient position 1
127   int nbStop;
128   grad_stop stops[2];
130 lin_grad;
132 // radial gradient (color is funciton of r^2, need to be corrected with a sqrt() to be r)
133 typedef struct rad_grad
135   int type;                     // 0= gradient appears once
136   // 1= repeats itself start-end/start-end/start-end...
137   // 2= repeats itself start-end/end-start/start-end...
138   double mh, mv;                        // center
139   double rxx, rxy, ryx, ryy;    // 1/radius
140   int nbStop;
141   grad_stop stops[2];
143 rad_grad;
145 // functions types for an arbitrary filling shader
146 typedef void (*InitColorFunc) (int ph, int pv, void *); // init for position ph,pv; the last parameter is a pointer
147                                                      // on the gen_color structure
148 typedef void (*NextPixelColorFunc) (void *);    // go to next pixel and update the color
149 typedef void (*NextLigneColorFunc) (void *);    // go to next line (the h-coordinate must be the ph passed in
150                                             // the InitColorFunc)
151 typedef void (*GotoPixelColorFunc) (int ph, void *);    // move to h-coordinate ph
152 typedef void (*GotoLigneColorFunc) (int pv, void *);    // move to v-coordinate pv (the h-coordinate must be the ph passed
153                                                   // in the InitColorFunc)
155 // an arbitrary shader
156 typedef struct gen_color
158   double colA, colR, colG, colB;
159   InitColorFunc iFunc;
160   NextPixelColorFunc npFunc;
161   NextLigneColorFunc nlFunc;
162   GotoPixelColorFunc gpFunc;
163   GotoLigneColorFunc glFunc;
165 gen_color;
167 // info for a run of pixel to fill
168 typedef struct raster_info {
169                 int       startPix,endPix;  // start and end pixel from the polygon POV
170                 int       sth,stv;          // coordinates for the first pixel in the run, in (possibly another) POV
171                 uint32_t* buffer;           // pointer to the first pixel in the run
172 } raster_info;
173 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
176 enum Side {
177     LEFT = 0,
178     RIGHT = 1
179 };
181 enum FirstOrLast {
182     FIRST = 0,
183     LAST = 1
184 };
186 #endif