1 /** \file
2  * \brief User API
3  * CD - Canvas Draw
4  * Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil
5  * http://www.tecgraf.puc-rio.br/cd
6  * mailto:cd@tecgraf.puc-rio.br
7  *
8  * See Copyright Notice at the end of this file
9  */
10 
11 module cd.cd;
12 
13 extern (C) @safe nothrow:
14 
15 
16 enum CD_NAME = "CD - A 2D Graphics Library";
17 enum CD_DESCRIPTION = "Vector Graphics Toolkit with Device Independent Output";
18 enum CD_COPYRIGHT = "Copyright (C) 1994-2015 Tecgraf/PUC-Rio";
19 enum CD_VERSION = "5.9";              /* bug fixes are reported only by cdVersion functions */
20 enum CD_VERSION_NUMBER = 509000;
21 enum CD_VERSION_DATE = "2015/09/15";  /* does not include bug fix releases */
22 
23 struct _cdContext;
24 alias cdContext = _cdContext;
25 struct _cdCanvas;
26 alias cdCanvas = _cdCanvas;
27 alias cdState = _cdCanvas;
28 struct _cdImage;
29 alias cdImage = _cdImage;
30 
31 /* client images using bitmap structure */
32 struct _cdBitmap {
33   int w;
34   int h;
35   int type;
36   void *data;
37 }
38 alias cdBitmap = _cdBitmap;
39 
40 
41 /* library */
42 char*         cdVersion();
43 char*         cdVersionDate();
44 int           cdVersionNumber();
45 
46 /* canvas init */
47 cdCanvas*   cdCreateCanvas(cdContext *context, void *data);
48 cdCanvas*   cdCreateCanvasf(cdContext *context, const(char) * format, ...);
49 void        cdKillCanvas(cdCanvas* canvas);
50 
51 cdContext*  cdCanvasGetContext(cdCanvas* canvas);
52 int         cdCanvasActivate(cdCanvas* canvas);
53 void        cdCanvasDeactivate(cdCanvas* canvas);
54 int         cdUseContextPlus(int use);
55 void        cdInitContextPlus();   /* need an external library */
56 void        cdFinishContextPlus();   /* need an external library */
57 
58 /* context */
59 alias cdCallback = int function(cdCanvas* canvas, ...);
60 int cdContextRegisterCallback(cdContext *context, int cb, cdCallback func);
61 ulong cdContextCaps(cdContext *context);
62 int cdContextIsPlus(cdContext *context);
63 int cdContextType(cdContext *context);
64 
65 /* control */
66 int      cdCanvasSimulate(cdCanvas* canvas, int mode);
67 void     cdCanvasFlush(cdCanvas* canvas);
68 void     cdCanvasClear(cdCanvas* canvas);
69 cdState* cdCanvasSaveState(cdCanvas* canvas);
70 void     cdCanvasRestoreState(cdCanvas* canvas, cdState* state);
71 void     cdReleaseState(cdState* state);
72 void     cdCanvasSetAttribute(cdCanvas* canvas, const(char) * name, char* data);
73 void     cdCanvasSetfAttribute(cdCanvas* canvas, const(char) * name, const(char) * format, ...);
74 char*    cdCanvasGetAttribute(cdCanvas* canvas, const(char) * name);
75 
76 /* interpretation */
77 int cdCanvasPlay(cdCanvas* canvas, cdContext *context, int xmin, int xmax, int ymin, int ymax, void *data);
78 
79 /* coordinate transformation */
80 void cdCanvasGetSize(cdCanvas* canvas, int *width, int *height, double *width_mm, double *height_mm);
81 int cdCanvasUpdateYAxis(cdCanvas* canvas, int* y);
82 double cdfCanvasUpdateYAxis(cdCanvas* canvas, double* y);
83 int cdCanvasInvertYAxis(cdCanvas* canvas, int y);
84 double cdfCanvasInvertYAxis(cdCanvas* canvas, double y);
85 void cdCanvasMM2Pixel(cdCanvas* canvas, double mm_dx, double mm_dy, int *dx, int *dy);
86 void cdCanvasPixel2MM(cdCanvas* canvas, int dx, int dy, double *mm_dx, double *mm_dy);
87 void cdfCanvasMM2Pixel(cdCanvas* canvas, double mm_dx, double mm_dy, double *dx, double *dy);
88 void cdfCanvasPixel2MM(cdCanvas* canvas, double dx, double dy, double *mm_dx, double *mm_dy);
89 void cdCanvasOrigin(cdCanvas* canvas, int x, int y);
90 void cdfCanvasOrigin(cdCanvas* canvas, double x, double y);
91 void cdCanvasGetOrigin(cdCanvas* canvas, int *x, int *y);
92 void cdfCanvasGetOrigin(cdCanvas* canvas, double *x, double *y);
93 void cdCanvasTransform(cdCanvas* canvas, const(double) * matrix);
94 double* cdCanvasGetTransform(cdCanvas* canvas);
95 void cdCanvasTransformMultiply(cdCanvas* canvas, const(double) * matrix);
96 void cdCanvasTransformRotate(cdCanvas* canvas, double angle);
97 void cdCanvasTransformScale(cdCanvas* canvas, double sx, double sy);
98 void cdCanvasTransformTranslate(cdCanvas* canvas, double dx, double dy);
99 void cdCanvasTransformPoint(cdCanvas* canvas, int x, int y, int *tx, int *ty);
100 void cdfCanvasTransformPoint(cdCanvas* canvas, double x, double y, double *tx, double *ty);
101 
102 /* clipping */
103 int  cdCanvasClip(cdCanvas* canvas, int mode);
104 void cdCanvasClipArea(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax);
105 int  cdCanvasGetClipArea(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax);
106 void cdfCanvasClipArea(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax);
107 int  cdfCanvasGetClipArea(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax);
108 
109 /* clipping region */
110 int  cdCanvasIsPointInRegion(cdCanvas* canvas, int x, int y);
111 void cdCanvasOffsetRegion(cdCanvas* canvas, int x, int y);
112 void cdCanvasGetRegionBox(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax);
113 int  cdCanvasRegionCombineMode(cdCanvas* canvas, int mode);
114 
115 /* primitives */
116 void cdCanvasPixel(cdCanvas* canvas, int x, int y, long color);
117 void cdCanvasMark(cdCanvas* canvas, int x, int y);
118 void cdfCanvasPixel(cdCanvas* canvas, double x, double y, long color);
119 void cdfCanvasMark(cdCanvas* canvas, double x, double y);
120 
121 void cdCanvasBegin(cdCanvas* canvas, int mode);
122 void cdCanvasPathSet(cdCanvas* canvas, int action);
123 void cdCanvasEnd(cdCanvas* canvas);
124 
125 void cdCanvasLine(cdCanvas* canvas, int x1, int y1, int x2, int y2);
126 void cdCanvasVertex(cdCanvas* canvas, int x, int y);
127 void cdCanvasRect(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax);
128 void cdCanvasBox(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax);
129 void cdCanvasArc(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2);
130 void cdCanvasSector(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2);
131 void cdCanvasChord(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2);
132 void cdCanvasText(cdCanvas* canvas, int x, int y, const(char) * s);
133 
134 void cdfCanvasLine(cdCanvas* canvas, double x1, double y1, double x2, double y2);
135 void cdfCanvasVertex(cdCanvas* canvas, double x, double y);
136 void cdfCanvasRect(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax);
137 void cdfCanvasBox(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax);
138 void cdfCanvasArc(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2);
139 void cdfCanvasSector(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2);
140 void cdfCanvasChord(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2);
141 void cdfCanvasText(cdCanvas* canvas, double x, double y, const(char) * s);
142 
143 /* attributes */
144 void cdCanvasSetBackground(cdCanvas* canvas, long color);
145 void cdCanvasSetForeground(cdCanvas* canvas, long color);
146 long cdCanvasBackground(cdCanvas* canvas, long color);
147 long cdCanvasForeground(cdCanvas* canvas, long color);
148 int  cdCanvasBackOpacity(cdCanvas* canvas, int opacity);
149 int  cdCanvasWriteMode(cdCanvas* canvas, int mode);
150 int  cdCanvasLineStyle(cdCanvas* canvas, int style);
151 void cdCanvasLineStyleDashes(cdCanvas* canvas, const(int) * dashes, int count);
152 int  cdCanvasLineWidth(cdCanvas* canvas, int width);
153 int  cdCanvasLineJoin(cdCanvas* canvas, int join);
154 int  cdCanvasLineCap(cdCanvas* canvas, int cap);
155 int  cdCanvasInteriorStyle(cdCanvas* canvas, int style);
156 int  cdCanvasHatch(cdCanvas* canvas, int style);
157 void cdCanvasStipple(cdCanvas* canvas, int w, int h, const(ubyte) * stipple);
158 ubyte* cdCanvasGetStipple(cdCanvas* canvas, int *n, int *m);
159 void   cdCanvasPattern(cdCanvas* canvas, int w, int h, const(long) *pattern);
160 long*  cdCanvasGetPattern(cdCanvas* canvas, int* n, int* m);
161 int    cdCanvasFillMode(cdCanvas* canvas, int mode);
162 int    cdCanvasFont(cdCanvas* canvas, const(char) * type_face, int style, int size);
163 void   cdCanvasGetFont(cdCanvas* canvas, char *type_face, int *style, int *size);
164 char*  cdCanvasNativeFont(cdCanvas* canvas, const(char) * font);
165 int    cdCanvasTextAlignment(cdCanvas* canvas, int alignment);
166 double cdCanvasTextOrientation(cdCanvas* canvas, double angle);
167 int    cdCanvasMarkType(cdCanvas* canvas, int type);
168 int    cdCanvasMarkSize(cdCanvas* canvas, int size);
169 
170 /* vector text */
171 void cdCanvasVectorText(cdCanvas* canvas, int x, int y, const(char) * s);
172 void cdCanvasMultiLineVectorText(cdCanvas* canvas, int x, int y, const(char) * s);
173 
174 /* vector text attributes */
175 char* cdCanvasVectorFont(cdCanvas* canvas, const(char) *filename);
176 void  cdCanvasVectorTextDirection(cdCanvas* canvas, int x1, int y1, int x2, int y2);
177 double* cdCanvasVectorTextTransform(cdCanvas* canvas, const(double) * matrix);
178 void  cdCanvasVectorTextSize(cdCanvas* canvas, int size_x, int size_y, const(char) * s);
179 int   cdCanvasVectorCharSize(cdCanvas* canvas, int size);
180 void  cdCanvasVectorFontSize(cdCanvas* canvas, double size_x, double size_y);
181 void  cdCanvasGetVectorFontSize(cdCanvas* canvas, double *size_x, double *size_y);
182 
183 /* vector text properties */
184 void cdCanvasGetVectorTextSize(cdCanvas* canvas, const(char) * s, int *x, int *y);
185 void cdCanvasGetVectorTextBounds(cdCanvas* canvas, const(char) * s, int x, int y, int *rect);
186 void cdCanvasGetVectorTextBox(cdCanvas* canvas, int x, int y, const(char) *s, int *xmin, int *xmax, int *ymin, int *ymax);
187 
188 void cdfCanvasVectorTextDirection(cdCanvas* canvas, double x1, double y1, double x2, double y2);
189 void cdfCanvasVectorTextSize(cdCanvas* canvas, double size_x, double size_y, const(char) * s);
190 void cdfCanvasGetVectorTextSize(cdCanvas* canvas, const(char) * s, double *x, double *y);
191 double cdfCanvasVectorCharSize(cdCanvas* canvas, double size);
192 void cdfCanvasVectorText(cdCanvas* canvas, double x, double y, const(char) * s);
193 void cdfCanvasMultiLineVectorText(cdCanvas* canvas, double x, double y, const(char) * s);
194 void cdfCanvasGetVectorTextBounds(cdCanvas* canvas, const(char) * s, double x, double y, double *rect);
195 void cdfCanvasGetVectorTextBox(cdCanvas* canvas, double x, double y, const(char) *s, double *xmin, double *xmax, double *ymin, double *ymax);
196 
197 /* properties */
198 void cdCanvasGetFontDim(cdCanvas* canvas, int *max_width, int *height, int *ascent, int *descent);
199 void cdCanvasGetTextSize(cdCanvas* canvas, const(char) * s, int *width, int *height);
200 void cdCanvasGetTextBox(cdCanvas* canvas, int x, int y, const(char) * s, int *xmin, int *xmax, int *ymin, int *ymax);
201 void cdfCanvasGetTextBox(cdCanvas* canvas, double x, double y, const(char) *s, double *xmin, double *xmax, double *ymin, double *ymax);
202 void cdCanvasGetTextBounds(cdCanvas* canvas, int x, int y, const(char) * s, int *rect);
203 void cdfCanvasGetTextBounds(cdCanvas* canvas, double x, double y, const(char) *s, double *rect);
204 int  cdCanvasGetColorPlanes(cdCanvas* canvas);
205 
206 /* color */
207 void cdCanvasPalette(cdCanvas* canvas, int n, const(long) *palette, int mode);
208 
209 /* client images */
210 void cdCanvasGetImageRGB(cdCanvas* canvas, ubyte* r, ubyte* g, ubyte* b, int x, int y, int iw, int ih);
211 
212 void cdCanvasPutImageRectRGB(cdCanvas* canvas, int iw, int ih, const(ubyte) * r, const(ubyte) * g, const(ubyte) * b, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax);
213 void cdCanvasPutImageRectRGBA(cdCanvas* canvas, int iw, int ih, const(ubyte) * r, const(ubyte) * g, const(ubyte) * b, const(ubyte) * a, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax);
214 void cdCanvasPutImageRectMap(cdCanvas* canvas, int iw, int ih, const(ubyte) * index, const(long) * colors, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax);
215 
216 void cdfCanvasPutImageRectRGB(cdCanvas* canvas, int iw, int ih, const(ubyte) * r, const(ubyte) * g, const(ubyte) * b, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax);
217 void cdfCanvasPutImageRectRGBA(cdCanvas* canvas, int iw, int ih, const(ubyte) * r, const(ubyte) * g, const(ubyte) * b, const(ubyte) * a, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax);
218 void cdfCanvasPutImageRectMap(cdCanvas* canvas, int iw, int ih, const(ubyte) * index, const(long) * colors, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax);
219 
220 /* server images - deprecated (use double buffer drivers) */
221 cdImage* cdCanvasCreateImage(cdCanvas* canvas, int w, int h);
222 void cdKillImage(cdImage* image);
223 void cdCanvasGetImage(cdCanvas* canvas, cdImage* image, int x, int y);
224 void cdCanvasPutImageRect(cdCanvas* canvas, cdImage* image, int x, int y, int xmin, int xmax, int ymin, int ymax);
225 void cdCanvasScrollArea(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, int dx, int dy);
226 
227 /* bitmap - deprecated (use imImage) */
228 cdBitmap* cdCreateBitmap(int w, int h, int type);
229 cdBitmap* cdInitBitmap(int w, int h, int type, ...);
230 void cdKillBitmap(cdBitmap* bitmap);
231 ubyte* cdBitmapGetData(cdBitmap* bitmap, int dataptr);
232 void cdBitmapSetRect(cdBitmap* bitmap, int xmin, int xmax, int ymin, int ymax);
233 void cdCanvasPutBitmap(cdCanvas* canvas, cdBitmap* bitmap, int x, int y, int w, int h);
234 void cdCanvasGetBitmap(cdCanvas* canvas, cdBitmap* bitmap, int x, int y);
235 void cdBitmapRGB2Map(cdBitmap* bitmap_rgb, cdBitmap* bitmap_map);
236 
237 /* color */
238 long cdEncodeColor(ubyte red, ubyte green, ubyte blue);
239 long cdEncodeColorAlpha(ubyte red, ubyte green, ubyte blue, ubyte alpha);
240 long cdEncodeAlpha(long color, ubyte alpha);
241 void cdDecodeColor(long color, ubyte* red, ubyte* green, ubyte* blue);
242 void cdDecodeColorAlpha(long color, ubyte* red, ubyte* green, ubyte* blue, ubyte* alpha);
243 ubyte cdDecodeAlpha(long color);
244 
245 pragma(inline, true) {
246 
247 auto cdAlpha(T)(T _)  { return cast(ubyte)(~(((_) >> 24) & 0xFF)); }
248 auto cdReserved(T)(_) { return cast(ubyte)(((_) >> 24) & 0xFF); }
249 auto cdRed(T)(_)      { return cast(ubyte)(((_) >> 16) & 0xFF); }
250 auto cdGreen(T)(_)    { return cast(ubyte)(((_) >>  8) & 0xFF); }
251 auto cdBlue(T)(_)     { return cast(ubyte)(((_) >>  0) & 0xFF); }
252 
253 }
254 
255 /* client image color conversion */
256 void cdRGB2Map(int width, int height, const(ubyte) * red, const(ubyte) * green, const(ubyte) * blue, ubyte* index, int pal_size, long *color);
257 
258 
259 /* CD Values */
260 
261 enum CD_QUERY = -1;             /* query value */
262 
263 enum {                        /* bitmap type */
264  CD_RGB,                      /* these definitions are compatible with the IM library */
265  CD_MAP,
266  CD_RGBA = 0x100
267 };
268 
269 enum {                         /* bitmap data */
270  CD_IRED,
271  CD_IGREEN,
272  CD_IBLUE,
273  CD_IALPHA,
274  CD_INDEX,
275  CD_COLORS
276 };
277 
278 enum {                          /* status report */
279  CD_ERROR = -1,
280  CD_OK    =  0
281 };
282 
283 enum {                          /* clip mode */
284  CD_CLIPOFF,
285  CD_CLIPAREA,
286  CD_CLIPPOLYGON,
287  CD_CLIPREGION
288 };
289 
290 enum {                          /* region combine mode */
291  CD_UNION,
292  CD_INTERSECT,
293  CD_DIFFERENCE,
294  CD_NOTINTERSECT
295 };
296 
297 enum {                          /* polygon mode (begin...end) */
298  CD_FILL,
299  CD_OPEN_LINES,
300  CD_CLOSED_LINES,
301  CD_CLIP,
302  CD_BEZIER,
303  CD_REGION,
304  CD_PATH
305 };
306 
307 enum CD_POLYCUSTOM = 10;
308 
309 enum {                          /* path actions */
310  CD_PATH_NEW,
311  CD_PATH_MOVETO,
312  CD_PATH_LINETO,
313  CD_PATH_ARC,
314  CD_PATH_CURVETO,
315  CD_PATH_CLOSE,
316  CD_PATH_FILL,
317  CD_PATH_STROKE,
318  CD_PATH_FILLSTROKE,
319  CD_PATH_CLIP
320 };
321 
322 enum {                          /* fill mode */
323  CD_EVENODD,
324  CD_WINDING
325 };
326 
327 enum {                          /* line join  */
328  CD_MITER,
329  CD_BEVEL,
330  CD_ROUND
331 };
332 
333 enum {                          /* line cap  */
334  CD_CAPFLAT,
335  CD_CAPSQUARE,
336  CD_CAPROUND
337 };
338 
339 enum {                          /* background opacity mode */
340  CD_OPAQUE,
341  CD_TRANSPARENT
342 };
343 
344 enum {                          /* write mode */
345  CD_REPLACE,
346  CD_XOR,
347  CD_NOT_XOR
348 };
349 
350 enum {                          /* color allocation mode (palette) */
351  CD_POLITE,
352  CD_FORCE
353 };
354 
355 enum {                          /* line style */
356  CD_CONTINUOUS,
357  CD_DASHED,
358  CD_DOTTED,
359  CD_DASH_DOT,
360  CD_DASH_DOT_DOT,
361  CD_CUSTOM
362 };
363 
364 enum {                          /* marker type */
365  CD_PLUS,
366  CD_STAR,
367  CD_CIRCLE,
368  CD_X,
369  CD_BOX,
370  CD_DIAMOND,
371  CD_HOLLOW_CIRCLE,
372  CD_HOLLOW_BOX,
373  CD_HOLLOW_DIAMOND
374 };
375 
376 enum {                          /* hatch type */
377  CD_HORIZONTAL,
378  CD_VERTICAL,
379  CD_FDIAGONAL,
380  CD_BDIAGONAL,
381  CD_CROSS,
382  CD_DIAGCROSS
383 };
384 
385 enum {                          /* interior style */
386  CD_SOLID,
387  CD_HATCH,
388  CD_STIPPLE,
389  CD_PATTERN,
390  CD_HOLLOW
391 };
392 
393 enum {                          /* text alignment */
394  CD_NORTH,
395  CD_SOUTH,
396  CD_EAST,
397  CD_WEST,
398  CD_NORTH_EAST,
399  CD_NORTH_WEST,
400  CD_SOUTH_EAST,
401  CD_SOUTH_WEST,
402  CD_CENTER,
403  CD_BASE_LEFT,
404  CD_BASE_CENTER,
405  CD_BASE_RIGHT
406 };
407 
408 enum {                          /* style */
409  CD_PLAIN  = 0,
410  CD_BOLD   = 1,
411  CD_ITALIC = 2,
412  CD_UNDERLINE = 4,
413  CD_STRIKEOUT = 8
414 };
415 
416 enum CD_BOLD_ITALIC = (CD_BOLD|CD_ITALIC);  /* compatibility name */
417 
418 enum {                          /* some font sizes */
419  CD_SMALL    =  8,
420  CD_STANDARD = 12,
421  CD_LARGE    = 18
422 };
423 
424 /* Context Capabilities */
425 enum CD_CAP_NONE             = 0x00000000;
426 enum CD_CAP_FLUSH            = 0x00000001;
427 enum CD_CAP_CLEAR            = 0x00000002;
428 enum CD_CAP_PLAY             = 0x00000004;
429 enum CD_CAP_YAXIS            = 0x00000008;
430 enum CD_CAP_CLIPAREA         = 0x00000010;
431 enum CD_CAP_CLIPPOLY         = 0x00000020;
432 enum CD_CAP_REGION           = 0x00000040;
433 enum CD_CAP_RECT             = 0x00000080;
434 enum CD_CAP_CHORD            = 0x00000100;
435 enum CD_CAP_IMAGERGB         = 0x00000200;
436 enum CD_CAP_IMAGERGBA        = 0x00000400;
437 enum CD_CAP_IMAGEMAP         = 0x00000800;
438 enum CD_CAP_GETIMAGERGB      = 0x00001000;
439 enum CD_CAP_IMAGESRV         = 0x00002000;
440 enum CD_CAP_BACKGROUND       = 0x00004000;
441 enum CD_CAP_BACKOPACITY      = 0x00008000;
442 enum CD_CAP_WRITEMODE        = 0x00010000;
443 enum CD_CAP_LINESTYLE        = 0x00020000;
444 enum CD_CAP_LINEWITH         = 0x00040000;
445 enum CD_CAP_FPRIMTIVES       = 0x00080000;
446 enum CD_CAP_HATCH            = 0x00100000;
447 enum CD_CAP_STIPPLE          = 0x00200000;
448 enum CD_CAP_PATTERN          = 0x00400000;
449 enum CD_CAP_FONT             = 0x00800000;
450 enum CD_CAP_FONTDIM          = 0x01000000;
451 enum CD_CAP_TEXTSIZE         = 0x02000000;
452 enum CD_CAP_TEXTORIENTATION  = 0x04000000;
453 enum CD_CAP_PALETTE          = 0x08000000;
454 enum CD_CAP_LINECAP          = 0x10000000;
455 enum CD_CAP_LINEJOIN         = 0x20000000;
456 enum CD_CAP_PATH             = 0x40000000;
457 enum CD_CAP_BEZIER           = 0x80000000;
458 enum CD_CAP_ALL              = 0xFFFFFFFF;
459 
460 /* Context Types */
461 enum {
462   CD_CTX_WINDOW,
463   CD_CTX_DEVICE,
464   CD_CTX_IMAGE,
465   CD_CTX_FILE
466 };
467 
468 /* cdPlay definitions */
469 enum CD_SIZECB = 0;        /* size callback */
470 alias cdSizeCB = int function(cdCanvas *canvas, int w, int h, double w_mm, double h_mm);
471 enum CD_ABORT = 1;
472 enum CD_CONTINUE = 0;
473 
474 /* simulation flags */
475 enum CD_SIM_NONE         = 0x0000;
476 enum CD_SIM_LINE         = 0x0001;
477 enum CD_SIM_RECT         = 0x0002;
478 enum CD_SIM_BOX          = 0x0004;
479 enum CD_SIM_ARC          = 0x0008;
480 enum CD_SIM_SECTOR       = 0x0010;
481 enum CD_SIM_CHORD        = 0x0020;
482 enum CD_SIM_POLYLINE     = 0x0040;
483 enum CD_SIM_POLYGON      = 0x0080;
484 enum CD_SIM_TEXT         = 0x0100;
485 enum CD_SIM_ALL          = 0xFFFF;
486 
487 enum CD_SIM_LINES = (CD_SIM_LINE | CD_SIM_RECT | CD_SIM_ARC | CD_SIM_POLYLINE);
488 enum CD_SIM_FILLS = (CD_SIM_BOX | CD_SIM_SECTOR | CD_SIM_CHORD | CD_SIM_POLYGON);
489 
490 /* some predefined colors for convenience */
491 enum CD_RED           = 0xFF0000L;   /* 255,  0,  0 */
492 enum CD_DARK_RED      = 0x800000L;   /* 128,  0,  0 */
493 enum CD_GREEN         = 0x00FF00L;   /*   0,255,  0 */
494 enum CD_DARK_GREEN    = 0x008000L;   /*   0,128,  0 */
495 enum CD_BLUE          = 0x0000FFL;   /*   0,  0,255 */
496 enum CD_DARK_BLUE     = 0x000080L;   /*   0,  0,128 */
497 
498 enum CD_YELLOW        = 0xFFFF00L;   /* 255,255,  0 */
499 enum CD_DARK_YELLOW   = 0x808000L;   /* 128,128,  0 */
500 enum CD_MAGENTA       = 0xFF00FFL;   /* 255,  0,255 */
501 enum CD_DARK_MAGENTA  = 0x800080L;   /* 128,  0,128 */
502 enum CD_CYAN          = 0x00FFFFL;   /*   0,255,255 */
503 enum CD_DARK_CYAN     = 0x008080L;   /*   0,128,128 */
504 
505 enum CD_WHITE         = 0xFFFFFFL;   /* 255,255,255 */
506 enum CD_BLACK         = 0x000000L;   /*   0,  0,  0 */
507 
508 enum CD_DARK_GRAY     = 0x808080L;   /* 128,128,128 */
509 enum CD_GRAY          = 0xC0C0C0L;   /* 192,192,192 */
510 
511 /* some usefull conversion factors */
512 enum CD_MM2PT     = 2.834645669;   /* milimeters to points (pt = CD_MM2PT * mm) */
513 enum CD_RAD2DEG  = 57.295779513;   /* radians to degrees (deg = CD_RAD2DEG * rad) */
514 enum CD_DEG2RAD  = 0.01745329252;  /* degrees to radians (rad = CD_DEG2RAD * deg) */
515 
516 /* paper sizes */
517 enum {
518   CD_A0,
519   CD_A1,
520   CD_A2,
521   CD_A3,
522   CD_A4,
523   CD_A5,
524   CD_LETTER,
525   CD_LEGAL
526 };
527 
528 
529 
530 /******************************************************************************
531 Copyright (C) 1994-2015 Tecgraf/PUC-Rio.
532 
533 Permission is hereby granted, free of charge, to any person obtaining
534 a copy of this software and associated documentation files (the
535 "Software"), to deal in the Software without restriction, including
536 without limitation the rights to use, copy, modify, merge, publish,
537 distribute, sublicense, and/or sell copies of the Software, and to
538 permit persons to whom the Software is furnished to do so, subject to
539 the following conditions:
540 
541 The above copyright notice and this permission notice shall be
542 included in all copies or substantial portions of the Software.
543 
544 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
545 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
546 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
547 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
548 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
549 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
550 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
551 ******************************************************************************/
552