1 /*
2   Copyright (C) 2003 - 2020 GraphicsMagick Group
3   Copyright (C) 2002 ImageMagick Studio
4 
5   This program is covered by multiple licenses, which are described in
6   Copyright.txt. You should have received a copy of Copyright.txt with this
7   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
8 
9   Drawing methods.
10 */
11 #ifndef _MAGICK_RENDER_H
12 #define _MAGICK_RENDER_H
13 
14 #include "magick/type.h"
15 
16 #if defined(__cplusplus) || defined(c_plusplus)
17 extern "C" {
18 #endif
19 
20 /*
21   Enum declarations.
22 */
23 typedef enum
24 {
25   UndefinedAlign,
26   LeftAlign,
27   CenterAlign,
28   RightAlign
29 } AlignType;
30 
31 typedef enum
32 {
33   UserSpace,
34   UserSpaceOnUse,
35   ObjectBoundingBox
36 } ClipPathUnits;
37 
38 typedef enum
39 {
40   NoDecoration,
41   UnderlineDecoration,
42   OverlineDecoration,
43   LineThroughDecoration
44 } DecorationType;
45 
46 typedef enum
47 {
48   UndefinedRule,
49 #undef EvenOddRule
50   EvenOddRule,
51   NonZeroRule
52 } FillRule;
53 
54 typedef enum
55 {
56   UndefinedGradient,
57   LinearGradient,
58   RadialGradient
59 } GradientType;
60 
61 typedef enum
62 {
63   UndefinedCap,
64   ButtCap,
65   RoundCap,
66   SquareCap
67 } LineCap;
68 
69 typedef enum
70 {
71   UndefinedJoin,
72   MiterJoin,
73   RoundJoin,
74   BevelJoin
75 } LineJoin;
76 
77 typedef enum
78 {
79   PointMethod = 0,
80   ReplaceMethod,
81   FloodfillMethod,
82   FillToBorderMethod,
83   ResetMethod
84 } PaintMethod;
85 
86 typedef enum
87 {
88   UndefinedPrimitive = 0,
89   PointPrimitive,
90   LinePrimitive,
91   RectanglePrimitive,
92   RoundRectanglePrimitive,
93   ArcPrimitive,
94   EllipsePrimitive,
95   CirclePrimitive,
96   PolylinePrimitive,
97   PolygonPrimitive,
98   BezierPrimitive,
99   ColorPrimitive,
100   MattePrimitive,
101   TextPrimitive,
102   ImagePrimitive,
103   PathPrimitive
104 } PrimitiveType;
105 
106 typedef enum
107 {
108   UndefinedReference,
109   GradientReference
110 } ReferenceType;
111 
112 typedef enum
113 {
114   UndefinedSpread,
115   PadSpread,
116   ReflectSpead,
117   RepeatSpread
118 } SpreadMethod;
119 
120 /*
121   Typedef declarations.
122 */
123 typedef struct _GradientInfo
124 {
125   GradientType
126     type;
127 
128   PixelPacket
129     color;
130 
131   SegmentInfo
132     stop;
133 
134   unsigned long
135     length;
136 
137   SpreadMethod
138     spread;
139 
140   unsigned long
141     signature;
142 
143   struct _GradientInfo
144     *previous,
145     *next;
146 } GradientInfo;
147 
148 typedef struct _ElementReference
149 {
150   char
151     *id;
152 
153   ReferenceType
154     type;
155 
156   GradientInfo
157     gradient;
158 
159   unsigned long
160     signature;
161 
162   struct _ElementReference
163     *previous,
164     *next;
165 } ElementReference;
166 
167 struct _DrawInfoExtra;  /* forward decl.; see member "extra" below */
168 
169 typedef struct _DrawInfo
170 {
171   char
172     *primitive,
173     *geometry;
174 
175   AffineMatrix
176     affine;
177 
178   GravityType
179     gravity;
180 
181   PixelPacket
182     fill,
183     stroke;
184 
185   double
186     stroke_width;
187 
188   GradientInfo
189     gradient;
190 
191   Image
192     *fill_pattern,
193     *tile,
194     *stroke_pattern;
195 
196   unsigned int
197     stroke_antialias,
198     text_antialias;
199 
200   FillRule
201     fill_rule;
202 
203   LineCap
204     linecap;
205 
206   LineJoin
207     linejoin;
208 
209   unsigned long
210     miterlimit;
211 
212   double
213     dash_offset;
214 
215   DecorationType
216     decorate;
217 
218   CompositeOperator
219     compose;
220 
221   char
222     *text,
223     *font,
224     *family;
225 
226   StyleType
227     style;
228 
229   StretchType
230     stretch;
231 
232   unsigned long
233     weight;
234 
235   char
236     *encoding;
237 
238   double
239     pointsize;
240 
241   char
242     *density;
243 
244   AlignType
245     align;
246 
247   PixelPacket
248     undercolor,
249     border_color;
250 
251   char
252     *server_name;
253 
254   double
255     *dash_pattern; /* Terminated by value 0.0 (i.e. < MagickEpsilon)*/
256 
257 #if 0
258   char
259     *clip_path;
260 #endif
261   /*
262     Allow for expansion of DrawInfo without increasing its size.  The
263     internals are defined only in render.c.  Clients outside of render.c
264     can access the internals via the provided access functions (see below).
265 
266     This location in DrawInfo used to be occupied by char *clip_path. The
267     clip_path member now lives in _DrawInfoExtra.
268   */
269   struct _DrawInfoExtra
270     *extra;
271 
272   SegmentInfo
273     bounds;
274 
275   ClipPathUnits
276     clip_units;
277 
278   Quantum
279     opacity;
280 
281   unsigned int
282     render,
283     /*
284       Bit fields in flags:
285 
286         Bit 0: should this DrawInfo should be drawn as:
287           0:  normal (original behavior)
288           1:  SVG compliant
289         Bit 1: is the DrawInfo a clipping path:
290           0:  is not a clipping path
291           1:  is a clipping path
292 
293       Access to these bits should be through functions (defined in render.c):
294         IsDrawInfoClippingPath()
295         IsDrawInfoSVGCompliant()
296         IsDrawInfoSVGCompliantClippingPath()
297         SetDrawInfoClippingPath()
298         SetDrawInfoSVGCompliant()
299 
300       At the present time the SVG compliance bit only affects how clipping paths are drawn.
301     */
302     flags;  /* previously "unused1" */
303 
304   ElementReference
305     element_reference;
306 
307   unsigned long
308     signature;
309 } DrawInfo;
310 
311 typedef struct _PointInfo
312 {
313   double
314     x,
315     y;
316 } PointInfo;
317 
318 #if defined(MAGICK_IMPLEMENTATION)
319 #  include "magick/render-private.h"
320 #endif /* if defined(MAGICK_IMPLEMENTATION) */
321 
322 typedef struct _TypeMetric
323 {
324   PointInfo
325     pixels_per_em;
326 
327   double
328     ascent,
329     descent,
330     width,
331     height,
332     max_advance;
333 
334   SegmentInfo
335     bounds;
336 
337   double
338     underline_position,
339     underline_thickness;
340 } TypeMetric;
341 
342 /*
343   Method declarations.
344 */
345 extern MagickExport DrawInfo
346   *CloneDrawInfo(const ImageInfo *,const DrawInfo *);
347 
348 extern MagickExport MagickPassFail
349   AnnotateImage(Image *,const DrawInfo *),
350   DrawAffineImage(Image *,const Image *,const AffineMatrix *),
351   DrawClipPath(Image *,const DrawInfo *,const char *),
352   DrawImage(Image *,const DrawInfo *),
353   DrawPatternPath(Image *,const DrawInfo *,const char *,Image **),
354   GetTypeMetrics(Image *,const DrawInfo *,TypeMetric *);
355 
356 extern MagickExport void
357   DestroyDrawInfo(DrawInfo *),
358   GetDrawInfo(const ImageInfo *,DrawInfo *);
359 
360 /* provide public access to the clip_path member of DrawInfo */
361 extern MagickExport char
362   **DrawInfoGetClipPath(const DrawInfo *) MAGICK_FUNC_PURE;
363 
364 /* provide public access to the composite_path member of DrawInfo */
365 extern MagickExport char
366   **DrawInfoGetCompositePath(const DrawInfo *) MAGICK_FUNC_PURE;
367 
368 #if defined(__cplusplus) || defined(c_plusplus)
369 }
370 #endif
371 
372 #endif /* _MAGICK_RENDER_H */
373 
374 /*
375  * Local Variables:
376  * mode: c
377  * c-basic-offset: 2
378  * fill-column: 78
379  * End:
380  */
381