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