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-2019 Tecgraf/PUC-Rio";
29 enum CD_VERSION = "5.12";              /* bug fixes are reported only by cdVersion functions */
30 enum CD_VERSION_NUMBER = 512000;
31 enum CD_VERSION_DATE = "2019/01/07";  /* 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  CD_CLIPPATH
301 }
302 
303 enum {                          /* region combine mode */
304  CD_UNION,
305  CD_INTERSECT,
306  CD_DIFFERENCE,
307  CD_NOTINTERSECT
308 }
309 
310 enum {                          /* polygon mode (begin...end) */
311  CD_FILL,
312  CD_OPEN_LINES,
313  CD_CLOSED_LINES,
314  CD_CLIP,
315  CD_BEZIER,
316  CD_REGION,
317  CD_PATH
318 }
319 
320 enum CD_POLYCUSTOM = 10;
321 
322 enum {                          /* path actions */
323  CD_PATH_NEW,
324  CD_PATH_MOVETO,
325  CD_PATH_LINETO,
326  CD_PATH_ARC,
327  CD_PATH_CURVETO,
328  CD_PATH_CLOSE,
329  CD_PATH_FILL,
330  CD_PATH_STROKE,
331  CD_PATH_FILLSTROKE,
332  CD_PATH_CLIP
333 }
334 
335 enum {                          /* fill mode */
336  CD_EVENODD,
337  CD_WINDING
338 }
339 
340 enum {                          /* line join  */
341  CD_MITER,
342  CD_BEVEL,
343  CD_ROUND
344 }
345 
346 enum {                          /* line cap  */
347  CD_CAPFLAT,
348  CD_CAPSQUARE,
349  CD_CAPROUND
350 }
351 
352 enum {                          /* background opacity mode */
353  CD_OPAQUE,
354  CD_TRANSPARENT
355 }
356 
357 enum {                          /* write mode */
358  CD_REPLACE,
359  CD_XOR,
360  CD_NOT_XOR
361 }
362 
363 enum {                          /* color allocation mode (palette) */
364  CD_POLITE,
365  CD_FORCE
366 }
367 
368 enum {                          /* line style */
369  CD_CONTINUOUS,
370  CD_DASHED,
371  CD_DOTTED,
372  CD_DASH_DOT,
373  CD_DASH_DOT_DOT,
374  CD_CUSTOM
375 }
376 
377 enum {                          /* marker type */
378  CD_PLUS,
379  CD_STAR,
380  CD_CIRCLE,
381  CD_X,
382  CD_BOX,
383  CD_DIAMOND,
384  CD_HOLLOW_CIRCLE,
385  CD_HOLLOW_BOX,
386  CD_HOLLOW_DIAMOND
387 }
388 
389 enum {                          /* hatch type */
390  CD_HORIZONTAL,
391  CD_VERTICAL,
392  CD_FDIAGONAL,
393  CD_BDIAGONAL,
394  CD_CROSS,
395  CD_DIAGCROSS
396 }
397 
398 enum {                          /* interior style */
399  CD_SOLID,
400  CD_HATCH,
401  CD_STIPPLE,
402  CD_PATTERN,
403  CD_HOLLOW,
404  CD_CUSTOMPATTERN     /* used only in ContextPlus drivers */
405 }
406 
407 enum {                          /* text alignment */
408  CD_NORTH,
409  CD_SOUTH,
410  CD_EAST,
411  CD_WEST,
412  CD_NORTH_EAST,
413  CD_NORTH_WEST,
414  CD_SOUTH_EAST,
415  CD_SOUTH_WEST,
416  CD_CENTER,
417  CD_BASE_LEFT,
418  CD_BASE_CENTER,
419  CD_BASE_RIGHT
420 }
421 
422 enum {                          /* style */
423  CD_PLAIN  = 0,
424  CD_BOLD   = 1,
425  CD_ITALIC = 2,
426  CD_UNDERLINE = 4,
427  CD_STRIKEOUT = 8
428 }
429 
430 enum CD_BOLD_ITALIC = (CD_BOLD|CD_ITALIC);  /* compatibility name */
431 
432 enum {                          /* some font sizes */
433  CD_SMALL    =  8,
434  CD_STANDARD = 12,
435  CD_LARGE    = 18
436 }
437 
438 /* Context Capabilities */
439 enum CD_CAP_NONE             = 0x0000_0000;
440 enum CD_CAP_FLUSH            = 0x0000_0001;
441 enum CD_CAP_CLEAR            = 0x0000_0002;
442 enum CD_CAP_PLAY             = 0x0000_0004;
443 enum CD_CAP_YAXIS            = 0x0000_0008;
444 enum CD_CAP_CLIPAREA         = 0x0000_0010;
445 enum CD_CAP_CLIPPOLY         = 0x0000_0020;
446 enum CD_CAP_REGION           = 0x0000_0040;
447 enum CD_CAP_RECT             = 0x0000_0080;
448 enum CD_CAP_CHORD            = 0x0000_0100;
449 enum CD_CAP_IMAGERGB         = 0x0000_0200;
450 enum CD_CAP_IMAGERGBA        = 0x0000_0400;
451 enum CD_CAP_IMAGEMAP         = 0x0000_0800;
452 enum CD_CAP_GETIMAGERGB      = 0x0000_1000;
453 enum CD_CAP_IMAGESRV         = 0x0000_2000;
454 enum CD_CAP_BACKGROUND       = 0x0000_4000;
455 enum CD_CAP_BACKOPACITY      = 0x0000_8000;
456 enum CD_CAP_WRITEMODE        = 0x0001_0000;
457 enum CD_CAP_LINESTYLE        = 0x0002_0000;
458 enum CD_CAP_LINEWITH         = 0x0004_0000;
459 enum CD_CAP_FPRIMTIVES       = 0x0008_0000;
460 enum CD_CAP_HATCH            = 0x0010_0000;
461 enum CD_CAP_STIPPLE          = 0x0020_0000;
462 enum CD_CAP_PATTERN          = 0x0040_0000;
463 enum CD_CAP_FONT             = 0x0080_0000;
464 enum CD_CAP_FONTDIM          = 0x0100_0000;
465 enum CD_CAP_TEXTSIZE         = 0x0200_0000;
466 enum CD_CAP_TEXTORIENTATION  = 0x0400_0000;
467 enum CD_CAP_PALETTE          = 0x0800_0000;
468 enum CD_CAP_LINECAP          = 0x1000_0000;
469 enum CD_CAP_LINEJOIN         = 0x2000_0000;
470 enum CD_CAP_PATH             = 0x4000_0000;
471 enum CD_CAP_BEZIER           = 0x8000_0000;
472 enum CD_CAP_ALL              = 0xFFFF_FFFF;
473 
474 /* Context Types */
475 enum {
476   CD_CTX_WINDOW,
477   CD_CTX_DEVICE,
478   CD_CTX_IMAGE,
479   CD_CTX_FILE
480 }
481 
482 /* cdPlay definitions */
483 enum CD_SIZECB = 0;        /* size callback */
484 //alias cdSizeCB = int function(cdCanvas* canvas, int w, int h, double w_mm, double h_mm) nothrow;
485 enum CD_ABORT = 1;
486 enum CD_CONTINUE = 0;
487 
488 /* simulation flags */
489 enum CD_SIM_NONE         = 0x0000;
490 enum CD_SIM_LINE         = 0x0001;
491 enum CD_SIM_RECT         = 0x0002;
492 enum CD_SIM_BOX          = 0x0004;
493 enum CD_SIM_ARC          = 0x0008;
494 enum CD_SIM_SECTOR       = 0x0010;
495 enum CD_SIM_CHORD        = 0x0020;
496 enum CD_SIM_POLYLINE     = 0x0040;
497 enum CD_SIM_POLYGON      = 0x0080;
498 enum CD_SIM_TEXT         = 0x0100;
499 enum CD_SIM_ALL          = 0xFFFF;
500 
501 enum CD_SIM_LINES = (CD_SIM_LINE | CD_SIM_RECT | CD_SIM_ARC | CD_SIM_POLYLINE);
502 enum CD_SIM_FILLS = (CD_SIM_BOX | CD_SIM_SECTOR | CD_SIM_CHORD | CD_SIM_POLYGON);
503 
504 /* some predefined colors for convenience */
505 enum  CD_RED           = 0xFF_00_00L;   /* 255,  0,  0 */
506 enum  CD_DARK_RED      = 0x80_00_00L;   /* 128,  0,  0 */
507 enum  CD_GREEN         = 0x00_FF_00L;   /*   0,255,  0 */
508 enum  CD_DARK_GREEN    = 0x00_80_00L;   /*   0,128,  0 */
509 enum  CD_BLUE          = 0x00_00_FFL;   /*   0,  0,255 */
510 enum  CD_DARK_BLUE     = 0x00_00_80L;   /*   0,  0,128 */
511 
512 enum  CD_YELLOW        = 0xFF_FF_00L;   /* 255,255,  0 */
513 enum  CD_DARK_YELLOW   = 0x80_80_00L;   /* 128,128,  0 */
514 enum  CD_MAGENTA       = 0xFF_00_FFL;   /* 255,  0,255 */
515 enum  CD_DARK_MAGENTA  = 0x80_00_80L;   /* 128,  0,128 */
516 enum  CD_CYAN          = 0x00_FF_FFL;   /*   0,255,255 */
517 enum  CD_DARK_CYAN     = 0x00_80_80L;   /*   0,128,128 */
518 
519 enum  CD_WHITE         = 0xFF_FF_FFL;   /* 255,255,255 */
520 enum  CD_BLACK         = 0x00_00_00L;   /*   0,  0,  0 */
521 
522 enum  CD_DARK_GRAY     = 0x80_80_80L;   /* 128,128,128 */
523 enum  CD_GRAY          = 0xC0_C0_C0L;   /* 192,192,192 */
524 
525 /* some useful conversion factors */
526 enum CD_MM2PT     = 2.834645669;   /* millimeters to points (pt = CD_MM2PT * mm) */
527 enum CD_RAD2DEG  = 57.295779513;   /* radians to degrees (deg = CD_RAD2DEG * rad) */
528 enum CD_DEG2RAD  = 0.01745329252;  /* degrees to radians (rad = CD_DEG2RAD * deg) */
529 
530 /* paper sizes */
531 enum {
532   CD_A0,
533   CD_A1,
534   CD_A2,
535   CD_A3,
536   CD_A4,
537   CD_A5,
538   CD_LETTER,
539   CD_LEGAL
540 }
541 
542 
543 
544 /******************************************************************************
545 Copyright (C) 1994-2019 Tecgraf/PUC-Rio.
546 
547 Permission is hereby granted, free of charge, to any person obtaining
548 a copy of this software and associated documentation files (the
549 "Software"), to deal in the Software without restriction, including
550 without limitation the rights to use, copy, modify, merge, publish,
551 distribute, sublicense, and/or sell copies of the Software, and to
552 permit persons to whom the Software is furnished to do so, subject to
553 the following conditions:
554 
555 The above copyright notice and this permission notice shall be
556 included in all copies or substantial portions of the Software.
557 
558 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
559 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
560 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
561 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
562 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
563 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
564 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
565 ******************************************************************************/