MagickWand 7.1.2-37
Convert, Edit, Or Compose Bitmap Images
Loading...
Searching...
No Matches
drawing-wand.c
1/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% DDDD RRRR AAA W W IIIII N N GGGG %
7% D D R R A A W W I NN N G %
8% D D RRRR AAAAA W W I N N N G GG %
9% D D R R A A W W W I N NN G G %
10% DDDD R R A A W W IIIII N N GGG %
11% %
12% W W AAA N N DDDD %
13% W W A A NN N D D %
14% W W W AAAAA N N N D D %
15% WW WW A A N NN D D %
16% W W A A N N DDDD %
17% %
18% %
19% MagickWand Image Vector Drawing Methods %
20% %
21% Software Design %
22% Bob Friesenhahn %
23% March 2002 %
24% %
25% %
26% Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization %
27% dedicated to making software imaging solutions freely available. %
28% %
29% You may not use this file except in compliance with the License. You may %
30% obtain a copy of the License at %
31% %
32% https://imagemagick.org/license/ %
33% %
34% Unless required by applicable law or agreed to in writing, software %
35% distributed under the License is distributed on an "AS IS" BASIS, %
36% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
37% See the License for the specific language governing permissions and %
38% limitations under the License. %
39% %
40%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41%
42%
43%
44*/
45␌
46/*
47 Include declarations.
48*/
49#include "MagickWand/studio.h"
50#include "MagickWand/MagickWand.h"
51#include "MagickWand/magick-wand-private.h"
52#include "MagickWand/wand.h"
53#include "MagickCore/image-private.h"
54#include "MagickCore/string-private.h"
55␌
56/*
57 Define declarations.
58*/
59#define DRAW_BINARY_IMPLEMENTATION 0
60
61#define CurrentContext (wand->graphic_context[wand->index])
62#define DrawingWandId "DrawingWand"
63#define ThrowDrawException(severity,tag,reason) (void) ThrowMagickException( \
64 wand->exception,GetMagickModule(),severity,tag,"`%s'",reason);
65␌
66/*
67 Typedef declarations.
68*/
69typedef enum
70{
71 PathDefaultOperation,
72 PathCloseOperation, /* Z|z (none) */
73 PathCurveToOperation, /* C|c (x1 y1 x2 y2 x y)+ */
74 PathCurveToQuadraticBezierOperation, /* Q|q (x1 y1 x y)+ */
75 PathCurveToQuadraticBezierSmoothOperation, /* T|t (x y)+ */
76 PathCurveToSmoothOperation, /* S|s (x2 y2 x y)+ */
77 PathEllipticArcOperation, /* A|a (rx ry x-axis-rotation large-arc-flag sweep-flag x y)+ */
78 PathLineToHorizontalOperation, /* H|h x+ */
79 PathLineToOperation, /* L|l (x y)+ */
80 PathLineToVerticalOperation, /* V|v y+ */
81 PathMoveToOperation /* M|m (x y)+ */
82} PathOperation;
83
84typedef enum
85{
86 DefaultPathMode,
87 AbsolutePathMode,
88 RelativePathMode
89} PathMode;
90
92{
93 size_t
94 id;
95
96 char
97 name[MagickPathExtent];
98
99 /* Support structures */
100 Image
101 *image;
102
103 ExceptionInfo
104 *exception;
105
106 /* MVG output string and housekeeping */
107 char
108 *mvg; /* MVG data */
109
110 size_t
111 mvg_alloc, /* total allocated memory */
112 mvg_length; /* total MVG length */
113
114 size_t
115 mvg_width; /* current line width */
116
117 /* Pattern support */
118 char
119 *pattern_id;
120
121 RectangleInfo
122 pattern_bounds;
123
124 size_t
125 pattern_offset;
126
127 /* Graphic wand */
128 size_t
129 index; /* array index */
130
131 DrawInfo
132 **graphic_context;
133
134 MagickBooleanType
135 filter_off; /* true if not filtering attributes */
136
137 /* Pretty-printing depth */
138 size_t
139 indent_depth; /* number of left-hand pad characters */
140
141 /* Path operation support */
142 PathOperation
143 path_operation;
144
145 PathMode
146 path_mode;
147
148 MagickBooleanType
149 destroy,
150 debug;
151
152 size_t
153 signature;
154};
155
156/*
157 Forward declarations.
158*/
159static int
160 MVGPrintf(DrawingWand *,const char *,...) wand_attribute((format
161 (printf,2,3))),
162 MVGAutoWrapPrintf(DrawingWand *,const char *,...) wand_attribute((format
163 (printf,2,3)));
164
165static void
166 MVGAppendColor(DrawingWand *,const PixelInfo *);
167␌
168/*
169 "Printf" for MVG commands
170*/
171static int MVGPrintf(DrawingWand *wand,const char *format,...)
172{
173 size_t
174 extent;
175
176 assert(wand != (DrawingWand *) NULL);
177 if (wand->debug != MagickFalse)
178 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",format);
179 assert(wand->signature == MagickWandSignature);
180 extent=20UL*MagickPathExtent;
181 if (wand->mvg == (char *) NULL)
182 {
183 wand->mvg=(char *) AcquireQuantumMemory(extent,sizeof(*wand->mvg));
184 if (wand->mvg == (char *) NULL)
185 {
186 ThrowDrawException(ResourceLimitError,"MemoryAllocationFailed",
187 wand->name);
188 return(-1);
189 }
190 wand->mvg_alloc=extent;
191 wand->mvg_length=0;
192 }
193 if (wand->mvg_alloc < (wand->mvg_length+10*MagickPathExtent))
194 {
195 extent+=wand->mvg_alloc;
196 wand->mvg=(char *) ResizeQuantumMemory(wand->mvg,extent,
197 sizeof(*wand->mvg));
198 if (wand->mvg == (char *) NULL)
199 {
200 ThrowDrawException(ResourceLimitError,"MemoryAllocationFailed",
201 wand->name);
202 return(-1);
203 }
204 wand->mvg_alloc=extent;
205 }
206 {
207 int
208 count;
209
210 ssize_t
211 offset;
212
213 va_list
214 argp;
215
216 while (wand->mvg_width < wand->indent_depth)
217 {
218 wand->mvg[wand->mvg_length]=' ';
219 wand->mvg_length++;
220 wand->mvg_width++;
221 }
222 wand->mvg[wand->mvg_length]='\0';
223 count=(-1);
224 offset=(ssize_t) (wand->mvg_alloc-wand->mvg_length-1);
225 if (offset > 0)
226 {
227 va_start(argp,format);
228 count=vsnprintf(wand->mvg+wand->mvg_length,(size_t) offset,format,argp);
229 va_end(argp);
230 }
231 if ((count < 0) || (count > (int) offset))
232 ThrowDrawException(DrawError,"UnableToPrint",format)
233 else
234 {
235 wand->mvg_length+=(size_t) count;
236 wand->mvg_width+=(size_t) count;
237 }
238 wand->mvg[wand->mvg_length]='\0';
239 if ((wand->mvg_length > 1) && (wand->mvg[wand->mvg_length-1] == '\n'))
240 wand->mvg_width=0;
241 assert((wand->mvg_length+1) < wand->mvg_alloc);
242 return(count);
243 }
244}
245
246static int MVGAutoWrapPrintf(DrawingWand *wand,const char *format,...)
247{
248 char
249 buffer[MagickPathExtent];
250
251 int
252 count;
253
254 va_list
255 argp;
256
257 va_start(argp,format);
258 count=vsnprintf(buffer,sizeof(buffer)-1,format,argp);
259 va_end(argp);
260 buffer[sizeof(buffer)-1]='\0';
261 if (count < 0)
262 ThrowDrawException(DrawError,"UnableToPrint",format)
263 else
264 {
265 if (((wand->mvg_width+(size_t) count) > 78) && (buffer[count-1] != '\n'))
266 (void) MVGPrintf(wand, "\n");
267 (void) MVGPrintf(wand,"%s",buffer);
268 }
269 return(count);
270}
271
272static void MVGAppendColor(DrawingWand *wand,const PixelInfo *packet)
273{
274 if ((packet->red == 0) && (packet->green == 0) && (packet->blue == 0) &&
275 (packet->alpha == (Quantum) TransparentAlpha))
276 (void) MVGPrintf(wand,"none");
277 else
278 {
279 char
280 tuple[MagickPathExtent];
281
282 GetColorTuple(packet,packet->colorspace != sRGBColorspace ? MagickFalse :
283 MagickTrue,tuple);
284 (void) MVGPrintf(wand,"%s",tuple);
285 }
286}
287
288static void MVGAppendPointsCommand(DrawingWand *wand,const char *command,
289 const size_t number_coordinates,const PointInfo *coordinates)
290{
291 const PointInfo
292 *coordinate;
293
294 size_t
295 i;
296
297 (void) MVGPrintf(wand,"%s",command);
298 for (i=number_coordinates, coordinate=coordinates; i != 0; i--)
299 {
300 (void) MVGAutoWrapPrintf(wand," %.17g %.17g",coordinate->x,coordinate->y);
301 coordinate++;
302 }
303 (void) MVGPrintf(wand, "\n");
304}
305
306static void AdjustAffine(DrawingWand *wand,const AffineMatrix *affine)
307{
308 assert(wand != (DrawingWand *) NULL);
309 assert(wand->signature == MagickWandSignature);
310 if (wand->debug != MagickFalse)
311 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
312 if ((affine->sx != 1.0) || (affine->rx != 0.0) || (affine->ry != 0.0) ||
313 (affine->sy != 1.0) || (affine->tx != 0.0) || (affine->ty != 0.0))
314 {
315 AffineMatrix
316 current;
317
318 current=CurrentContext->affine;
319 CurrentContext->affine.sx=affine->sx*current.sx+affine->ry*current.rx;
320 CurrentContext->affine.rx=affine->rx*current.sx+affine->sy*current.rx;
321 CurrentContext->affine.ry=affine->sx*current.ry+affine->ry*current.sy;
322 CurrentContext->affine.sy=affine->rx*current.ry+affine->sy*current.sy;
323 CurrentContext->affine.tx=affine->sx*current.tx+affine->ry*current.ty+
324 affine->tx;
325 CurrentContext->affine.ty=affine->rx*current.tx+affine->sy*current.ty+
326 affine->ty;
327 }
328}
329␌
330/*
331%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
332% %
333% %
334% %
335+ A c q u i r e D r a w i n g W a n d %
336% %
337% %
338% %
339%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
340%
341% AcquireDrawingWand() allocates an initial drawing wand which is an opaque
342% handle required by the remaining drawing methods.
343%
344% The format of the AcquireDrawingWand method is:
345%
346% DrawingWand AcquireDrawingWand(const DrawInfo *draw_info,Image *image)
347%
348% A description of each parameter follows:
349%
350% o draw_info: Initial drawing defaults. Set to NULL to use defaults.
351%
352% o image: the image to draw on.
353%
354*/
355WandExport DrawingWand *AcquireDrawingWand(const DrawInfo *draw_info,
356 Image *image)
357{
358 DrawingWand
359 *wand;
360
361 wand=NewDrawingWand();
362 if (draw_info != (const DrawInfo *) NULL)
363 {
364 CurrentContext=DestroyDrawInfo(CurrentContext);
365 CurrentContext=CloneDrawInfo((ImageInfo *) NULL,draw_info);
366 }
367 wand->image=DestroyImage(wand->image);
368 if (image != (Image *) NULL)
369 wand->destroy=MagickFalse;
370 wand->image=image;
371 return(wand);
372}
373␌
374/*
375%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
376% %
377% %
378% %
379% C l e a r D r a w i n g W a n d %
380% %
381% %
382% %
383%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
384%
385% ClearDrawingWand() clears resources associated with the drawing wand.
386%
387% The format of the ClearDrawingWand method is:
388%
389% void ClearDrawingWand(DrawingWand *wand)
390%
391% A description of each parameter follows:
392%
393% o wand: the drawing wand to clear.
394%
395*/
396WandExport void ClearDrawingWand(DrawingWand *wand)
397{
398 assert(wand != (DrawingWand *) NULL);
399 assert(wand->signature == MagickWandSignature);
400 if (wand->debug != MagickFalse)
401 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
402 for ( ; wand->index > 0; wand->index--)
403 CurrentContext=DestroyDrawInfo(CurrentContext);
404 CurrentContext=DestroyDrawInfo(CurrentContext);
405 wand->graphic_context=(DrawInfo **) RelinquishMagickMemory(
406 wand->graphic_context);
407 if (wand->pattern_id != (char *) NULL)
408 wand->pattern_id=DestroyString(wand->pattern_id);
409 wand->mvg=DestroyString(wand->mvg);
410 if ((wand->destroy != MagickFalse) && (wand->image != (Image *) NULL))
411 wand->image=DestroyImage(wand->image);
412 else
413 wand->image=(Image *) NULL;
414 wand->mvg=(char *) NULL;
415 wand->mvg_alloc=0;
416 wand->mvg_length=0;
417 wand->mvg_width=0;
418 wand->pattern_id=(char *) NULL;
419 wand->pattern_offset=0;
420 wand->pattern_bounds.x=0;
421 wand->pattern_bounds.y=0;
422 wand->pattern_bounds.width=0;
423 wand->pattern_bounds.height=0;
424 wand->index=0;
425 wand->graphic_context=(DrawInfo **) AcquireQuantumMemory(1,
426 sizeof(*wand->graphic_context));
427 if (wand->graphic_context == (DrawInfo **) NULL)
428 {
429 ThrowDrawException(ResourceLimitError,"MemoryAllocationFailed",
430 wand->name);
431 return;
432 }
433 CurrentContext=CloneDrawInfo((ImageInfo *) NULL,(DrawInfo *) NULL);
434 wand->filter_off=MagickTrue;
435 wand->indent_depth=0;
436 wand->path_operation=PathDefaultOperation;
437 wand->path_mode=DefaultPathMode;
438 wand->image=AcquireImage((const ImageInfo *) NULL,wand->exception);
439 ClearMagickException(wand->exception);
440 wand->destroy=MagickTrue;
441 wand->debug=IsEventLogging();
442}
443␌
444/*
445%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
446% %
447% %
448% %
449% C l o n e D r a w i n g W a n d %
450% %
451% %
452% %
453%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
454%
455% CloneDrawingWand() makes an exact copy of the specified wand.
456%
457% The format of the CloneDrawingWand method is:
458%
459% DrawingWand *CloneDrawingWand(const DrawingWand *wand)
460%
461% A description of each parameter follows:
462%
463% o wand: the magick wand.
464%
465*/
466WandExport DrawingWand *CloneDrawingWand(const DrawingWand *wand)
467{
468 DrawingWand
469 *clone_wand;
470
471 ssize_t
472 i;
473
474 assert(wand != (DrawingWand *) NULL);
475 assert(wand->signature == MagickWandSignature);
476 if (wand->debug != MagickFalse)
477 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
478 clone_wand=(DrawingWand *) AcquireMagickMemory(sizeof(*clone_wand));
479 if (clone_wand == (DrawingWand *) NULL)
480 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
481 (char *) NULL);
482 (void) memset(clone_wand,0,sizeof(*clone_wand));
483 clone_wand->id=AcquireWandId();
484 (void) FormatLocaleString(clone_wand->name,MagickPathExtent,
485 "DrawingWand-%.17g",(double) clone_wand->id);
486 clone_wand->exception=AcquireExceptionInfo();
487 InheritException(clone_wand->exception,wand->exception);
488 clone_wand->mvg=AcquireString(wand->mvg);
489 clone_wand->mvg_length=strlen(clone_wand->mvg);
490 clone_wand->mvg_alloc=wand->mvg_length+1;
491 clone_wand->mvg_width=wand->mvg_width;
492 clone_wand->pattern_id=AcquireString(wand->pattern_id);
493 clone_wand->pattern_offset=wand->pattern_offset;
494 clone_wand->pattern_bounds=wand->pattern_bounds;
495 clone_wand->index=wand->index;
496 clone_wand->graphic_context=(DrawInfo **) AcquireQuantumMemory((size_t)
497 wand->index+1UL,sizeof(*wand->graphic_context));
498 if (clone_wand->graphic_context == (DrawInfo **) NULL)
499 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
500 (char *) NULL);
501 for (i=0; i <= (ssize_t) wand->index; i++)
502 clone_wand->graphic_context[i]=CloneDrawInfo((ImageInfo *) NULL,
503 wand->graphic_context[i]);
504 clone_wand->filter_off=wand->filter_off;
505 clone_wand->indent_depth=wand->indent_depth;
506 clone_wand->path_operation=wand->path_operation;
507 clone_wand->path_mode=wand->path_mode;
508 clone_wand->image=wand->image;
509 if (wand->image != (Image *) NULL)
510 clone_wand->image=CloneImage(wand->image,0,0,MagickTrue,
511 clone_wand->exception);
512 clone_wand->destroy=MagickTrue;
513 clone_wand->debug=IsEventLogging();
514 if (clone_wand->debug != MagickFalse)
515 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",clone_wand->name);
516 clone_wand->signature=MagickWandSignature;
517 return(clone_wand);
518}
519␌
520/*
521%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
522% %
523% %
524% %
525% D e s t r o y D r a w i n g W a n d %
526% %
527% %
528% %
529%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
530%
531% DestroyDrawingWand() frees all resources associated with the drawing wand.
532% Once the drawing wand has been freed, it should not be used and further
533% unless it re-allocated.
534%
535% The format of the DestroyDrawingWand method is:
536%
537% DrawingWand *DestroyDrawingWand(DrawingWand *wand)
538%
539% A description of each parameter follows:
540%
541% o wand: the drawing wand to destroy.
542%
543*/
544WandExport DrawingWand *DestroyDrawingWand(DrawingWand *wand)
545{
546 assert(wand != (DrawingWand *) NULL);
547 assert(wand->signature == MagickWandSignature);
548 if (wand->debug != MagickFalse)
549 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
550 for ( ; wand->index > 0; wand->index--)
551 CurrentContext=DestroyDrawInfo(CurrentContext);
552 CurrentContext=DestroyDrawInfo(CurrentContext);
553 wand->graphic_context=(DrawInfo **) RelinquishMagickMemory(
554 wand->graphic_context);
555 if (wand->pattern_id != (char *) NULL)
556 wand->pattern_id=DestroyString(wand->pattern_id);
557 wand->mvg=DestroyString(wand->mvg);
558 if ((wand->destroy != MagickFalse) && (wand->image != (Image *) NULL))
559 wand->image=DestroyImage(wand->image);
560 wand->image=(Image *) NULL;
561 wand->exception=DestroyExceptionInfo(wand->exception);
562 wand->signature=(~MagickWandSignature);
563 RelinquishWandId(wand->id);
564 wand=(DrawingWand *) RelinquishMagickMemory(wand);
565 return(wand);
566}
567␌
568/*
569%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
570% %
571% %
572% %
573% D r a w A f f i n e %
574% %
575% %
576% %
577%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
578%
579% DrawAffine() adjusts the current affine transformation matrix with
580% the specified affine transformation matrix. Note that the current affine
581% transform is adjusted rather than replaced.
582%
583% The format of the DrawAffine method is:
584%
585% void DrawAffine(DrawingWand *wand,const AffineMatrix *affine)
586%
587% A description of each parameter follows:
588%
589% o wand: Drawing wand
590%
591% o affine: Affine matrix parameters
592%
593*/
594WandExport void DrawAffine(DrawingWand *wand,const AffineMatrix *affine)
595{
596 assert(wand != (DrawingWand *) NULL);
597 assert(wand->signature == MagickWandSignature);
598 if (wand->debug != MagickFalse)
599 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
600 assert(affine != (const AffineMatrix *) NULL);
601 AdjustAffine(wand,affine);
602 (void) MVGPrintf(wand,"affine %.17g %.17g %.17g %.17g %.17g %.17g\n",
603 affine->sx,affine->ry,affine->rx,affine->sy,affine->tx,affine->ty);
604}
605␌
606/*
607%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
608% %
609% %
610% %
611% D r a w A l p h a %
612% %
613% %
614% %
615%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
616%
617% DrawAlpha() paints on the image's alpha channel in order to set effected
618% pixels to transparent. The available paint methods are:
619%
620% PointMethod: Select the target pixel
621% ReplaceMethod: Select any pixel that matches the target pixel.
622% FloodfillMethod: Select the target pixel and matching neighbors.
623% FillToBorderMethod: Select the target pixel and neighbors not matching
624% border color.
625% ResetMethod: Select all pixels.
626%
627% The format of the DrawAlpha method is:
628%
629% void DrawAlpha(DrawingWand *wand,const double x,const double y,
630% const PaintMethod paint_method)
631%
632% A description of each parameter follows:
633%
634% o wand: the drawing wand.
635%
636% o x: x ordinate
637%
638% o y: y ordinate
639%
640% o paint_method: paint method.
641%
642*/
643WandExport void DrawAlpha(DrawingWand *wand,const double x,const double y,
644 const PaintMethod paint_method)
645{
646 assert(wand != (DrawingWand *) NULL);
647 assert(wand->signature == MagickWandSignature);
648 if (wand->debug != MagickFalse)
649 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
650 (void) MVGPrintf(wand,"alpha %.17g %.17g '%s'\n",x,y,CommandOptionToMnemonic(
651 MagickMethodOptions,(ssize_t) paint_method));
652}
653␌
654/*
655%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
656% %
657% %
658% %
659% D r a w A n n o t a t i o n %
660% %
661% %
662% %
663%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
664%
665% DrawAnnotation() draws text on the image.
666%
667% The format of the DrawAnnotation method is:
668%
669% void DrawAnnotation(DrawingWand *wand,const double x,
670% const double y,const unsigned char *text)
671%
672% A description of each parameter follows:
673%
674% o wand: the drawing wand.
675%
676% o x: x ordinate to left of text
677%
678% o y: y ordinate to text baseline
679%
680% o text: text to draw
681%
682*/
683WandExport void DrawAnnotation(DrawingWand *wand,const double x,const double y,
684 const unsigned char *text)
685{
686 char
687 *escaped_text;
688
689 assert(wand != (DrawingWand *) NULL);
690 assert(wand->signature == MagickWandSignature);
691 if (wand->debug != MagickFalse)
692 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
693 assert(text != (const unsigned char *) NULL);
694 escaped_text=EscapeString((const char *) text,'\'');
695 if (escaped_text != (char *) NULL)
696 {
697 (void) MVGPrintf(wand,"text %.17g %.17g '%s'\n",x,y,escaped_text);
698 escaped_text=DestroyString(escaped_text);
699 }
700}
701␌
702/*
703%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
704% %
705% %
706% %
707% D r a w A r c %
708% %
709% %
710% %
711%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
712%
713% DrawArc() draws an arc falling within a specified bounding rectangle on the
714% image.
715%
716% The format of the DrawArc method is:
717%
718% void DrawArc(DrawingWand *wand,const double sx,const double sy,
719% const double ex,const double ey,const double sd,const double ed)
720%
721% A description of each parameter follows:
722%
723% o wand: the drawing wand.
724%
725% o sx: starting x ordinate of bounding rectangle
726%
727% o sy: starting y ordinate of bounding rectangle
728%
729% o ex: ending x ordinate of bounding rectangle
730%
731% o ey: ending y ordinate of bounding rectangle
732%
733% o sd: starting degrees of rotation
734%
735% o ed: ending degrees of rotation
736%
737*/
738WandExport void DrawArc(DrawingWand *wand,const double sx,const double sy,
739 const double ex,const double ey,const double sd,const double ed)
740{
741 assert(wand != (DrawingWand *) NULL);
742 assert(wand->signature == MagickWandSignature);
743 if (wand->debug != MagickFalse)
744 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
745 (void) MVGPrintf(wand,"arc %.17g %.17g %.17g %.17g %.17g %.17g\n",sx,sy,ex,
746 ey,sd,ed);
747}
748␌
749/*
750%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
751% %
752% %
753% %
754% D r a w B e z i e r %
755% %
756% %
757% %
758%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
759%
760% DrawBezier() draws a bezier curve through a set of points on the image.
761%
762% The format of the DrawBezier method is:
763%
764% void DrawBezier(DrawingWand *wand,
765% const size_t number_coordinates,const PointInfo *coordinates)
766%
767% A description of each parameter follows:
768%
769% o wand: the drawing wand.
770%
771% o number_coordinates: number of coordinates
772%
773% o coordinates: coordinates
774%
775*/
776WandExport void DrawBezier(DrawingWand *wand,
777 const size_t number_coordinates,const PointInfo *coordinates)
778{
779 assert(wand != (DrawingWand *) NULL);
780 assert(wand->signature == MagickWandSignature);
781 if (wand->debug != MagickFalse)
782 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
783 assert(coordinates != (const PointInfo *) NULL);
784 MVGAppendPointsCommand(wand,"bezier",number_coordinates,coordinates);
785}
786␌
787/*
788%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
789% %
790% %
791% %
792% D r a w C i r c l e %
793% %
794% %
795% %
796%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
797%
798% DrawCircle() draws a circle on the image.
799%
800% The format of the DrawCircle method is:
801%
802% void DrawCircle(DrawingWand *wand,const double ox,
803% const double oy,const double px, const double py)
804%
805% A description of each parameter follows:
806%
807% o wand: the drawing wand.
808%
809% o ox: origin x ordinate
810%
811% o oy: origin y ordinate
812%
813% o px: perimeter x ordinate
814%
815% o py: perimeter y ordinate
816%
817*/
818WandExport void DrawCircle(DrawingWand *wand,const double ox,const double oy,
819 const double px,const double py)
820{
821 assert(wand != (DrawingWand *) NULL);
822 assert(wand->signature == MagickWandSignature);
823 if (wand->debug != MagickFalse)
824 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
825 (void) MVGPrintf(wand,"circle %.17g %.17g %.17g %.17g\n",ox,oy,px,py);
826}
827␌
828/*
829%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
830% %
831% %
832% %
833% D r a w C l e a r E x c e p t i o n %
834% %
835% %
836% %
837%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
838%
839% DrawClearException() clear any exceptions associated with the wand.
840%
841% The format of the DrawClearException method is:
842%
843% MagickBooleanType DrawClearException(DrawWand *wand)
844%
845% A description of each parameter follows:
846%
847% o wand: the drawing wand.
848%
849*/
850WandExport MagickBooleanType DrawClearException(DrawingWand *wand)
851{
852 assert(wand != (DrawingWand *) NULL);
853 assert(wand->signature == MagickWandSignature);
854 if (wand->debug != MagickFalse)
855 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
856 ClearMagickException(wand->exception);
857 return(MagickTrue);
858}
859
860/*
861%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
862% %
863% %
864% %
865% D r a w C l o n e E x c e p t i o n I n f o %
866% %
867% %
868% %
869%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
870%
871% DrawCloneExceptionInfo() clones the ExceptionInfo structure within the wand.
872%
873% The format of the DrawCloneExceptionInfo method is:
874%
875% ExceptionInfo *DrawCloneExceptionInfo(DrawWand *wand)
876%
877% A description of each parameter follows:
878%
879% o wand: the drawing wand.
880%
881*/
882WandExport ExceptionInfo *DrawCloneExceptionInfo(const DrawingWand *wand)
883{
884 assert(wand != (DrawingWand *) NULL);
885 assert(wand->signature == MagickWandSignature);
886 if (wand->exception == (ExceptionInfo*) NULL)
887 return (ExceptionInfo*) NULL;
888 return CloneExceptionInfo(wand->exception);
889}
890
891/*
892%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
893% %
894% %
895% %
896% D r a w C o l o r %
897% %
898% %
899% %
900%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
901%
902% DrawColor() draws color on image using the current fill color, starting at
903% specified position, and using specified paint method. The available paint
904% methods are:
905%
906% PointMethod: Recolors the target pixel
907% ReplaceMethod: Recolor any pixel that matches the target pixel.
908% FloodfillMethod: Recolors target pixels and matching neighbors.
909% ResetMethod: Recolor all pixels.
910%
911% The format of the DrawColor method is:
912%
913% void DrawColor(DrawingWand *wand,const double x,const double y,
914% const PaintMethod paint_method)
915%
916% A description of each parameter follows:
917%
918% o wand: the drawing wand.
919%
920% o x: x ordinate.
921%
922% o y: y ordinate.
923%
924% o paint_method: paint method.
925%
926*/
927WandExport void DrawColor(DrawingWand *wand, const double x, const double y,
928 const PaintMethod paint_method)
929{
930 assert(wand != (DrawingWand *)NULL);
931 assert(wand->signature == MagickWandSignature);
932 if (wand->debug != MagickFalse)
933 (void) LogMagickEvent(WandEvent, GetMagickModule(), "%s", wand->name);
934 (void) MVGPrintf(wand, "color %.17g %.17g '%s'\n",x,y,CommandOptionToMnemonic(
935 MagickMethodOptions,(ssize_t) paint_method));
936}
937␌
938/*
939%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
940% %
941% %
942% %
943% D r a w C o m p o s i t e %
944% %
945% %
946% %
947%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
948%
949% DrawComposite() composites an image onto the current image, using the
950% specified composition operator, specified position, and at the specified
951% size.
952%
953% The format of the DrawComposite method is:
954%
955% MagickBooleanType DrawComposite(DrawingWand *wand,
956% const CompositeOperator compose,const double x,
957% const double y,const double width,const double height,
958% MagickWand *magick_wand)
959%
960% A description of each parameter follows:
961%
962% o wand: the drawing wand.
963%
964% o compose: composition operator
965%
966% o x: x ordinate of top left corner
967%
968% o y: y ordinate of top left corner
969%
970% o width: Width to resize image to prior to compositing. Specify zero to
971% use existing width.
972%
973% o height: Height to resize image to prior to compositing. Specify zero
974% to use existing height.
975%
976% o magick_wand: Image to composite is obtained from this wand.
977%
978*/
979WandExport MagickBooleanType DrawComposite(DrawingWand *wand,
980 const CompositeOperator compose,const double x,const double y,
981 const double width,const double height,MagickWand *magick_wand)
982{
983 char
984 *base64,
985 *media_type;
986
987 const char
988 *mode;
989
990 ImageInfo
991 *image_info;
992
993 Image
994 *clone_image,
995 *image;
996
997 char
998 *p;
999
1000 ssize_t
1001 i;
1002
1003 size_t
1004 blob_length,
1005 encoded_length;
1006
1007 unsigned char
1008 *blob;
1009
1010 assert(wand != (DrawingWand *) NULL);
1011 assert(wand->signature == MagickWandSignature);
1012 if (wand->debug != MagickFalse)
1013 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1014 assert(magick_wand != (MagickWand *) NULL);
1015 image=GetImageFromMagickWand(magick_wand);
1016 if (image == (Image *) NULL)
1017 return(MagickFalse);
1018 clone_image=CloneImage(image,0,0,MagickTrue,wand->exception);
1019 if (clone_image == (Image *) NULL)
1020 return(MagickFalse);
1021 image_info=AcquireImageInfo();
1022 (void) CopyMagickString(image_info->magick,"MIFF",MagickPathExtent);
1023 media_type=MagickToMime(image_info->magick);
1024 blob_length=2048;
1025 blob=(unsigned char *) ImageToBlob(image_info,clone_image,&blob_length,
1026 wand->exception);
1027 image_info=DestroyImageInfo(image_info);
1028 clone_image=DestroyImageList(clone_image);
1029 if (blob == (void *) NULL)
1030 return(MagickFalse);
1031 encoded_length=0;
1032 base64=Base64Encode(blob,blob_length,&encoded_length);
1033 blob=(unsigned char *) RelinquishMagickMemory(blob);
1034 if (base64 == (char *) NULL)
1035 {
1036 char
1037 buffer[MagickPathExtent];
1038
1039 (void) FormatLocaleString(buffer,MagickPathExtent,"%.17g bytes",(double)
1040 (4L*blob_length/3L+4L));
1041 ThrowDrawException(ResourceLimitWarning,"MemoryAllocationFailed",
1042 wand->name);
1043 return(MagickFalse);
1044 }
1045 mode=CommandOptionToMnemonic(MagickComposeOptions,(ssize_t) compose);
1046 (void) MVGPrintf(wand,"image %s %.17g %.17g %.17g %.17g 'data:%s;base64,\n",
1047 mode,x,y,width,height,media_type);
1048 p=base64;
1049 for (i=(ssize_t) encoded_length; i > 0; i-=76)
1050 {
1051 (void) MVGPrintf(wand,"%.76s",p);
1052 p+=(ptrdiff_t) 76;
1053 if (i > 76)
1054 (void) MVGPrintf(wand,"\n");
1055 }
1056 (void) MVGPrintf(wand,"'\n");
1057 media_type=DestroyString(media_type);
1058 base64=DestroyString(base64);
1059 return(MagickTrue);
1060}
1061␌
1062/*
1063%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1064% %
1065% %
1066% %
1067% D r a w C o m m e n t %
1068% %
1069% %
1070% %
1071%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1072%
1073% DrawComment() adds a comment to a vector output stream.
1074%
1075% The format of the DrawComment method is:
1076%
1077% void DrawComment(DrawingWand *wand,const char *comment)
1078%
1079% A description of each parameter follows:
1080%
1081% o wand: the drawing wand.
1082%
1083% o comment: comment text
1084%
1085*/
1086WandExport void DrawComment(DrawingWand *wand,const char *comment)
1087{
1088 (void) MVGPrintf(wand,"#%s\n",comment);
1089}
1090␌
1091/*
1092%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1093% %
1094% %
1095% %
1096% D r a w E l l i p s e %
1097% %
1098% %
1099% %
1100%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1101%
1102% DrawEllipse() draws an ellipse on the image.
1103%
1104% The format of the DrawEllipse method is:
1105%
1106% void DrawEllipse(DrawingWand *wand,const double ox,const double oy,
1107% const double rx,const double ry,const double start,const double end)
1108%
1109% A description of each parameter follows:
1110%
1111% o wand: the drawing wand.
1112%
1113% o ox: origin x ordinate
1114%
1115% o oy: origin y ordinate
1116%
1117% o rx: radius in x
1118%
1119% o ry: radius in y
1120%
1121% o start: starting rotation in degrees
1122%
1123% o end: ending rotation in degrees
1124%
1125*/
1126WandExport void DrawEllipse(DrawingWand *wand,const double ox,const double oy,
1127 const double rx,const double ry,const double start,const double end)
1128{
1129 assert(wand != (DrawingWand *) NULL);
1130 assert(wand->signature == MagickWandSignature);
1131 if (wand->debug != MagickFalse)
1132 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1133 (void) MVGPrintf(wand,"ellipse %.17g %.17g %.17g %.17g %.17g %.17g\n",ox,oy,
1134 rx,ry,start,end);
1135}
1136␌
1137/*
1138%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1139% %
1140% %
1141% %
1142% D r a w G e t B o r d e r C o l o r %
1143% %
1144% %
1145% %
1146%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1147%
1148% DrawGetBorderColor() returns the border color used for drawing bordered
1149% objects.
1150%
1151% The format of the DrawGetBorderColor method is:
1152%
1153% void DrawGetBorderColor(const DrawingWand *wand,
1154% PixelWand *border_color)
1155%
1156% A description of each parameter follows:
1157%
1158% o wand: the drawing wand.
1159%
1160% o border_color: Return the border color.
1161%
1162*/
1163WandExport void DrawGetBorderColor(const DrawingWand *wand,
1164 PixelWand *border_color)
1165{
1166 assert(wand != (const DrawingWand *) NULL);
1167 assert(wand->signature == MagickWandSignature);
1168 assert(border_color != (PixelWand *) NULL);
1169 if (wand->debug != MagickFalse)
1170 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1171 PixelSetPixelColor(border_color,&CurrentContext->border_color);
1172}
1173␌
1174/*
1175%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1176% %
1177% %
1178% %
1179% D r a w G e t C l i p P a t h %
1180% %
1181% %
1182% %
1183%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1184%
1185% DrawGetClipPath() obtains the current clipping path ID. The value returned
1186% must be deallocated by the user when it is no longer needed.
1187%
1188% The format of the DrawGetClipPath method is:
1189%
1190% char *DrawGetClipPath(const DrawingWand *wand)
1191%
1192% A description of each parameter follows:
1193%
1194% o wand: the drawing wand.
1195%
1196*/
1197WandExport char *DrawGetClipPath(const DrawingWand *wand)
1198{
1199 assert(wand != (const DrawingWand *) NULL);
1200 assert(wand->signature == MagickWandSignature);
1201 if (wand->debug != MagickFalse)
1202 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1203 if (CurrentContext->clip_mask != (char *) NULL)
1204 return((char *) AcquireString(CurrentContext->clip_mask));
1205 return((char *) NULL);
1206}
1207␌
1208/*
1209%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1210% %
1211% %
1212% %
1213% D r a w G e t C l i p R u l e %
1214% %
1215% %
1216% %
1217%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1218%
1219% DrawGetClipRule() returns the current polygon fill rule to be used by the
1220% clipping path.
1221%
1222% The format of the DrawGetClipRule method is:
1223%
1224% FillRule DrawGetClipRule(const DrawingWand *wand)
1225%
1226% A description of each parameter follows:
1227%
1228% o wand: the drawing wand.
1229%
1230*/
1231WandExport FillRule DrawGetClipRule(const DrawingWand *wand)
1232{
1233 assert(wand != (const DrawingWand *) NULL);
1234 assert(wand->signature == MagickWandSignature);
1235 if (wand->debug != MagickFalse)
1236 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1237 return(CurrentContext->fill_rule);
1238}
1239␌
1240/*
1241%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1242% %
1243% %
1244% %
1245% D r a w G e t C l i p U n i t s %
1246% %
1247% %
1248% %
1249%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1250%
1251% DrawGetClipUnits() returns the interpretation of clip path units.
1252%
1253% The format of the DrawGetClipUnits method is:
1254%
1255% ClipPathUnits DrawGetClipUnits(const DrawingWand *wand)
1256%
1257% A description of each parameter follows:
1258%
1259% o wand: the drawing wand.
1260%
1261*/
1262WandExport ClipPathUnits DrawGetClipUnits(const DrawingWand *wand)
1263{
1264 assert(wand != (const DrawingWand *) NULL);
1265 assert(wand->signature == MagickWandSignature);
1266 if (wand->debug != MagickFalse)
1267 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1268 return(CurrentContext->clip_units);
1269}
1270␌
1271/*
1272%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1273% %
1274% %
1275% %
1276% D r a w G e t D e n s i t y %
1277% %
1278% %
1279% %
1280%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1281%
1282% DrawGetDensity() obtains the vertical and horizontal resolution. The value
1283% returned must be deallocated by the user when it is no longer needed.
1284%
1285% The format of the DrawGetDensity method is:
1286%
1287% char *DrawGetDensity(const DrawingWand *wand)
1288%
1289% A description of each parameter follows:
1290%
1291% o wand: the drawing wand.
1292%
1293*/
1294WandExport char *DrawGetDensity(const DrawingWand *wand)
1295{
1296 assert(wand != (const DrawingWand *) NULL);
1297 assert(wand->signature == MagickWandSignature);
1298 if (wand->debug != MagickFalse)
1299 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1300 if (CurrentContext->density != (char *) NULL)
1301 return((char *) AcquireString(CurrentContext->density));
1302 return((char *) NULL);
1303}
1304␌
1305/*
1306%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1307% %
1308% %
1309% %
1310% D r a w G e t E x c e p t i o n %
1311% %
1312% %
1313% %
1314%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1315%
1316% DrawGetException() returns the severity, reason, and description of any
1317% error that occurs when using other methods in this API.
1318%
1319% The format of the DrawGetException method is:
1320%
1321% char *DrawGetException(const DrawWand *wand,
1322% ExceptionType *severity)
1323%
1324% A description of each parameter follows:
1325%
1326% o wand: the drawing wand.
1327%
1328% o severity: the severity of the error is returned here.
1329%
1330*/
1331WandExport char *DrawGetException(const DrawingWand *wand,
1332 ExceptionType *severity)
1333{
1334 char
1335 *description;
1336
1337 assert(wand != (const DrawingWand *) NULL);
1338 assert(wand->signature == MagickWandSignature);
1339 if (wand->debug != MagickFalse)
1340 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1341 assert(severity != (ExceptionType *) NULL);
1342 *severity=wand->exception->severity;
1343 description=(char *) AcquireQuantumMemory(2UL*MagickPathExtent,
1344 sizeof(*description));
1345 if (description == (char *) NULL)
1346 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
1347 wand->name);
1348 *description='\0';
1349 if (wand->exception->reason != (char *) NULL)
1350 (void) CopyMagickString(description,GetLocaleExceptionMessage(
1351 wand->exception->severity,wand->exception->reason),
1352 MagickPathExtent);
1353 if (wand->exception->description != (char *) NULL)
1354 {
1355 (void) ConcatenateMagickString(description," (",MagickPathExtent);
1356 (void) ConcatenateMagickString(description,GetLocaleExceptionMessage(
1357 wand->exception->severity,wand->exception->description),
1358 MagickPathExtent);
1359 (void) ConcatenateMagickString(description,")",MagickPathExtent);
1360 }
1361 return(description);
1362}
1363␌
1364/*
1365%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1366% %
1367% %
1368% %
1369% P i x e l G e t E x c e p t i o n T y p e %
1370% %
1371% %
1372% %
1373%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1374%
1375% DrawGetExceptionType() the exception type associated with the wand. If
1376% no exception has occurred, UndefinedExceptionType is returned.
1377%
1378% The format of the DrawGetExceptionType method is:
1379%
1380% ExceptionType DrawGetExceptionType(const DrawWand *wand)
1381%
1382% A description of each parameter follows:
1383%
1384% o wand: the magick wand.
1385%
1386*/
1387WandExport ExceptionType DrawGetExceptionType(const DrawingWand *wand)
1388{
1389 assert(wand != (const DrawingWand *) NULL);
1390 assert(wand->signature == MagickWandSignature);
1391 if (wand->debug != MagickFalse)
1392 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1393 return(wand->exception->severity);
1394}
1395␌
1396/*
1397%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1398% %
1399% %
1400% %
1401% D r a w G e t F i l l C o l o r %
1402% %
1403% %
1404% %
1405%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1406%
1407% DrawGetFillColor() returns the fill color used for drawing filled objects.
1408%
1409% The format of the DrawGetFillColor method is:
1410%
1411% void DrawGetFillColor(const DrawingWand *wand,
1412% PixelWand *fill_color)
1413%
1414% A description of each parameter follows:
1415%
1416% o wand: the drawing wand.
1417%
1418% o fill_color: Return the fill color.
1419%
1420*/
1421WandExport void DrawGetFillColor(const DrawingWand *wand,PixelWand *fill_color)
1422{
1423 assert(wand != (const DrawingWand *) NULL);
1424 assert(wand->signature == MagickWandSignature);
1425 assert(fill_color != (PixelWand *) NULL);
1426 if (wand->debug != MagickFalse)
1427 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1428 PixelSetPixelColor(fill_color,&CurrentContext->fill);
1429}
1430␌
1431/*
1432%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1433% %
1434% %
1435% %
1436% D r a w G e t F i l l O p a c i t y %
1437% %
1438% %
1439% %
1440%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1441%
1442% DrawGetFillOpacity() returns the alpha used when drawing using the fill
1443% color or fill texture. Fully opaque is 1.0.
1444%
1445% The format of the DrawGetFillOpacity method is:
1446%
1447% double DrawGetFillOpacity(const DrawingWand *wand)
1448%
1449% A description of each parameter follows:
1450%
1451% o wand: the drawing wand.
1452%
1453*/
1454WandExport double DrawGetFillOpacity(const DrawingWand *wand)
1455{
1456 double
1457 alpha;
1458
1459 assert(wand != (const DrawingWand *) NULL);
1460 assert(wand->signature == MagickWandSignature);
1461 if (wand->debug != MagickFalse)
1462 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1463 alpha=(double) QuantumScale*CurrentContext->fill.alpha;
1464 return(alpha);
1465}
1466␌
1467/*
1468%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1469% %
1470% %
1471% %
1472% D r a w G e t F i l l R u l e %
1473% %
1474% %
1475% %
1476%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1477%
1478% DrawGetFillRule() returns the fill rule used while drawing polygons.
1479%
1480% The format of the DrawGetFillRule method is:
1481%
1482% FillRule DrawGetFillRule(const DrawingWand *wand)
1483%
1484% A description of each parameter follows:
1485%
1486% o wand: the drawing wand.
1487%
1488*/
1489WandExport FillRule DrawGetFillRule(const DrawingWand *wand)
1490{
1491 assert(wand != (const DrawingWand *) NULL);
1492 assert(wand->signature == MagickWandSignature);
1493 if (wand->debug != MagickFalse)
1494 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1495 return(CurrentContext->fill_rule);
1496}
1497␌
1498/*
1499%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1500% %
1501% %
1502% %
1503% D r a w G e t F o n t %
1504% %
1505% %
1506% %
1507%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1508%
1509% DrawGetFont() returns a null-terminated string specifying the font used
1510% when annotating with text. The value returned must be freed by the user
1511% when no longer needed.
1512%
1513% The format of the DrawGetFont method is:
1514%
1515% char *DrawGetFont(const DrawingWand *wand)
1516%
1517% A description of each parameter follows:
1518%
1519% o wand: the drawing wand.
1520%
1521*/
1522WandExport char *DrawGetFont(const DrawingWand *wand)
1523{
1524 assert(wand != (const DrawingWand *) NULL);
1525 assert(wand->signature == MagickWandSignature);
1526 if (wand->debug != MagickFalse)
1527 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1528 if (CurrentContext->font != (char *) NULL)
1529 return(AcquireString(CurrentContext->font));
1530 return((char *) NULL);
1531}
1532␌
1533/*
1534%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1535% %
1536% %
1537% %
1538% D r a w G e t F o n t F a m i l y %
1539% %
1540% %
1541% %
1542%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1543%
1544% DrawGetFontFamily() returns the font family to use when annotating with text.
1545% The value returned must be freed by the user when it is no longer needed.
1546%
1547% The format of the DrawGetFontFamily method is:
1548%
1549% char *DrawGetFontFamily(const DrawingWand *wand)
1550%
1551% A description of each parameter follows:
1552%
1553% o wand: the drawing wand.
1554%
1555*/
1556WandExport char *DrawGetFontFamily(const DrawingWand *wand)
1557{
1558 assert(wand != (const DrawingWand *) NULL);
1559 assert(wand->signature == MagickWandSignature);
1560 if (wand->debug != MagickFalse)
1561 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1562 if (CurrentContext->family != NULL)
1563 return(AcquireString(CurrentContext->family));
1564 return((char *) NULL);
1565}
1566␌
1567/*
1568%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1569% %
1570% %
1571% %
1572% D r a w G e t F o n t R e s o l u t i o n %
1573% %
1574% %
1575% %
1576%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1577%
1578% DrawGetFontResolution() gets the image X and Y resolution.
1579%
1580% The format of the DrawGetFontResolution method is:
1581%
1582% MagickBooleanType DrawGetFontResolution(const DrawingWand *wand,
1583% double *x,double *y)
1584%
1585% A description of each parameter follows:
1586%
1587% o wand: the magick wand.
1588%
1589% o x: the x-resolution.
1590%
1591% o y: the y-resolution.
1592%
1593*/
1594WandExport MagickBooleanType DrawGetFontResolution(const DrawingWand *wand,
1595 double *x,double *y)
1596{
1597 assert(wand != (DrawingWand *) NULL);
1598 assert(wand->signature == MagickWandSignature);
1599 if (wand->debug != MagickFalse)
1600 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1601 *x=DefaultResolution;
1602 *y=DefaultResolution;
1603 if (CurrentContext->density != (char *) NULL)
1604 {
1605 GeometryInfo
1606 geometry_info;
1607
1608 MagickStatusType
1609 flags;
1610
1611 flags=ParseGeometry(CurrentContext->density,&geometry_info);
1612 *x=geometry_info.rho;
1613 *y=geometry_info.sigma;
1614 if ((flags & SigmaValue) == MagickFalse)
1615 *y=(*x);
1616 }
1617 return(MagickTrue);
1618}
1619␌
1620/*
1621%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1622% %
1623% %
1624% %
1625% D r a w G e t F o n t S i z e %
1626% %
1627% %
1628% %
1629%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1630%
1631% DrawGetFontSize() returns the font pointsize used when annotating with text.
1632%
1633% The format of the DrawGetFontSize method is:
1634%
1635% double DrawGetFontSize(const DrawingWand *wand)
1636%
1637% A description of each parameter follows:
1638%
1639% o wand: the drawing wand.
1640%
1641*/
1642WandExport double DrawGetFontSize(const DrawingWand *wand)
1643{
1644 assert(wand != (const DrawingWand *) NULL);
1645 assert(wand->signature == MagickWandSignature);
1646 if (wand->debug != MagickFalse)
1647 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1648 return(CurrentContext->pointsize);
1649}
1650␌
1651/*
1652%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1653% %
1654% %
1655% %
1656% D r a w G e t F o n t S t r e t c h %
1657% %
1658% %
1659% %
1660%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1661%
1662% DrawGetFontStretch() returns the font stretch used when annotating with text.
1663%
1664% The format of the DrawGetFontStretch method is:
1665%
1666% StretchType DrawGetFontStretch(const DrawingWand *wand)
1667%
1668% A description of each parameter follows:
1669%
1670% o wand: the drawing wand.
1671%
1672*/
1673WandExport StretchType DrawGetFontStretch(const DrawingWand *wand)
1674{
1675 assert(wand != (const DrawingWand *) NULL);
1676 assert(wand->signature == MagickWandSignature);
1677 if (wand->debug != MagickFalse)
1678 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1679 return(CurrentContext->stretch);
1680}
1681␌
1682/*
1683%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1684% %
1685% %
1686% %
1687% D r a w G e t F o n t S t y l e %
1688% %
1689% %
1690% %
1691%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1692%
1693% DrawGetFontStyle() returns the font style used when annotating with text.
1694%
1695% The format of the DrawGetFontStyle method is:
1696%
1697% StyleType DrawGetFontStyle(const DrawingWand *wand)
1698%
1699% A description of each parameter follows:
1700%
1701% o wand: the drawing wand.
1702%
1703*/
1704WandExport StyleType DrawGetFontStyle(const DrawingWand *wand)
1705{
1706 assert(wand != (const DrawingWand *) NULL);
1707 assert(wand->signature == MagickWandSignature);
1708 if (wand->debug != MagickFalse)
1709 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1710 return(CurrentContext->style);
1711}
1712␌
1713/*
1714%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1715% %
1716% %
1717% %
1718% D r a w G e t F o n t W e i g h t %
1719% %
1720% %
1721% %
1722%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1723%
1724% DrawGetFontWeight() returns the font weight used when annotating with text.
1725%
1726% The format of the DrawGetFontWeight method is:
1727%
1728% size_t DrawGetFontWeight(const DrawingWand *wand)
1729%
1730% A description of each parameter follows:
1731%
1732% o wand: the drawing wand.
1733%
1734*/
1735WandExport size_t DrawGetFontWeight(const DrawingWand *wand)
1736{
1737 assert(wand != (const DrawingWand *) NULL);
1738 assert(wand->signature == MagickWandSignature);
1739 if (wand->debug != MagickFalse)
1740 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1741 return(CurrentContext->weight);
1742}
1743␌
1744/*
1745%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1746% %
1747% %
1748% %
1749% D r a w G e t G r a v i t y %
1750% %
1751% %
1752% %
1753%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1754%
1755% DrawGetGravity() returns the text placement gravity used when annotating
1756% with text.
1757%
1758% The format of the DrawGetGravity method is:
1759%
1760% GravityType DrawGetGravity(const DrawingWand *wand)
1761%
1762% A description of each parameter follows:
1763%
1764% o wand: the drawing wand.
1765%
1766*/
1767WandExport GravityType DrawGetGravity(const DrawingWand *wand)
1768{
1769 assert(wand != (const DrawingWand *) NULL);
1770 assert(wand->signature == MagickWandSignature);
1771 if (wand->debug != MagickFalse)
1772 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1773 return(CurrentContext->gravity);
1774}
1775␌
1776/*
1777%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1778% %
1779% %
1780% %
1781% D r a w G e t O p a c i t y %
1782% %
1783% %
1784% %
1785%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1786%
1787% DrawGetOpacity() returns the alpha used when drawing with the fill
1788% or stroke color or texture. Fully opaque is 1.0.
1789%
1790% The format of the DrawGetOpacity method is:
1791%
1792% double DrawGetOpacity(const DrawingWand *wand)
1793%
1794% A description of each parameter follows:
1795%
1796% o wand: the drawing wand.
1797%
1798*/
1799WandExport double DrawGetOpacity(const DrawingWand *wand)
1800{
1801 double
1802 alpha;
1803
1804 assert(wand != (const DrawingWand *) NULL);
1805 assert(wand->signature == MagickWandSignature);
1806 if (wand->debug != MagickFalse)
1807 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1808 alpha=QuantumScale*(double) CurrentContext->alpha;
1809 return(alpha);
1810}
1811␌
1812/*
1813%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1814% %
1815% %
1816% %
1817% D r a w G e t S t r o k e A n t i a l i a s %
1818% %
1819% %
1820% %
1821%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1822%
1823% DrawGetStrokeAntialias() returns the current stroke antialias setting.
1824% Stroked outlines are antialiased by default. When antialiasing is disabled
1825% stroked pixels are thresholded to determine if the stroke color or
1826% underlying canvas color should be used.
1827%
1828% The format of the DrawGetStrokeAntialias method is:
1829%
1830% MagickBooleanType DrawGetStrokeAntialias(const DrawingWand *wand)
1831%
1832% A description of each parameter follows:
1833%
1834% o wand: the drawing wand.
1835%
1836*/
1837WandExport MagickBooleanType DrawGetStrokeAntialias(const DrawingWand *wand)
1838{
1839 assert(wand != (const DrawingWand *) NULL);
1840 assert(wand->signature == MagickWandSignature);
1841 if (wand->debug != MagickFalse)
1842 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1843 return(CurrentContext->stroke_antialias);
1844}
1845␌
1846/*
1847%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1848% %
1849% %
1850% %
1851% D r a w G e t S t r o k e C o l o r %
1852% %
1853% %
1854% %
1855%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1856%
1857% DrawGetStrokeColor() returns the color used for stroking object outlines.
1858%
1859% The format of the DrawGetStrokeColor method is:
1860%
1861% void DrawGetStrokeColor(const DrawingWand *wand,
1862% PixelWand *stroke_color)
1863%
1864% A description of each parameter follows:
1865%
1866% o wand: the drawing wand.
1867%
1868% o stroke_color: Return the stroke color.
1869%
1870*/
1871WandExport void DrawGetStrokeColor(const DrawingWand *wand,
1872 PixelWand *stroke_color)
1873{
1874 assert(wand != (const DrawingWand *) NULL);
1875 assert(wand->signature == MagickWandSignature);
1876 assert(stroke_color != (PixelWand *) NULL);
1877 if (wand->debug != MagickFalse)
1878 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1879 PixelSetPixelColor(stroke_color,&CurrentContext->stroke);
1880}
1881␌
1882/*
1883%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1884% %
1885% %
1886% %
1887% D r a w G e t S t r o k e D a s h A r r a y %
1888% %
1889% %
1890% %
1891%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1892%
1893% DrawGetStrokeDashArray() returns an array representing the pattern of
1894% dashes and gaps used to stroke paths (see DrawSetStrokeDashArray). The
1895% array must be freed once it is no longer required by the user.
1896%
1897% The format of the DrawGetStrokeDashArray method is:
1898%
1899% double *DrawGetStrokeDashArray(const DrawingWand *wand,
1900% size_t *number_elements)
1901%
1902% A description of each parameter follows:
1903%
1904% o wand: the drawing wand.
1905%
1906% o number_elements: address to place number of elements in dash array
1907%
1908*/
1909WandExport double *DrawGetStrokeDashArray(const DrawingWand *wand,
1910 size_t *number_elements)
1911{
1912 const double
1913 *p;
1914
1915 double
1916 *dasharray,
1917 *q;
1918
1919 size_t
1920 n = 0;
1921
1922 ssize_t
1923 i;
1924
1925 assert(wand != (const DrawingWand *) NULL);
1926 assert(wand->signature == MagickWandSignature);
1927 if (wand->debug != MagickFalse)
1928 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1929 assert(number_elements != (size_t *) NULL);
1930 p=CurrentContext->dash_pattern;
1931 if (p != (const double *) NULL)
1932 while (fabs(*p++) >= MagickEpsilon)
1933 n++;
1934 *number_elements=n;
1935 dasharray=(double *) NULL;
1936 if (n != 0)
1937 {
1938 dasharray=(double *) AcquireQuantumMemory((size_t) n+1UL,
1939 sizeof(*dasharray));
1940 if (dasharray != (double *) NULL)
1941 {
1942 p=CurrentContext->dash_pattern;
1943 q=dasharray;
1944 for (i=0; i < (ssize_t) n; i++)
1945 *q++=(*p++);
1946 *q=0.0;
1947 }
1948 }
1949 return(dasharray);
1950}
1951␌
1952/*
1953%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1954% %
1955% %
1956% %
1957% D r a w G e t S t r o k e D a s h O f f s e t %
1958% %
1959% %
1960% %
1961%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1962%
1963% DrawGetStrokeDashOffset() returns the offset into the dash pattern to
1964% start the dash.
1965%
1966% The format of the DrawGetStrokeDashOffset method is:
1967%
1968% double DrawGetStrokeDashOffset(const DrawingWand *wand)
1969%
1970% A description of each parameter follows:
1971%
1972% o wand: the drawing wand.
1973%
1974*/
1975WandExport double DrawGetStrokeDashOffset(const DrawingWand *wand)
1976{
1977 assert(wand != (const DrawingWand *) NULL);
1978 assert(wand->signature == MagickWandSignature);
1979 if (wand->debug != MagickFalse)
1980 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1981 return(CurrentContext->dash_offset);
1982}
1983␌
1984/*
1985%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1986% %
1987% %
1988% %
1989% D r a w G e t S t r o k e L i n e C a p %
1990% %
1991% %
1992% %
1993%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1994%
1995% DrawGetStrokeLineCap() returns the shape to be used at the end of
1996% open subpaths when they are stroked. Values of LineCap are
1997% UndefinedCap, ButtCap, RoundCap, and SquareCap.
1998%
1999% The format of the DrawGetStrokeLineCap method is:
2000%
2001% LineCap DrawGetStrokeLineCap(const DrawingWand *wand)
2002%
2003% A description of each parameter follows:
2004%
2005% o wand: the drawing wand.
2006%
2007*/
2008WandExport LineCap DrawGetStrokeLineCap(const DrawingWand *wand)
2009{
2010 assert(wand != (const DrawingWand *) NULL);
2011 assert(wand->signature == MagickWandSignature);
2012 if (wand->debug != MagickFalse)
2013 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2014 return(CurrentContext->linecap);
2015}
2016␌
2017/*
2018%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2019% %
2020% %
2021% %
2022% D r a w G e t S t r o k e L i n e J o i n %
2023% %
2024% %
2025% %
2026%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2027%
2028% DrawGetStrokeLineJoin() returns the shape to be used at the
2029% corners of paths (or other vector shapes) when they are
2030% stroked. Values of LineJoin are UndefinedJoin, MiterJoin, RoundJoin,
2031% and BevelJoin.
2032%
2033% The format of the DrawGetStrokeLineJoin method is:
2034%
2035% LineJoin DrawGetStrokeLineJoin(const DrawingWand *wand)
2036%
2037% A description of each parameter follows:
2038%
2039% o wand: the drawing wand.
2040%
2041*/
2042WandExport LineJoin DrawGetStrokeLineJoin(const DrawingWand *wand)
2043{
2044 assert(wand != (const DrawingWand *) NULL);
2045 assert(wand->signature == MagickWandSignature);
2046 if (wand->debug != MagickFalse)
2047 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2048 return(CurrentContext->linejoin);
2049}
2050␌
2051/*
2052%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2053% %
2054% %
2055% %
2056% D r a w G e t S t r o k e M i t e r L i m i t %
2057% %
2058% %
2059% %
2060%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2061%
2062% DrawGetStrokeMiterLimit() returns the miter limit. When two line
2063% segments meet at a sharp angle and miter joins have been specified for
2064% 'lineJoin', it is possible for the miter to extend far beyond the
2065% thickness of the line stroking the path. The miterLimit' imposes a
2066% limit on the ratio of the miter length to the 'lineWidth'.
2067%
2068% The format of the DrawGetStrokeMiterLimit method is:
2069%
2070% size_t DrawGetStrokeMiterLimit(const DrawingWand *wand)
2071%
2072% A description of each parameter follows:
2073%
2074% o wand: the drawing wand.
2075%
2076*/
2077WandExport size_t DrawGetStrokeMiterLimit(const DrawingWand *wand)
2078{
2079 assert(wand != (const DrawingWand *) NULL);
2080 assert(wand->signature == MagickWandSignature);
2081 if (wand->debug != MagickFalse)
2082 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2083 return CurrentContext->miterlimit;
2084}
2085␌
2086/*
2087%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2088% %
2089% %
2090% %
2091% D r a w G e t S t r o k e O p a c i t y %
2092% %
2093% %
2094% %
2095%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2096%
2097% DrawGetStrokeOpacity() returns the alpha of stroked object outlines.
2098%
2099% The format of the DrawGetStrokeOpacity method is:
2100%
2101% double DrawGetStrokeOpacity(const DrawingWand *wand)
2102%
2103% A description of each parameter follows:
2104%
2105% o wand: the drawing wand.
2106%
2107*/
2108WandExport double DrawGetStrokeOpacity(const DrawingWand *wand)
2109{
2110 double
2111 alpha;
2112
2113 assert(wand != (const DrawingWand *) NULL);
2114 assert(wand->signature == MagickWandSignature);
2115 if (wand->debug != MagickFalse)
2116 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2117 alpha=(double) QuantumScale*CurrentContext->stroke.alpha;
2118 return(alpha);
2119}
2120␌
2121/*
2122%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2123% %
2124% %
2125% %
2126% D r a w G e t S t r o k e W i d t h %
2127% %
2128% %
2129% %
2130%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2131%
2132% DrawGetStrokeWidth() returns the width of the stroke used to draw object
2133% outlines.
2134%
2135% The format of the DrawGetStrokeWidth method is:
2136%
2137% double DrawGetStrokeWidth(const DrawingWand *wand)
2138%
2139% A description of each parameter follows:
2140%
2141% o wand: the drawing wand.
2142%
2143*/
2144WandExport double DrawGetStrokeWidth(const DrawingWand *wand)
2145{
2146 assert(wand != (const DrawingWand *) NULL);
2147 assert(wand->signature == MagickWandSignature);
2148 if (wand->debug != MagickFalse)
2149 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2150 return(CurrentContext->stroke_width);
2151}
2152␌
2153/*
2154%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2155% %
2156% %
2157% %
2158% D r a w G e t T e x t A l i g n m e n t %
2159% %
2160% %
2161% %
2162%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2163%
2164% DrawGetTextAlignment() returns the alignment applied when annotating with
2165% text.
2166%
2167% The format of the DrawGetTextAlignment method is:
2168%
2169% AlignType DrawGetTextAlignment(const DrawingWand *wand)
2170%
2171% A description of each parameter follows:
2172%
2173% o wand: the drawing wand.
2174%
2175*/
2176WandExport AlignType DrawGetTextAlignment(const DrawingWand *wand)
2177{
2178 assert(wand != (const DrawingWand *) NULL);
2179 assert(wand->signature == MagickWandSignature);
2180 if (wand->debug != MagickFalse)
2181 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2182 return(CurrentContext->align);
2183}
2184␌
2185/*
2186%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2187% %
2188% %
2189% %
2190% D r a w G e t T e x t A n t i a l i a s %
2191% %
2192% %
2193% %
2194%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2195%
2196% DrawGetTextAntialias() returns the current text antialias setting, which
2197% determines whether text is antialiased. Text is antialiased by default.
2198%
2199% The format of the DrawGetTextAntialias method is:
2200%
2201% MagickBooleanType DrawGetTextAntialias(const DrawingWand *wand)
2202%
2203% A description of each parameter follows:
2204%
2205% o wand: the drawing wand.
2206%
2207*/
2208WandExport MagickBooleanType DrawGetTextAntialias(const DrawingWand *wand)
2209{
2210 assert(wand != (const DrawingWand *) NULL);
2211 assert(wand->signature == MagickWandSignature);
2212 if (wand->debug != MagickFalse)
2213 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2214 return(CurrentContext->text_antialias);
2215}
2216␌
2217/*
2218%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2219% %
2220% %
2221% %
2222% D r a w G e t T e x t D e c o r a t i o n %
2223% %
2224% %
2225% %
2226%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2227%
2228% DrawGetTextDecoration() returns the decoration applied when annotating with
2229% text.
2230%
2231% The format of the DrawGetTextDecoration method is:
2232%
2233% DecorationType DrawGetTextDecoration(const DrawingWand *wand)
2234%
2235% A description of each parameter follows:
2236%
2237% o wand: the drawing wand.
2238%
2239*/
2240WandExport DecorationType DrawGetTextDecoration(const DrawingWand *wand)
2241{
2242 assert(wand != (const DrawingWand *) NULL);
2243 assert(wand->signature == MagickWandSignature);
2244 if (wand->debug != MagickFalse)
2245 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2246 return(CurrentContext->decorate);
2247}
2248␌
2249/*
2250%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2251% %
2252% %
2253% %
2254% D r a w G e t T e x t D i r e c t i o n %
2255% %
2256% %
2257% %
2258%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2259%
2260% DrawGetTextDirection() returns the direction that will be used when
2261% annotating with text.
2262%
2263% The format of the DrawGetTextDirection method is:
2264%
2265% DirectionType DrawGetTextDirection(const DrawingWand *wand)
2266%
2267% A description of each parameter follows:
2268%
2269% o wand: the drawing wand.
2270%
2271*/
2272WandExport DirectionType DrawGetTextDirection(const DrawingWand *wand)
2273{
2274 assert(wand != (const DrawingWand *) NULL);
2275 assert(wand->signature == MagickWandSignature);
2276 if (wand->debug != MagickFalse)
2277 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2278 return(CurrentContext->direction);
2279}
2280␌
2281/*
2282%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2283% %
2284% %
2285% %
2286% D r a w G e t T e x t E n c o d i n g %
2287% %
2288% %
2289% %
2290%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2291%
2292% DrawGetTextEncoding() returns a null-terminated string which specifies the
2293% code set used for text annotations. The string must be freed by the user
2294% once it is no longer required.
2295%
2296% The format of the DrawGetTextEncoding method is:
2297%
2298% char *DrawGetTextEncoding(const DrawingWand *wand)
2299%
2300% A description of each parameter follows:
2301%
2302% o wand: the drawing wand.
2303%
2304*/
2305WandExport char *DrawGetTextEncoding(const DrawingWand *wand)
2306{
2307 assert(wand != (const DrawingWand *) NULL);
2308 assert(wand->signature == MagickWandSignature);
2309 if (wand->debug != MagickFalse)
2310 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2311 if (CurrentContext->encoding != (char *) NULL)
2312 return((char *) AcquireString(CurrentContext->encoding));
2313 return((char *) NULL);
2314}
2315␌
2316/*
2317%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2318% %
2319% %
2320% %
2321% D r a w G e t T e x t K e r n i n g %
2322% %
2323% %
2324% %
2325%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2326%
2327% DrawGetTextKerning() gets the spacing between characters in text.
2328%
2329% The format of the DrawSetFontKerning method is:
2330%
2331% double DrawGetTextKerning(DrawingWand *wand)
2332%
2333% A description of each parameter follows:
2334%
2335% o wand: the drawing wand.
2336%
2337*/
2338WandExport double DrawGetTextKerning(DrawingWand *wand)
2339{
2340 assert(wand != (DrawingWand *) NULL);
2341 assert(wand->signature == MagickWandSignature);
2342
2343 if (wand->debug != MagickFalse)
2344 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2345 return(CurrentContext->kerning);
2346}
2347␌
2348/*
2349%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2350% %
2351% %
2352% %
2353% D r a w G e t T e x t I n t e r l i n e S p a c i n g %
2354% %
2355% %
2356% %
2357%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2358%
2359% DrawGetTextInterlineSpacing() gets the spacing between lines in text.
2360%
2361% The format of the DrawGetTextInterlineSpacing method is:
2362%
2363% double DrawGetTextInterlineSpacing(DrawingWand *wand)
2364%
2365% A description of each parameter follows:
2366%
2367% o wand: the drawing wand.
2368%
2369*/
2370WandExport double DrawGetTextInterlineSpacing(DrawingWand *wand)
2371{
2372 assert(wand != (DrawingWand *) NULL);
2373 assert(wand->signature == MagickWandSignature);
2374 if (wand->debug != MagickFalse)
2375 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2376 return(CurrentContext->interline_spacing);
2377}
2378␌
2379/*
2380%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2381% %
2382% %
2383% %
2384% D r a w G e t T e x t I n t e r w o r d S p a c i n g %
2385% %
2386% %
2387% %
2388%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2389%
2390% DrawGetTextInterwordSpacing() gets the spacing between words in text.
2391%
2392% The format of the DrawSetFontKerning method is:
2393%
2394% double DrawGetTextInterwordSpacing(DrawingWand *wand)
2395%
2396% A description of each parameter follows:
2397%
2398% o wand: the drawing wand.
2399%
2400*/
2401WandExport double DrawGetTextInterwordSpacing(DrawingWand *wand)
2402{
2403 assert(wand != (DrawingWand *) NULL);
2404 assert(wand->signature == MagickWandSignature);
2405 if (wand->debug != MagickFalse)
2406 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2407 return(CurrentContext->interword_spacing);
2408}
2409␌
2410/*
2411%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2412% %
2413% %
2414% %
2415% D r a w G e t T y p e M e t r i c s %
2416% %
2417% %
2418% %
2419%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2420%
2421% DrawGetTypeMetrics() returns the following information for the specified
2422% font and text:
2423%
2424% character width
2425% character height
2426% ascender
2427% descender
2428% text width
2429% text height
2430% maximum horizontal advance
2431% bounds: x1
2432% bounds: y1
2433% bounds: x2
2434% bounds: y2
2435% origin: x
2436% origin: y
2437% underline position
2438% underline thickness
2439%
2440% The format of the DrawGetTypeMetrics method is:
2441%
2442% MagickBooleanType DrawGetTypeMetrics(const DrawingWand *wand,
2443% const char *text,MagickBooleanType ignore_newlines,
2444$ TypeMetric *metrics)
2445%
2446% A description of each parameter follows:
2447%
2448% o wand: the drawing wand.
2449%
2450% o text: text to draw.
2451%
2452% o metrics: Return the font metrics in this structure.
2453%
2454% o ignore_newlines: indicates whether newlines should be ignored.
2455%
2456% o metrics: Return the font metrics in this structure.
2457%
2458*/
2459WandExport MagickBooleanType DrawGetTypeMetrics(const DrawingWand *wand,
2460 const char *text,MagickBooleanType ignore_newlines,TypeMetric *metrics)
2461{
2462 DrawInfo
2463 *draw_info;
2464
2465 MagickBooleanType
2466 status;
2467
2468 assert(wand != (const DrawingWand *) NULL);
2469 assert(wand->signature == MagickWandSignature);
2470 if (wand->debug != MagickFalse)
2471 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2472 draw_info=PeekDrawingWand(wand);
2473 if (draw_info == (DrawInfo *) NULL)
2474 return(MagickFalse);
2475 (void) CloneString(&draw_info->text,text);
2476 if (ignore_newlines != MagickFalse)
2477 status=GetTypeMetrics(wand->image,draw_info,metrics,wand->exception);
2478 else
2479 status=GetMultilineTypeMetrics(wand->image,draw_info,metrics,
2480 wand->exception);
2481 draw_info=DestroyDrawInfo(draw_info);
2482 return(status);
2483}
2484␌
2485/*
2486%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2487% %
2488% %
2489% %
2490% D r a w G e t V e c t o r G r a p h i c s %
2491% %
2492% %
2493% %
2494%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2495%
2496% DrawGetVectorGraphics() returns a null-terminated string which specifies the
2497% vector graphics generated by any graphics calls made since the wand was
2498% instantiated. The string must be freed by the user once it is no longer
2499% required.
2500%
2501% The format of the DrawGetVectorGraphics method is:
2502%
2503% char *DrawGetVectorGraphics(DrawingWand *wand)
2504%
2505% A description of each parameter follows:
2506%
2507% o wand: the drawing wand.
2508%
2509*/
2510WandExport char *DrawGetVectorGraphics(DrawingWand *wand)
2511{
2512 char
2513 value[MagickPathExtent],
2514 *xml;
2515
2516 PixelInfo
2517 pixel;
2518
2519 ssize_t
2520 i;
2521
2522 XMLTreeInfo
2523 *child,
2524 *xml_info;
2525
2526 assert(wand != (const DrawingWand *) NULL);
2527 assert(wand->signature == MagickWandSignature);
2528 if (wand->debug != MagickFalse)
2529 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2530 xml_info=NewXMLTreeTag("drawing-wand");
2531 if (xml_info == (XMLTreeInfo *) NULL)
2532 return((char *) NULL);
2533 (void) SetXMLTreeContent(xml_info," ");
2534 GetPixelInfo(wand->image,&pixel);
2535 child=AddChildToXMLTree(xml_info,"clip-path",0);
2536 if (child != (XMLTreeInfo *) NULL)
2537 (void) SetXMLTreeContent(child,CurrentContext->clip_mask);
2538 child=AddChildToXMLTree(xml_info,"clip-units",0);
2539 if (child != (XMLTreeInfo *) NULL)
2540 {
2541 (void) CopyMagickString(value,CommandOptionToMnemonic(
2542 MagickClipPathOptions,(ssize_t) CurrentContext->clip_units),
2543 MagickPathExtent);
2544 (void) SetXMLTreeContent(child,value);
2545 }
2546 child=AddChildToXMLTree(xml_info,"decorate",0);
2547 if (child != (XMLTreeInfo *) NULL)
2548 {
2549 (void) CopyMagickString(value,CommandOptionToMnemonic(
2550 MagickDecorateOptions,(ssize_t) CurrentContext->decorate),
2551 MagickPathExtent);
2552 (void) SetXMLTreeContent(child,value);
2553 }
2554 child=AddChildToXMLTree(xml_info,"encoding",0);
2555 if (child != (XMLTreeInfo *) NULL)
2556 (void) SetXMLTreeContent(child,CurrentContext->encoding);
2557 child=AddChildToXMLTree(xml_info,"fill",0);
2558 if (child != (XMLTreeInfo *) NULL)
2559 {
2560 if (CurrentContext->fill.alpha != (double) OpaqueAlpha)
2561 pixel.alpha_trait=CurrentContext->fill.alpha != (double) OpaqueAlpha ?
2562 BlendPixelTrait : UndefinedPixelTrait;
2563 pixel=CurrentContext->fill;
2564 GetColorTuple(&pixel,MagickTrue,value);
2565 (void) SetXMLTreeContent(child,value);
2566 }
2567 child=AddChildToXMLTree(xml_info,"fill-opacity",0);
2568 if (child != (XMLTreeInfo *) NULL)
2569 {
2570 (void) FormatLocaleString(value,MagickPathExtent,"%.17g",
2571 (double) (QuantumScale*CurrentContext->fill.alpha));
2572 (void) SetXMLTreeContent(child,value);
2573 }
2574 child=AddChildToXMLTree(xml_info,"fill-rule",0);
2575 if (child != (XMLTreeInfo *) NULL)
2576 {
2577 (void) CopyMagickString(value,CommandOptionToMnemonic(
2578 MagickFillRuleOptions,(ssize_t) CurrentContext->fill_rule),
2579 MagickPathExtent);
2580 (void) SetXMLTreeContent(child,value);
2581 }
2582 child=AddChildToXMLTree(xml_info,"font",0);
2583 if (child != (XMLTreeInfo *) NULL)
2584 (void) SetXMLTreeContent(child,CurrentContext->font);
2585 child=AddChildToXMLTree(xml_info,"font-family",0);
2586 if (child != (XMLTreeInfo *) NULL)
2587 (void) SetXMLTreeContent(child,CurrentContext->family);
2588 child=AddChildToXMLTree(xml_info,"font-size",0);
2589 if (child != (XMLTreeInfo *) NULL)
2590 {
2591 (void) FormatLocaleString(value,MagickPathExtent,"%.17g",
2592 CurrentContext->pointsize);
2593 (void) SetXMLTreeContent(child,value);
2594 }
2595 child=AddChildToXMLTree(xml_info,"font-stretch",0);
2596 if (child != (XMLTreeInfo *) NULL)
2597 {
2598 (void) CopyMagickString(value,CommandOptionToMnemonic(
2599 MagickStretchOptions,(ssize_t) CurrentContext->stretch),
2600 MagickPathExtent);
2601 (void) SetXMLTreeContent(child,value);
2602 }
2603 child=AddChildToXMLTree(xml_info,"font-style",0);
2604 if (child != (XMLTreeInfo *) NULL)
2605 {
2606 (void) CopyMagickString(value,CommandOptionToMnemonic(
2607 MagickStyleOptions,(ssize_t) CurrentContext->style),MagickPathExtent);
2608 (void) SetXMLTreeContent(child,value);
2609 }
2610 child=AddChildToXMLTree(xml_info,"font-weight",0);
2611 if (child != (XMLTreeInfo *) NULL)
2612 {
2613 (void) FormatLocaleString(value,MagickPathExtent,"%.17g",(double)
2614 CurrentContext->weight);
2615 (void) SetXMLTreeContent(child,value);
2616 }
2617 child=AddChildToXMLTree(xml_info,"gravity",0);
2618 if (child != (XMLTreeInfo *) NULL)
2619 {
2620 (void) CopyMagickString(value,CommandOptionToMnemonic(
2621 MagickGravityOptions,(ssize_t) CurrentContext->gravity),
2622 MagickPathExtent);
2623 (void) SetXMLTreeContent(child,value);
2624 }
2625 child=AddChildToXMLTree(xml_info,"stroke",0);
2626 if (child != (XMLTreeInfo *) NULL)
2627 {
2628 if (CurrentContext->stroke.alpha != (double) OpaqueAlpha)
2629 pixel.alpha_trait=CurrentContext->stroke.alpha != (double) OpaqueAlpha ?
2630 BlendPixelTrait : UndefinedPixelTrait;
2631 pixel=CurrentContext->stroke;
2632 GetColorTuple(&pixel,MagickTrue,value);
2633 (void) SetXMLTreeContent(child,value);
2634 }
2635 child=AddChildToXMLTree(xml_info,"stroke-antialias",0);
2636 if (child != (XMLTreeInfo *) NULL)
2637 {
2638 (void) FormatLocaleString(value,MagickPathExtent,"%d",
2639 CurrentContext->stroke_antialias != MagickFalse ? 1 : 0);
2640 (void) SetXMLTreeContent(child,value);
2641 }
2642 child=AddChildToXMLTree(xml_info,"stroke-dasharray",0);
2643 if ((child != (XMLTreeInfo *) NULL) &&
2644 (CurrentContext->dash_pattern != (double *) NULL))
2645 {
2646 char
2647 *dash_pattern;
2648
2649 dash_pattern=AcquireString((char *) NULL);
2650 for (i=0; fabs(CurrentContext->dash_pattern[i]) >= MagickEpsilon; i++)
2651 {
2652 if (i != 0)
2653 (void) ConcatenateString(&dash_pattern,",");
2654 (void) FormatLocaleString(value,MagickPathExtent,"%.17g",
2655 CurrentContext->dash_pattern[i]);
2656 (void) ConcatenateString(&dash_pattern,value);
2657 }
2658 (void) SetXMLTreeContent(child,dash_pattern);
2659 dash_pattern=DestroyString(dash_pattern);
2660 }
2661 child=AddChildToXMLTree(xml_info,"stroke-dashoffset",0);
2662 if (child != (XMLTreeInfo *) NULL)
2663 {
2664 (void) FormatLocaleString(value,MagickPathExtent,"%.17g",
2665 CurrentContext->dash_offset);
2666 (void) SetXMLTreeContent(child,value);
2667 }
2668 child=AddChildToXMLTree(xml_info,"stroke-linecap",0);
2669 if (child != (XMLTreeInfo *) NULL)
2670 {
2671 (void) CopyMagickString(value,CommandOptionToMnemonic(
2672 MagickLineCapOptions,(ssize_t) CurrentContext->linecap),
2673 MagickPathExtent);
2674 (void) SetXMLTreeContent(child,value);
2675 }
2676 child=AddChildToXMLTree(xml_info,"stroke-linejoin",0);
2677 if (child != (XMLTreeInfo *) NULL)
2678 {
2679 (void) CopyMagickString(value,CommandOptionToMnemonic(
2680 MagickLineJoinOptions,(ssize_t) CurrentContext->linejoin),
2681 MagickPathExtent);
2682 (void) SetXMLTreeContent(child,value);
2683 }
2684 child=AddChildToXMLTree(xml_info,"stroke-miterlimit",0);
2685 if (child != (XMLTreeInfo *) NULL)
2686 {
2687 (void) FormatLocaleString(value,MagickPathExtent,"%.17g",(double)
2688 CurrentContext->miterlimit);
2689 (void) SetXMLTreeContent(child,value);
2690 }
2691 child=AddChildToXMLTree(xml_info,"stroke-opacity",0);
2692 if (child != (XMLTreeInfo *) NULL)
2693 {
2694 (void) FormatLocaleString(value,MagickPathExtent,"%.17g",
2695 (double) (QuantumScale*CurrentContext->stroke.alpha));
2696 (void) SetXMLTreeContent(child,value);
2697 }
2698 child=AddChildToXMLTree(xml_info,"stroke-width",0);
2699 if (child != (XMLTreeInfo *) NULL)
2700 {
2701 (void) FormatLocaleString(value,MagickPathExtent,"%.17g",
2702 CurrentContext->stroke_width);
2703 (void) SetXMLTreeContent(child,value);
2704 }
2705 child=AddChildToXMLTree(xml_info,"text-align",0);
2706 if (child != (XMLTreeInfo *) NULL)
2707 {
2708 (void) CopyMagickString(value,CommandOptionToMnemonic(MagickAlignOptions,
2709 (ssize_t) CurrentContext->align),MagickPathExtent);
2710 (void) SetXMLTreeContent(child,value);
2711 }
2712 child=AddChildToXMLTree(xml_info,"text-antialias",0);
2713 if (child != (XMLTreeInfo *) NULL)
2714 {
2715 (void) FormatLocaleString(value,MagickPathExtent,"%d",
2716 CurrentContext->text_antialias != MagickFalse ? 1 : 0);
2717 (void) SetXMLTreeContent(child,value);
2718 }
2719 child=AddChildToXMLTree(xml_info,"text-undercolor",0);
2720 if (child != (XMLTreeInfo *) NULL)
2721 {
2722 if (CurrentContext->undercolor.alpha != (double) OpaqueAlpha)
2723 pixel.alpha_trait=CurrentContext->undercolor.alpha != (double) OpaqueAlpha ?
2724 BlendPixelTrait : UndefinedPixelTrait;
2725 pixel=CurrentContext->undercolor;
2726 GetColorTuple(&pixel,MagickTrue,value);
2727 (void) SetXMLTreeContent(child,value);
2728 }
2729 child=AddChildToXMLTree(xml_info,"vector-graphics",0);
2730 if (child != (XMLTreeInfo *) NULL)
2731 (void) SetXMLTreeContent(child,wand->mvg);
2732 xml=XMLTreeInfoToXML(xml_info);
2733 xml_info=DestroyXMLTree(xml_info);
2734 return(xml);
2735}
2736␌
2737/*
2738%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2739% %
2740% %
2741% %
2742% D r a w G e t T e x t U n d e r C o l o r %
2743% %
2744% %
2745% %
2746%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2747%
2748% DrawGetTextUnderColor() returns the color of a background rectangle
2749% to place under text annotations.
2750%
2751% The format of the DrawGetTextUnderColor method is:
2752%
2753% void DrawGetTextUnderColor(const DrawingWand *wand,
2754% PixelWand *under_color)
2755%
2756% A description of each parameter follows:
2757%
2758% o wand: the drawing wand.
2759%
2760% o under_color: Return the under color.
2761%
2762*/
2763WandExport void DrawGetTextUnderColor(const DrawingWand *wand,
2764 PixelWand *under_color)
2765{
2766 assert(wand != (const DrawingWand *) NULL);
2767 assert(wand->signature == MagickWandSignature);
2768 assert(under_color != (PixelWand *) NULL);
2769 if (wand->debug != MagickFalse)
2770 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2771 PixelSetPixelColor(under_color,&CurrentContext->undercolor);
2772}
2773␌
2774/*
2775%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2776% %
2777% %
2778% %
2779% D r a w L i n e %
2780% %
2781% %
2782% %
2783%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2784%
2785% DrawLine() draws a line on the image using the current stroke color,
2786% stroke alpha, and stroke width.
2787%
2788% The format of the DrawLine method is:
2789%
2790% void DrawLine(DrawingWand *wand,const double sx,const double sy,
2791% const double ex,const double ey)
2792%
2793% A description of each parameter follows:
2794%
2795% o wand: the drawing wand.
2796%
2797% o sx: starting x ordinate
2798%
2799% o sy: starting y ordinate
2800%
2801% o ex: ending x ordinate
2802%
2803% o ey: ending y ordinate
2804%
2805*/
2806WandExport void DrawLine(DrawingWand *wand,const double sx,const double sy,
2807 const double ex,const double ey)
2808{
2809 assert(wand != (DrawingWand *) NULL);
2810 assert(wand->signature == MagickWandSignature);
2811 if (wand->debug != MagickFalse)
2812 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2813 (void) MVGPrintf(wand,"line %.17g %.17g %.17g %.17g\n",sx,sy,ex,ey);
2814}
2815␌
2816/*
2817%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2818% %
2819% %
2820% %
2821% D r a w P a t h C l o s e %
2822% %
2823% %
2824% %
2825%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2826%
2827% DrawPathClose() adds a path element to the current path which closes the
2828% current subpath by drawing a straight line from the current point to the
2829% current subpath's most recent starting point (usually, the most recent
2830% moveto point).
2831%
2832% The format of the DrawPathClose method is:
2833%
2834% void DrawPathClose(DrawingWand *wand)
2835%
2836% A description of each parameter follows:
2837%
2838% o wand: the drawing wand.
2839%
2840*/
2841WandExport void DrawPathClose(DrawingWand *wand)
2842{
2843 assert(wand != (DrawingWand *) NULL);
2844 assert(wand->signature == MagickWandSignature);
2845 if (wand->debug != MagickFalse)
2846 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2847 (void) MVGAutoWrapPrintf(wand,"%s",wand->path_mode == AbsolutePathMode ?
2848 "Z" : "z");
2849}
2850␌
2851/*
2852%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2853% %
2854% %
2855% %
2856% D r a w P a t h C u r v e T o A b s o l u t e %
2857% %
2858% %
2859% %
2860%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2861%
2862% DrawPathCurveToAbsolute() draws a cubic Bezier curve from the current
2863% point to (x,y) using (x1,y1) as the control point at the beginning of
2864% the curve and (x2,y2) as the control point at the end of the curve using
2865% absolute coordinates. At the end of the command, the new current point
2866% becomes the final (x,y) coordinate pair used in the polybezier.
2867%
2868% The format of the DrawPathCurveToAbsolute method is:
2869%
2870% void DrawPathCurveToAbsolute(DrawingWand *wand,const double x1,
2871% const double y1,const double x2,const double y2,const double x,
2872% const double y)
2873%
2874% A description of each parameter follows:
2875%
2876% o wand: the drawing wand.
2877%
2878% o x1: x ordinate of control point for curve beginning
2879%
2880% o y1: y ordinate of control point for curve beginning
2881%
2882% o x2: x ordinate of control point for curve ending
2883%
2884% o y2: y ordinate of control point for curve ending
2885%
2886% o x: x ordinate of the end of the curve
2887%
2888% o y: y ordinate of the end of the curve
2889%
2890*/
2891
2892static void DrawPathCurveTo(DrawingWand *wand,const PathMode mode,
2893 const double x1,const double y1,const double x2,const double y2,
2894 const double x,const double y)
2895{
2896 assert(wand != (DrawingWand *) NULL);
2897 assert(wand->signature == MagickWandSignature);
2898 if (wand->debug != MagickFalse)
2899 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2900 if ((wand->path_operation != PathCurveToOperation) ||
2901 (wand->path_mode != mode))
2902 {
2903 wand->path_operation=PathCurveToOperation;
2904 wand->path_mode=mode;
2905 (void) MVGAutoWrapPrintf(wand, "%c%.17g %.17g %.17g %.17g %.17g %.17g",
2906 mode == AbsolutePathMode ? 'C' : 'c',x1,y1,x2,y2,x,y);
2907 }
2908 else
2909 (void) MVGAutoWrapPrintf(wand," %.17g %.17g %.17g %.17g %.17g %.17g",x1,y1,
2910 x2,y2,x,y);
2911}
2912
2913WandExport void DrawPathCurveToAbsolute(DrawingWand *wand,const double x1,
2914 const double y1,const double x2,const double y2,const double x,const double y)
2915{
2916 assert(wand != (DrawingWand *) NULL);
2917 assert(wand->signature == MagickWandSignature);
2918 if (wand->debug != MagickFalse)
2919 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2920 DrawPathCurveTo(wand,AbsolutePathMode,x1,y1,x2,y2,x,y);
2921}
2922␌
2923/*
2924%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2925% %
2926% %
2927% %
2928% D r a w P a t h C u r v e T o R e l a t i v e %
2929% %
2930% %
2931% %
2932%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2933%
2934% DrawPathCurveToRelative() draws a cubic Bezier curve from the current
2935% point to (x,y) using (x1,y1) as the control point at the beginning of
2936% the curve and (x2,y2) as the control point at the end of the curve using
2937% relative coordinates. At the end of the command, the new current point
2938% becomes the final (x,y) coordinate pair used in the polybezier.
2939%
2940% The format of the DrawPathCurveToRelative method is:
2941%
2942% void DrawPathCurveToRelative(DrawingWand *wand,const double x1,
2943% const double y1,const double x2,const double y2,const double x,
2944% const double y)
2945%
2946% A description of each parameter follows:
2947%
2948% o wand: the drawing wand.
2949%
2950% o x1: x ordinate of control point for curve beginning
2951%
2952% o y1: y ordinate of control point for curve beginning
2953%
2954% o x2: x ordinate of control point for curve ending
2955%
2956% o y2: y ordinate of control point for curve ending
2957%
2958% o x: x ordinate of the end of the curve
2959%
2960% o y: y ordinate of the end of the curve
2961%
2962*/
2963WandExport void DrawPathCurveToRelative(DrawingWand *wand,const double x1,
2964 const double y1,const double x2,const double y2,const double x,const double y)
2965{
2966 assert(wand != (DrawingWand *) NULL);
2967 assert(wand->signature == MagickWandSignature);
2968 if (wand->debug != MagickFalse)
2969 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2970 DrawPathCurveTo(wand,RelativePathMode,x1,y1,x2,y2,x,y);
2971}
2972␌
2973/*
2974%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2975% %
2976% %
2977% %
2978% D r a w P a t h C u r v e T o Q u a d r a t i c B e z i e r A b s o l u t e %
2979% %
2980% %
2981% %
2982%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2983%
2984% DrawPathCurveToQuadraticBezierAbsolute() draws a quadratic Bezier curve
2985% from the current point to (x,y) using (x1,y1) as the control point using
2986% absolute coordinates. At the end of the command, the new current point
2987% becomes the final (x,y) coordinate pair used in the polybezier.
2988%
2989% The format of the DrawPathCurveToQuadraticBezierAbsolute method is:
2990%
2991% void DrawPathCurveToQuadraticBezierAbsolute(DrawingWand *wand,
2992% const double x1,const double y1,const double x,const double y)
2993%
2994% A description of each parameter follows:
2995%
2996% o wand: the drawing wand.
2997%
2998% o x1: x ordinate of the control point
2999%
3000% o y1: y ordinate of the control point
3001%
3002% o x: x ordinate of final point
3003%
3004% o y: y ordinate of final point
3005%
3006*/
3007
3008static void DrawPathCurveToQuadraticBezier(DrawingWand *wand,
3009 const PathMode mode,const double x1,double y1,const double x,const double y)
3010{
3011 assert(wand != (DrawingWand *) NULL);
3012 assert(wand->signature == MagickWandSignature);
3013 if (wand->debug != MagickFalse)
3014 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3015 if ((wand->path_operation != PathCurveToQuadraticBezierOperation) ||
3016 (wand->path_mode != mode))
3017 {
3018 wand->path_operation=PathCurveToQuadraticBezierOperation;
3019 wand->path_mode=mode;
3020 (void) MVGAutoWrapPrintf(wand, "%c%.17g %.17g %.17g %.17g",
3021 mode == AbsolutePathMode ? 'Q' : 'q',x1,y1,x,y);
3022 }
3023 else
3024 (void) MVGAutoWrapPrintf(wand," %.17g %.17g %.17g %.17g",x1,y1,x,y);
3025}
3026
3027WandExport void DrawPathCurveToQuadraticBezierAbsolute(DrawingWand *wand,
3028 const double x1,const double y1,const double x,const double y)
3029{
3030 assert(wand != (DrawingWand *) NULL);
3031 assert(wand->signature == MagickWandSignature);
3032 if (wand->debug != MagickFalse)
3033 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3034 DrawPathCurveToQuadraticBezier(wand,AbsolutePathMode,x1,y1,x,y);
3035}
3036␌
3037/*
3038%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3039% %
3040% %
3041% %
3042% D r a w P a t h C u r v e T o Q u a d r a t i c B e z i e r R e l a t i v e %
3043% %
3044% %
3045% %
3046%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3047%
3048% DrawPathCurveToQuadraticBezierRelative() draws a quadratic Bezier curve
3049% from the current point to (x,y) using (x1,y1) as the control point using
3050% relative coordinates. At the end of the command, the new current point
3051% becomes the final (x,y) coordinate pair used in the polybezier.
3052%
3053% The format of the DrawPathCurveToQuadraticBezierRelative method is:
3054%
3055% void DrawPathCurveToQuadraticBezierRelative(DrawingWand *wand,
3056% const double x1,const double y1,const double x,const double y)
3057%
3058% A description of each parameter follows:
3059%
3060% o wand: the drawing wand.
3061%
3062% o x1: x ordinate of the control point
3063%
3064% o y1: y ordinate of the control point
3065%
3066% o x: x ordinate of final point
3067%
3068% o y: y ordinate of final point
3069%
3070*/
3071WandExport void DrawPathCurveToQuadraticBezierRelative(DrawingWand *wand,
3072 const double x1,const double y1,const double x,const double y)
3073{
3074 assert(wand != (DrawingWand *) NULL);
3075 assert(wand->signature == MagickWandSignature);
3076 if (wand->debug != MagickFalse)
3077 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3078 DrawPathCurveToQuadraticBezier(wand,RelativePathMode,x1,y1,x,y);
3079}
3080␌
3081/*
3082%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3083% %
3084% %
3085% %
3086% D r a w P a t h C u r v e T o Q u a d r a t i c B e z i e r S m o o t h %
3087% %
3088% %
3089% %
3090%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3091%
3092% DrawPathCurveToQuadraticBezierSmoothAbsolute() draws a quadratic
3093% Bezier curve (using absolute coordinates) from the current point to
3094% (x,y). The control point is assumed to be the reflection of the
3095% control point on the previous command relative to the current
3096% point. (If there is no previous command or if the previous command was
3097% not a DrawPathCurveToQuadraticBezierAbsolute,
3098% DrawPathCurveToQuadraticBezierRelative,
3099% DrawPathCurveToQuadraticBezierSmoothAbsolute or
3100% DrawPathCurveToQuadraticBezierSmoothRelative, assume the control point
3101% is coincident with the current point.). At the end of the command, the
3102% new current point becomes the final (x,y) coordinate pair used in the
3103% polybezier.
3104%
3105% The format of the DrawPathCurveToQuadraticBezierSmoothAbsolute method is:
3106%
3107% void DrawPathCurveToQuadraticBezierSmoothAbsolute(
3108% DrawingWand *wand,const double x,const double y)
3109%
3110% A description of each parameter follows:
3111%
3112% o wand: the drawing wand.
3113%
3114% o x: x ordinate of final point
3115%
3116% o y: y ordinate of final point
3117%
3118*/
3119
3120static void DrawPathCurveToQuadraticBezierSmooth(DrawingWand *wand,
3121 const PathMode mode,const double x,const double y)
3122{
3123 assert(wand != (DrawingWand *) NULL);
3124 assert(wand->signature == MagickWandSignature);
3125 if (wand->debug != MagickFalse)
3126 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3127 if ((wand->path_operation != PathCurveToQuadraticBezierSmoothOperation) ||
3128 (wand->path_mode != mode))
3129 {
3130 wand->path_operation=PathCurveToQuadraticBezierSmoothOperation;
3131 wand->path_mode=mode;
3132 (void) MVGAutoWrapPrintf(wand,"%c%.17g %.17g",mode == AbsolutePathMode ?
3133 'T' : 't',x,y);
3134 }
3135 else
3136 (void) MVGAutoWrapPrintf(wand," %.17g %.17g",x,y);
3137}
3138
3139WandExport void DrawPathCurveToQuadraticBezierSmoothAbsolute(DrawingWand *wand,
3140 const double x,const double y)
3141{
3142 assert(wand != (DrawingWand *) NULL);
3143 assert(wand->signature == MagickWandSignature);
3144 if (wand->debug != MagickFalse)
3145 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3146 DrawPathCurveToQuadraticBezierSmooth(wand,AbsolutePathMode,x,y);
3147}
3148␌
3149/*
3150%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3151% %
3152% %
3153% %
3154% D r a w P a t h C u r v e T o Q u a d r a t i c B e z i e r S m o o t h %
3155% %
3156% %
3157% %
3158%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3159%
3160% DrawPathCurveToQuadraticBezierSmoothRelative() draws a quadratic Bezier
3161% curve (using relative coordinates) from the current point to (x,y). The
3162% control point is assumed to be the reflection of the control point on the
3163% previous command relative to the current point. (If there is no previous
3164% command or if the previous command was not a
3165% DrawPathCurveToQuadraticBezierAbsolute,
3166% DrawPathCurveToQuadraticBezierRelative,
3167% DrawPathCurveToQuadraticBezierSmoothAbsolute or
3168% DrawPathCurveToQuadraticBezierSmoothRelative, assume the control point is
3169% coincident with the current point.). At the end of the command, the new
3170% current point becomes the final (x,y) coordinate pair used in the polybezier.
3171%
3172% The format of the DrawPathCurveToQuadraticBezierSmoothRelative method is:
3173%
3174% void DrawPathCurveToQuadraticBezierSmoothRelative(DrawingWand *wand,
3175% const double x,const double y)
3176%
3177% A description of each parameter follows:
3178%
3179% o wand: the drawing wand.
3180%
3181% o x: x ordinate of final point
3182%
3183% o y: y ordinate of final point
3184%
3185*/
3186WandExport void DrawPathCurveToQuadraticBezierSmoothRelative(DrawingWand *wand,
3187 const double x,const double y)
3188{
3189 DrawPathCurveToQuadraticBezierSmooth(wand,RelativePathMode,x,y);
3190}
3191␌
3192/*
3193%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3194% %
3195% %
3196% %
3197% D r a w P a t h C u r v e T o S m o o t h A b s o l u t e %
3198% %
3199% %
3200% %
3201%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3202%
3203% DrawPathCurveToSmoothAbsolute() draws a cubic Bezier curve from the
3204% current point to (x,y) using absolute coordinates. The first control
3205% point is assumed to be the reflection of the second control point on
3206% the previous command relative to the current point. (If there is no
3207% previous command or if the previous command was not an
3208% DrawPathCurveToAbsolute, DrawPathCurveToRelative,
3209% DrawPathCurveToSmoothAbsolute or DrawPathCurveToSmoothRelative, assume
3210% the first control point is coincident with the current point.) (x2,y2)
3211% is the second control point (i.e., the control point at the end of the
3212% curve). At the end of the command, the new current point becomes the
3213% final (x,y) coordinate pair used in the polybezier.
3214%
3215% The format of the DrawPathCurveToSmoothAbsolute method is:
3216%
3217% void DrawPathCurveToSmoothAbsolute(DrawingWand *wand,
3218% const double x2,const double y2,const double x,const double y)
3219%
3220% A description of each parameter follows:
3221%
3222% o wand: the drawing wand.
3223%
3224% o x2: x ordinate of second control point
3225%
3226% o y2: y ordinate of second control point
3227%
3228% o x: x ordinate of termination point
3229%
3230% o y: y ordinate of termination point
3231%
3232*/
3233
3234static void DrawPathCurveToSmooth(DrawingWand *wand,const PathMode mode,
3235 const double x2,const double y2,const double x,const double y)
3236{
3237 assert(wand != (DrawingWand *) NULL);
3238 assert(wand->signature == MagickWandSignature);
3239 if (wand->debug != MagickFalse)
3240 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3241 if ((wand->path_operation != PathCurveToSmoothOperation) ||
3242 (wand->path_mode != mode))
3243 {
3244 wand->path_operation=PathCurveToSmoothOperation;
3245 wand->path_mode=mode;
3246 (void) MVGAutoWrapPrintf(wand,"%c%.17g %.17g %.17g %.17g",
3247 mode == AbsolutePathMode ? 'S' : 's',x2,y2,x,y);
3248 }
3249 else
3250 (void) MVGAutoWrapPrintf(wand," %.17g %.17g %.17g %.17g",x2,y2,x,y);
3251}
3252
3253WandExport void DrawPathCurveToSmoothAbsolute(DrawingWand *wand,const double x2,
3254 const double y2,const double x,const double y)
3255{
3256 assert(wand != (DrawingWand *) NULL);
3257 assert(wand->signature == MagickWandSignature);
3258 if (wand->debug != MagickFalse)
3259 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3260 DrawPathCurveToSmooth(wand,AbsolutePathMode,x2,y2,x,y);
3261}
3262␌
3263/*
3264%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3265% %
3266% %
3267% %
3268% D r a w P a t h C u r v e T o S m o o t h R e l a t i v e %
3269% %
3270% %
3271% %
3272%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3273%
3274% DrawPathCurveToSmoothRelative() draws a cubic Bezier curve from the current
3275% point to (x,y) using relative coordinates. The first control point is
3276% assumed to be the reflection of the second control point on the previous
3277% command relative to the current point. (If there is no previous command or
3278% if the previous command was not an DrawPathCurveToAbsolute,
3279% DrawPathCurveToRelative, DrawPathCurveToSmoothAbsolute or
3280% DrawPathCurveToSmoothRelative, assume the first control point is coincident
3281% with the current point.) (x2,y2) is the second control point (i.e., the
3282% control point at the end of the curve). At the end of the command, the new
3283% current point becomes the final (x,y) coordinate pair used in the polybezier.
3284%
3285% The format of the DrawPathCurveToSmoothRelative method is:
3286%
3287% void DrawPathCurveToSmoothRelative(DrawingWand *wand,
3288% const double x2,const double y2,const double x,const double y)
3289%
3290% A description of each parameter follows:
3291%
3292% o wand: the drawing wand.
3293%
3294% o x2: x ordinate of second control point
3295%
3296% o y2: y ordinate of second control point
3297%
3298% o x: x ordinate of termination point
3299%
3300% o y: y ordinate of termination point
3301%
3302*/
3303WandExport void DrawPathCurveToSmoothRelative(DrawingWand *wand,const double x2,
3304 const double y2,const double x,const double y)
3305{
3306 assert(wand != (DrawingWand *) NULL);
3307 assert(wand->signature == MagickWandSignature);
3308 if (wand->debug != MagickFalse)
3309 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3310 DrawPathCurveToSmooth(wand,RelativePathMode,x2,y2,x,y);
3311}
3312␌
3313/*
3314%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3315% %
3316% %
3317% %
3318% D r a w P a t h E l l i p t i c A r c A b s o l u t e %
3319% %
3320% %
3321% %
3322%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3323%
3324% DrawPathEllipticArcAbsolute() draws an elliptical arc from the current point
3325% to (x, y) using absolute coordinates. The size and orientation of the
3326% ellipse are defined by two radii (rx, ry) and an xAxisRotation, which
3327% indicates how the ellipse as a whole is rotated relative to the current
3328% coordinate system. The center (cx, cy) of the ellipse is calculated
3329% automagically to satisfy the constraints imposed by the other parameters.
3330% largeArcFlag and sweepFlag contribute to the automatic calculations and help
3331% determine how the arc is drawn. If largeArcFlag is true then draw the larger
3332% of the available arcs. If sweepFlag is true, then draw the arc matching a
3333% clock-wise rotation.
3334%
3335% The format of the DrawPathEllipticArcAbsolute method is:
3336%
3337% void DrawPathEllipticArcAbsolute(DrawingWand *wand,
3338% const double rx,const double ry,const double x_axis_rotation,
3339% const MagickBooleanType large_arc_flag,
3340% const MagickBooleanType sweep_flag,const double x,const double y)
3341%
3342% A description of each parameter follows:
3343%
3344% o wand: the drawing wand.
3345%
3346% o rx: x radius
3347%
3348% o ry: y radius
3349%
3350% o x_axis_rotation: indicates how the ellipse as a whole is rotated
3351% relative to the current coordinate system
3352%
3353% o large_arc_flag: If non-zero (true) then draw the larger of the
3354% available arcs
3355%
3356% o sweep_flag: If non-zero (true) then draw the arc matching a
3357% clock-wise rotation
3358%
3359%
3360*/
3361
3362static void DrawPathEllipticArc(DrawingWand *wand, const PathMode mode,
3363 const double rx,const double ry,const double x_axis_rotation,
3364 const MagickBooleanType large_arc_flag,const MagickBooleanType sweep_flag,
3365 const double x,const double y)
3366{
3367 assert(wand != (DrawingWand *) NULL);
3368 assert(wand->signature == MagickWandSignature);
3369 if (wand->debug != MagickFalse)
3370 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3371 if ((wand->path_operation != PathEllipticArcOperation) ||
3372 (wand->path_mode != mode))
3373 {
3374 wand->path_operation=PathEllipticArcOperation;
3375 wand->path_mode=mode;
3376 (void) MVGAutoWrapPrintf(wand, "%c%.17g %.17g %.17g %u %u %.17g %.17g",
3377 mode == AbsolutePathMode ? 'A' : 'a',rx,ry,x_axis_rotation,
3378 large_arc_flag,sweep_flag,x,y);
3379 }
3380 else
3381 (void) MVGAutoWrapPrintf(wand," %.17g %.17g %.17g %u %u %.17g %.17g",rx,ry,
3382 x_axis_rotation,large_arc_flag,sweep_flag,x,y);
3383}
3384
3385WandExport void DrawPathEllipticArcAbsolute(DrawingWand *wand,const double rx,
3386 const double ry,const double x_axis_rotation,
3387 const MagickBooleanType large_arc_flag,const MagickBooleanType sweep_flag,
3388 const double x,const double y)
3389{
3390 assert(wand != (DrawingWand *) NULL);
3391 assert(wand->signature == MagickWandSignature);
3392 if (wand->debug != MagickFalse)
3393 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3394 DrawPathEllipticArc(wand,AbsolutePathMode,rx,ry,x_axis_rotation,
3395 large_arc_flag,sweep_flag,x,y);
3396}
3397␌
3398/*
3399%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3400% %
3401% %
3402% %
3403% D r a w P a t h E l l i p t i c A r c R e l a t i v e %
3404% %
3405% %
3406% %
3407%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3408%
3409% DrawPathEllipticArcRelative() draws an elliptical arc from the current point
3410% to (x, y) using relative coordinates. The size and orientation of the
3411% ellipse are defined by two radii (rx, ry) and an xAxisRotation, which
3412% indicates how the ellipse as a whole is rotated relative to the current
3413% coordinate system. The center (cx, cy) of the ellipse is calculated
3414% automagically to satisfy the constraints imposed by the other parameters.
3415% largeArcFlag and sweepFlag contribute to the automatic calculations and help
3416% determine how the arc is drawn. If largeArcFlag is true then draw the larger
3417% of the available arcs. If sweepFlag is true, then draw the arc matching a
3418% clock-wise rotation.
3419%
3420% The format of the DrawPathEllipticArcRelative method is:
3421%
3422% void DrawPathEllipticArcRelative(DrawingWand *wand,
3423% const double rx,const double ry,const double x_axis_rotation,
3424% const MagickBooleanType large_arc_flag,
3425% const MagickBooleanType sweep_flag,const double x,const double y)
3426%
3427% A description of each parameter follows:
3428%
3429% o wand: the drawing wand.
3430%
3431% o rx: x radius
3432%
3433% o ry: y radius
3434%
3435% o x_axis_rotation: indicates how the ellipse as a whole is rotated
3436% relative to the current coordinate system
3437%
3438% o large_arc_flag: If non-zero (true) then draw the larger of the
3439% available arcs
3440%
3441% o sweep_flag: If non-zero (true) then draw the arc matching a
3442% clock-wise rotation
3443%
3444*/
3445WandExport void DrawPathEllipticArcRelative(DrawingWand *wand,const double rx,
3446 const double ry,const double x_axis_rotation,
3447 const MagickBooleanType large_arc_flag,const MagickBooleanType sweep_flag,
3448 const double x,const double y)
3449{
3450 DrawPathEllipticArc(wand,RelativePathMode,rx,ry,x_axis_rotation,
3451 large_arc_flag,sweep_flag,x,y);
3452}
3453␌
3454/*
3455%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3456% %
3457% %
3458% %
3459% D r a w P a t h F i n i s h %
3460% %
3461% %
3462% %
3463%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3464%
3465% DrawPathFinish() terminates the current path.
3466%
3467% The format of the DrawPathFinish method is:
3468%
3469% void DrawPathFinish(DrawingWand *wand)
3470%
3471% A description of each parameter follows:
3472%
3473% o wand: the drawing wand.
3474%
3475*/
3476WandExport void DrawPathFinish(DrawingWand *wand)
3477{
3478 assert(wand != (DrawingWand *) NULL);
3479 assert(wand->signature == MagickWandSignature);
3480 if (wand->debug != MagickFalse)
3481 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3482 (void) MVGPrintf(wand,"'\n");
3483 wand->path_operation=PathDefaultOperation;
3484 wand->path_mode=DefaultPathMode;
3485}
3486␌
3487/*
3488%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3489% %
3490% %
3491% %
3492% D r a w P a t h L i n e T o A b s o l u t e %
3493% %
3494% %
3495% %
3496%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3497%
3498% DrawPathLineToAbsolute() draws a line path from the current point to the
3499% given coordinate using absolute coordinates. The coordinate then becomes
3500% the new current point.
3501%
3502% The format of the DrawPathLineToAbsolute method is:
3503%
3504% void DrawPathLineToAbsolute(DrawingWand *wand,const double x,
3505% const double y)
3506%
3507% A description of each parameter follows:
3508%
3509% o wand: the drawing wand.
3510%
3511% o x: target x ordinate
3512%
3513% o y: target y ordinate
3514%
3515*/
3516static void DrawPathLineTo(DrawingWand *wand,const PathMode mode,
3517 const double x,const double y)
3518{
3519 assert(wand != (DrawingWand *) NULL);
3520 assert(wand->signature == MagickWandSignature);
3521 if (wand->debug != MagickFalse)
3522 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3523 if ((wand->path_operation != PathLineToOperation) ||
3524 (wand->path_mode != mode))
3525 {
3526 wand->path_operation=PathLineToOperation;
3527 wand->path_mode=mode;
3528 (void) MVGAutoWrapPrintf(wand,"%c%.17g %.17g",mode == AbsolutePathMode ?
3529 'L' : 'l',x,y);
3530 }
3531 else
3532 (void) MVGAutoWrapPrintf(wand," %.17g %.17g",x,y);
3533}
3534
3535WandExport void DrawPathLineToAbsolute(DrawingWand *wand,const double x,
3536 const double y)
3537{
3538 assert(wand != (DrawingWand *) NULL);
3539 assert(wand->signature == MagickWandSignature);
3540 if (wand->debug != MagickFalse)
3541 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3542 DrawPathLineTo(wand,AbsolutePathMode,x,y);
3543}
3544␌
3545/*
3546%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3547% %
3548% %
3549% %
3550% D r a w P a t h L i n e T o R e l a t i v e %
3551% %
3552% %
3553% %
3554%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3555%
3556% DrawPathLineToRelative() draws a line path from the current point to the
3557% given coordinate using relative coordinates. The coordinate then becomes
3558% the new current point.
3559%
3560% The format of the DrawPathLineToRelative method is:
3561%
3562% void DrawPathLineToRelative(DrawingWand *wand,const double x,
3563% const double y)
3564%
3565% A description of each parameter follows:
3566%
3567% o wand: the drawing wand.
3568%
3569% o x: target x ordinate
3570%
3571% o y: target y ordinate
3572%
3573*/
3574WandExport void DrawPathLineToRelative(DrawingWand *wand,const double x,
3575 const double y)
3576{
3577 assert(wand != (DrawingWand *) NULL);
3578 assert(wand->signature == MagickWandSignature);
3579 if (wand->debug != MagickFalse)
3580 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3581 DrawPathLineTo(wand,RelativePathMode,x,y);
3582}
3583␌
3584/*
3585%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3586% %
3587% %
3588% %
3589% D r a w P a t h L i n e T o H o r i z o n t a l A b s o l u t e %
3590% %
3591% %
3592% %
3593%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3594%
3595% DrawPathLineToHorizontalAbsolute() draws a horizontal line path from the
3596% current point to the target point using absolute coordinates. The target
3597% point then becomes the new current point.
3598%
3599% The format of the DrawPathLineToHorizontalAbsolute method is:
3600%
3601% void DrawPathLineToHorizontalAbsolute(DrawingWand *wand,const double x)
3602%
3603% A description of each parameter follows:
3604%
3605% o wand: the drawing wand.
3606%
3607% o x: target x ordinate
3608%
3609*/
3610
3611static void DrawPathLineToHorizontal(DrawingWand *wand,const PathMode mode,
3612 const double x)
3613{
3614 assert(wand != (DrawingWand *) NULL);
3615 assert(wand->signature == MagickWandSignature);
3616 if (wand->debug != MagickFalse)
3617 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3618 if ((wand->path_operation != PathLineToHorizontalOperation) ||
3619 (wand->path_mode != mode))
3620 {
3621 wand->path_operation=PathLineToHorizontalOperation;
3622 wand->path_mode=mode;
3623 (void) MVGAutoWrapPrintf(wand,"%c%.17g",mode == AbsolutePathMode ?
3624 'H' : 'h',x);
3625 }
3626 else
3627 (void) MVGAutoWrapPrintf(wand," %.17g",x);
3628}
3629
3630WandExport void DrawPathLineToHorizontalAbsolute(DrawingWand *wand,
3631 const double x)
3632{
3633 assert(wand != (DrawingWand *) NULL);
3634 assert(wand->signature == MagickWandSignature);
3635 if (wand->debug != MagickFalse)
3636 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3637 DrawPathLineToHorizontal(wand,AbsolutePathMode,x);
3638}
3639␌
3640/*
3641%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3642% %
3643% %
3644% %
3645% D r a w P a t h L i n e T o H o r i z o n t a l R e l a t i v e %
3646% %
3647% %
3648% %
3649%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3650%
3651% DrawPathLineToHorizontalRelative() draws a horizontal line path from the
3652% current point to the target point using relative coordinates. The target
3653% point then becomes the new current point.
3654%
3655% The format of the DrawPathLineToHorizontalRelative method is:
3656%
3657% void DrawPathLineToHorizontalRelative(DrawingWand *wand,
3658% const double x)
3659%
3660% A description of each parameter follows:
3661%
3662% o wand: the drawing wand.
3663%
3664% o x: target x ordinate
3665%
3666*/
3667WandExport void DrawPathLineToHorizontalRelative(DrawingWand *wand,
3668 const double x)
3669{
3670 DrawPathLineToHorizontal(wand,RelativePathMode,x);
3671}
3672␌
3673/*
3674%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3675% %
3676% %
3677% %
3678% D r a w P a t h L i n e T o V e r t i c a l A b s o l u t e %
3679% %
3680% %
3681% %
3682%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3683%
3684% DrawPathLineToVerticalAbsolute() draws a vertical line path from the
3685% current point to the target point using absolute coordinates. The target
3686% point then becomes the new current point.
3687%
3688% The format of the DrawPathLineToVerticalAbsolute method is:
3689%
3690% void DrawPathLineToVerticalAbsolute(DrawingWand *wand,
3691% const double y)
3692%
3693% A description of each parameter follows:
3694%
3695% o wand: the drawing wand.
3696%
3697% o y: target y ordinate
3698%
3699*/
3700
3701static void DrawPathLineToVertical(DrawingWand *wand,const PathMode mode,
3702 const double y)
3703{
3704 assert(wand != (DrawingWand *) NULL);
3705 assert(wand->signature == MagickWandSignature);
3706 if (wand->debug != MagickFalse)
3707 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3708 if ((wand->path_operation != PathLineToVerticalOperation) ||
3709 (wand->path_mode != mode))
3710 {
3711 wand->path_operation=PathLineToVerticalOperation;
3712 wand->path_mode=mode;
3713 (void) MVGAutoWrapPrintf(wand,"%c%.17g",mode == AbsolutePathMode ?
3714 'V' : 'v',y);
3715 }
3716 else
3717 (void) MVGAutoWrapPrintf(wand," %.17g",y);
3718}
3719
3720WandExport void DrawPathLineToVerticalAbsolute(DrawingWand *wand,const double y)
3721{
3722 assert(wand != (DrawingWand *) NULL);
3723 assert(wand->signature == MagickWandSignature);
3724 if (wand->debug != MagickFalse)
3725 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3726 DrawPathLineToVertical(wand,AbsolutePathMode,y);
3727}
3728␌
3729/*
3730%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3731% %
3732% %
3733% %
3734% D r a w P a t h L i n e T o V e r t i c a l R e l a t i v e %
3735% %
3736% %
3737% %
3738%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3739%
3740% DrawPathLineToVerticalRelative() draws a vertical line path from the
3741% current point to the target point using relative coordinates. The target
3742% point then becomes the new current point.
3743%
3744% The format of the DrawPathLineToVerticalRelative method is:
3745%
3746% void DrawPathLineToVerticalRelative(DrawingWand *wand,
3747% const double y)
3748%
3749% A description of each parameter follows:
3750%
3751% o wand: the drawing wand.
3752%
3753% o y: target y ordinate
3754%
3755*/
3756WandExport void DrawPathLineToVerticalRelative(DrawingWand *wand,const double y)
3757{
3758 assert(wand != (DrawingWand *) NULL);
3759 assert(wand->signature == MagickWandSignature);
3760 if (wand->debug != MagickFalse)
3761 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3762 DrawPathLineToVertical(wand,RelativePathMode,y);
3763}
3764/*
3765%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3766% %
3767% %
3768% %
3769% D r a w P a t h M o v e T o A b s o l u t e %
3770% %
3771% %
3772% %
3773%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3774%
3775% DrawPathMoveToAbsolute() starts a new sub-path at the given coordinate
3776% using absolute coordinates. The current point then becomes the
3777% specified coordinate.
3778%
3779% The format of the DrawPathMoveToAbsolute method is:
3780%
3781% void DrawPathMoveToAbsolute(DrawingWand *wand,const double x,
3782% const double y)
3783%
3784% A description of each parameter follows:
3785%
3786% o wand: the drawing wand.
3787%
3788% o x: target x ordinate
3789%
3790% o y: target y ordinate
3791%
3792*/
3793
3794static void DrawPathMoveTo(DrawingWand *wand,const PathMode mode,const double x,
3795 const double y)
3796{
3797 assert(wand != (DrawingWand *) NULL);
3798 assert(wand->signature == MagickWandSignature);
3799 if (wand->debug != MagickFalse)
3800 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3801 if ((wand->path_operation != PathMoveToOperation) ||
3802 (wand->path_mode != mode))
3803 {
3804 wand->path_operation=PathMoveToOperation;
3805 wand->path_mode=mode;
3806 (void) MVGAutoWrapPrintf(wand,"%c%.17g %.17g",mode == AbsolutePathMode ?
3807 'M' : 'm',x,y);
3808 }
3809 else
3810 (void) MVGAutoWrapPrintf(wand," %.17g %.17g",x,y);
3811}
3812
3813WandExport void DrawPathMoveToAbsolute(DrawingWand *wand,const double x,
3814 const double y)
3815{
3816 assert(wand != (DrawingWand *) NULL);
3817 assert(wand->signature == MagickWandSignature);
3818 if (wand->debug != MagickFalse)
3819 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3820 DrawPathMoveTo(wand,AbsolutePathMode,x,y);
3821}
3822␌
3823/*
3824%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3825% %
3826% %
3827% %
3828% D r a w P a t h M o v e T o R e l a t i v e %
3829% %
3830% %
3831% %
3832%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3833%
3834% DrawPathMoveToRelative() starts a new sub-path at the given coordinate using
3835% relative coordinates. The current point then becomes the specified
3836% coordinate.
3837%
3838% The format of the DrawPathMoveToRelative method is:
3839%
3840% void DrawPathMoveToRelative(DrawingWand *wand,const double x,
3841% const double y)
3842%
3843% A description of each parameter follows:
3844%
3845% o wand: the drawing wand.
3846%
3847% o x: target x ordinate
3848%
3849% o y: target y ordinate
3850%
3851*/
3852WandExport void DrawPathMoveToRelative(DrawingWand *wand,const double x,
3853 const double y)
3854{
3855 assert(wand != (DrawingWand *) NULL);
3856 assert(wand->signature == MagickWandSignature);
3857 if (wand->debug != MagickFalse)
3858 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3859 DrawPathMoveTo(wand,RelativePathMode,x,y);
3860}
3861␌
3862/*
3863%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3864% %
3865% %
3866% %
3867% D r a w P a t h S t a r t %
3868% %
3869% %
3870% %
3871%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3872%
3873% DrawPathStart() declares the start of a path drawing list which is terminated
3874% by a matching DrawPathFinish() command. All other DrawPath commands must
3875% be enclosed between a DrawPathStart() and a DrawPathFinish() command. This
3876% is because path drawing commands are subordinate commands and they do not
3877% function by themselves.
3878%
3879% The format of the DrawPathStart method is:
3880%
3881% void DrawPathStart(DrawingWand *wand)
3882%
3883% A description of each parameter follows:
3884%
3885% o wand: the drawing wand.
3886%
3887*/
3888WandExport void DrawPathStart(DrawingWand *wand)
3889{
3890 assert(wand != (DrawingWand *) NULL);
3891 assert(wand->signature == MagickWandSignature);
3892 if (wand->debug != MagickFalse)
3893 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3894 (void) MVGPrintf(wand,"path '");
3895 wand->path_operation=PathDefaultOperation;
3896 wand->path_mode=DefaultPathMode;
3897}
3898␌
3899/*
3900%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3901% %
3902% %
3903% %
3904% D r a w P o i n t %
3905% %
3906% %
3907% %
3908%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3909%
3910% DrawPoint() draws a point using the current fill color.
3911%
3912% The format of the DrawPoint method is:
3913%
3914% void DrawPoint(DrawingWand *wand,const double x,const double y)
3915%
3916% A description of each parameter follows:
3917%
3918% o wand: the drawing wand.
3919%
3920% o x: target x coordinate
3921%
3922% o y: target y coordinate
3923%
3924*/
3925WandExport void DrawPoint(DrawingWand *wand,const double x,const double y)
3926{
3927 assert(wand != (DrawingWand *) NULL);
3928 assert(wand->signature == MagickWandSignature);
3929 if (wand->debug != MagickFalse)
3930 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3931 (void) MVGPrintf(wand,"point %.17g %.17g\n",x,y);
3932}
3933␌
3934/*
3935%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3936% %
3937% %
3938% %
3939% D r a w P o l y g o n %
3940% %
3941% %
3942% %
3943%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3944%
3945% DrawPolygon() draws a polygon using the current stroke, stroke width, and
3946% fill color or texture, using the specified array of coordinates.
3947%
3948% The format of the DrawPolygon method is:
3949%
3950% void DrawPolygon(DrawingWand *wand,
3951% const size_t number_coordinates,const PointInfo *coordinates)
3952%
3953% A description of each parameter follows:
3954%
3955% o wand: the drawing wand.
3956%
3957% o number_coordinates: number of coordinates
3958%
3959% o coordinates: coordinate array
3960%
3961*/
3962WandExport void DrawPolygon(DrawingWand *wand,
3963 const size_t number_coordinates,const PointInfo *coordinates)
3964{
3965 assert(wand != (DrawingWand *) NULL);
3966 assert(wand->signature == MagickWandSignature);
3967 if (wand->debug != MagickFalse)
3968 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
3969 MVGAppendPointsCommand(wand,"polygon",number_coordinates,coordinates);
3970}
3971␌
3972/*
3973%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3974% %
3975% %
3976% %
3977% D r a w P o l y l i n e %
3978% %
3979% %
3980% %
3981%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3982%
3983% DrawPolyline() draws a polyline using the current stroke, stroke width, and
3984% fill color or texture, using the specified array of coordinates.
3985%
3986% The format of the DrawPolyline method is:
3987%
3988% void DrawPolyline(DrawingWand *wand,
3989% const size_t number_coordinates,const PointInfo *coordinates)
3990%
3991% A description of each parameter follows:
3992%
3993% o wand: the drawing wand.
3994%
3995% o number_coordinates: number of coordinates
3996%
3997% o coordinates: coordinate array
3998%
3999*/
4000WandExport void DrawPolyline(DrawingWand *wand,
4001 const size_t number_coordinates,const PointInfo *coordinates)
4002{
4003 assert(wand != (DrawingWand *) NULL);
4004 assert(wand->signature == MagickWandSignature);
4005 if (wand->debug != MagickFalse)
4006 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4007 MVGAppendPointsCommand(wand,"polyline",number_coordinates,coordinates);
4008}
4009␌
4010/*
4011%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4012% %
4013% %
4014% %
4015% D r a w P o p C l i p P a t h %
4016% %
4017% %
4018% %
4019%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4020%
4021% DrawPopClipPath() terminates a clip path definition.
4022%
4023% The format of the DrawPopClipPath method is:
4024%
4025% void DrawPopClipPath(DrawingWand *wand)
4026%
4027% A description of each parameter follows:
4028%
4029% o wand: the drawing wand.
4030%
4031*/
4032WandExport void DrawPopClipPath(DrawingWand *wand)
4033{
4034 assert(wand != (DrawingWand *) NULL);
4035 assert(wand->signature == MagickWandSignature);
4036 if (wand->debug != MagickFalse)
4037 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4038 if (wand->indent_depth > 0)
4039 wand->indent_depth--;
4040 (void) MVGPrintf(wand,"pop clip-path\n");
4041}
4042␌
4043/*
4044%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4045% %
4046% %
4047% %
4048% D r a w P o p D e f s %
4049% %
4050% %
4051% %
4052%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4053%
4054% DrawPopDefs() terminates a definition list.
4055%
4056% The format of the DrawPopDefs method is:
4057%
4058% void DrawPopDefs(DrawingWand *wand)
4059%
4060% A description of each parameter follows:
4061%
4062% o wand: the drawing wand.
4063%
4064*/
4065WandExport void DrawPopDefs(DrawingWand *wand)
4066{
4067 assert(wand != (DrawingWand *) NULL);
4068 assert(wand->signature == MagickWandSignature);
4069 if (wand->debug != MagickFalse)
4070 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4071 if (wand->indent_depth > 0)
4072 wand->indent_depth--;
4073 (void) MVGPrintf(wand,"pop defs\n");
4074}
4075␌
4076/*
4077%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4078% %
4079% %
4080% %
4081% D r a w P o p P a t t e r n %
4082% %
4083% %
4084% %
4085%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4086%
4087% DrawPopPattern() terminates a pattern definition.
4088%
4089% The format of the DrawPopPattern method is:
4090%
4091% MagickBooleanType DrawPopPattern(DrawingWand *wand)
4092%
4093% A description of each parameter follows:
4094%
4095% o wand: the drawing wand.
4096%
4097*/
4098WandExport MagickBooleanType DrawPopPattern(DrawingWand *wand)
4099{
4100 char
4101 geometry[MagickPathExtent],
4102 key[MagickPathExtent];
4103
4104 assert(wand != (DrawingWand *) NULL);
4105 assert(wand->signature == MagickWandSignature);
4106 if (wand->debug != MagickFalse)
4107 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4108 if (wand->image == (Image *) NULL)
4109 {
4110 ThrowDrawException(WandError,"ContainsNoImages",wand->name);
4111 return(MagickFalse);
4112 }
4113 if (wand->pattern_id == (const char *) NULL)
4114 {
4115 ThrowDrawException(DrawWarning,"NotCurrentlyPushingPatternDefinition",
4116 wand->name);
4117 return(MagickFalse);
4118 }
4119 (void) FormatLocaleString(key,MagickPathExtent,"%s",wand->pattern_id);
4120 (void) SetImageArtifact(wand->image,key,wand->mvg+wand->pattern_offset);
4121 (void) FormatLocaleString(geometry,MagickPathExtent,"%.17gx%.17g%+.20g%+.20g",
4122 (double) wand->pattern_bounds.width,(double) wand->pattern_bounds.height,
4123 (double) wand->pattern_bounds.x,(double) wand->pattern_bounds.y);
4124 (void) SetImageArtifact(wand->image,key,geometry);
4125 wand->pattern_id=DestroyString(wand->pattern_id);
4126 wand->pattern_offset=0;
4127 wand->pattern_bounds.x=0;
4128 wand->pattern_bounds.y=0;
4129 wand->pattern_bounds.width=0;
4130 wand->pattern_bounds.height=0;
4131 wand->filter_off=MagickTrue;
4132 if (wand->indent_depth > 0)
4133 wand->indent_depth--;
4134 (void) MVGPrintf(wand,"pop pattern\n");
4135 return(MagickTrue);
4136}
4137␌
4138/*
4139%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4140% %
4141% %
4142% %
4143% D r a w P u s h C l i p P a t h %
4144% %
4145% %
4146% %
4147%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4148%
4149% DrawPushClipPath() starts a clip path definition which is comprized of any
4150% number of drawing commands and terminated by a DrawPopClipPath() command.
4151%
4152% The format of the DrawPushClipPath method is:
4153%
4154% void DrawPushClipPath(DrawingWand *wand,const char *clip_mask_id)
4155%
4156% A description of each parameter follows:
4157%
4158% o wand: the drawing wand.
4159%
4160% o clip_mask_id: string identifier to associate with the clip path for
4161% later use.
4162%
4163*/
4164WandExport void DrawPushClipPath(DrawingWand *wand,const char *clip_mask_id)
4165{
4166 assert(wand != (DrawingWand *) NULL);
4167 assert(wand->signature == MagickWandSignature);
4168 if (wand->debug != MagickFalse)
4169 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4170 assert(clip_mask_id != (const char *) NULL);
4171 (void) MVGPrintf(wand,"push clip-path \"%s\"\n",clip_mask_id);
4172 wand->indent_depth++;
4173}
4174␌
4175/*
4176%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4177% %
4178% %
4179% %
4180% D r a w P u s h D e f s %
4181% %
4182% %
4183% %
4184%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4185%
4186% DrawPushDefs() indicates that commands up to a terminating DrawPopDefs()
4187% command create named elements (e.g. clip-paths, textures, etc.) which
4188% may safely be processed earlier for the sake of efficiency.
4189%
4190% The format of the DrawPushDefs method is:
4191%
4192% void DrawPushDefs(DrawingWand *wand)
4193%
4194% A description of each parameter follows:
4195%
4196% o wand: the drawing wand.
4197%
4198*/
4199WandExport void DrawPushDefs(DrawingWand *wand)
4200{
4201 assert(wand != (DrawingWand *) NULL);
4202 assert(wand->signature == MagickWandSignature);
4203 if (wand->debug != MagickFalse)
4204 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4205 (void) MVGPrintf(wand,"push defs\n");
4206 wand->indent_depth++;
4207}
4208␌
4209/*
4210%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4211% %
4212% %
4213% %
4214% D r a w P u s h P a t t e r n %
4215% %
4216% %
4217% %
4218%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4219%
4220% DrawPushPattern() indicates that subsequent commands up to a
4221% DrawPopPattern() command comprise the definition of a named pattern.
4222% The pattern space is assigned top left corner coordinates, a width
4223% and height, and becomes its own drawing space. Anything which can
4224% be drawn may be used in a pattern definition.
4225% Named patterns may be used as stroke or brush definitions.
4226%
4227% The format of the DrawPushPattern method is:
4228%
4229% MagickBooleanType DrawPushPattern(DrawingWand *wand,
4230% const char *pattern_id,const double x,const double y,
4231% const double width,const double height)
4232%
4233% A description of each parameter follows:
4234%
4235% o wand: the drawing wand.
4236%
4237% o pattern_id: pattern identification for later reference
4238%
4239% o x: x ordinate of top left corner
4240%
4241% o y: y ordinate of top left corner
4242%
4243% o width: width of pattern space
4244%
4245% o height: height of pattern space
4246%
4247*/
4248WandExport MagickBooleanType DrawPushPattern(DrawingWand *wand,
4249 const char *pattern_id,const double x,const double y,const double width,
4250 const double height)
4251{
4252 assert(wand != (DrawingWand *) NULL);
4253 assert(wand->signature == MagickWandSignature);
4254 if (wand->debug != MagickFalse)
4255 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4256 assert(pattern_id != (const char *) NULL);
4257 if (wand->pattern_id != NULL)
4258 {
4259 ThrowDrawException(DrawError,"AlreadyPushingPatternDefinition",
4260 wand->pattern_id);
4261 return(MagickFalse);
4262 }
4263 wand->filter_off=MagickTrue;
4264 (void) MVGPrintf(wand,"push pattern %s %.17g %.17g %.17g %.17g\n",pattern_id,
4265 x,y,width,height);
4266 wand->indent_depth++;
4267 wand->pattern_id=AcquireString(pattern_id);
4268 wand->pattern_bounds.x=CastDoubleToSsizeT(ceil(x-0.5));
4269 wand->pattern_bounds.y=CastDoubleToSsizeT(ceil(y-0.5));
4270 wand->pattern_bounds.width=(size_t) CastDoubleToSsizeT(floor(width+0.5));
4271 wand->pattern_bounds.height=(size_t) CastDoubleToSsizeT(floor(height+0.5));
4272 wand->pattern_offset=wand->mvg_length;
4273 return(MagickTrue);
4274}
4275␌
4276/*
4277%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4278% %
4279% %
4280% %
4281% D r a w R e c t a n g l e %
4282% %
4283% %
4284% %
4285%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4286%
4287% DrawRectangle() draws a rectangle given two coordinates and using the
4288% current stroke, stroke width, and fill settings.
4289%
4290% The format of the DrawRectangle method is:
4291%
4292% void DrawRectangle(DrawingWand *wand,const double x1,
4293% const double y1,const double x2,const double y2)
4294%
4295% A description of each parameter follows:
4296%
4297% o x1: x ordinate of first coordinate
4298%
4299% o y1: y ordinate of first coordinate
4300%
4301% o x2: x ordinate of second coordinate
4302%
4303% o y2: y ordinate of second coordinate
4304%
4305*/
4306WandExport void DrawRectangle(DrawingWand *wand,const double x1,const double y1,
4307 const double x2,const double y2)
4308{
4309 assert(wand != (DrawingWand *) NULL);
4310 assert(wand->signature == MagickWandSignature);
4311 if (wand->debug != MagickFalse)
4312 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4313 if ((fabs(x2-x1) < MagickEpsilon) && (fabs(y2-y1) < MagickEpsilon))
4314 (void) MVGPrintf(wand,"point %.17g %.17g\n",x1,y1);
4315 else
4316 (void) MVGPrintf(wand,"rectangle %.17g %.17g %.17g %.17g\n",x1,y1,x2,y2);
4317}
4318␌
4319/*
4320%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4321% %
4322% %
4323% %
4324+ D r a w R e n d e r %
4325% %
4326% %
4327% %
4328%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4329%
4330% DrawRender() renders all preceding drawing commands onto the image.
4331%
4332% The format of the DrawRender method is:
4333%
4334% MagickBooleanType DrawRender(DrawingWand *wand)
4335%
4336% A description of each parameter follows:
4337%
4338% o wand: the drawing wand.
4339%
4340*/
4341WandExport MagickBooleanType DrawRender(DrawingWand *wand)
4342{
4343 MagickBooleanType
4344 status;
4345
4346 assert(wand != (const DrawingWand *) NULL);
4347 assert(wand->signature == MagickWandSignature);
4348 if (wand->debug != MagickFalse)
4349 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4350 CurrentContext->primitive=wand->mvg;
4351 if (wand->debug != MagickFalse)
4352 (void) LogMagickEvent(DrawEvent,GetMagickModule(),"MVG:\n'%s'\n",wand->mvg);
4353 if (wand->image == (Image *) NULL)
4354 {
4355 ThrowDrawException(WandError,"ContainsNoImages",wand->name);
4356 return(MagickFalse);
4357 }
4358 status=DrawImage(wand->image,CurrentContext,wand->exception);
4359 CurrentContext->primitive=(char *) NULL;
4360 return(status);
4361}
4362␌
4363/*
4364%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4365% %
4366% %
4367% %
4368% D r a w R e s e t V e c t o r G r a p h i c s %
4369% %
4370% %
4371% %
4372%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4373%
4374% DrawResetVectorGraphics() resets the vector graphics associated with the
4375% specified wand.
4376%
4377% The format of the DrawResetVectorGraphics method is:
4378%
4379% void DrawResetVectorGraphics(DrawingWand *wand)
4380%
4381% A description of each parameter follows:
4382%
4383% o wand: the drawing wand.
4384%
4385*/
4386WandExport void DrawResetVectorGraphics(DrawingWand *wand)
4387{
4388 assert(wand != (DrawingWand *) NULL);
4389 assert(wand->signature == MagickWandSignature);
4390 if (wand->debug != MagickFalse)
4391 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4392 if (wand->mvg != (char *) NULL)
4393 wand->mvg=DestroyString(wand->mvg);
4394 wand->mvg_alloc=0;
4395 wand->mvg_length=0;
4396 wand->mvg_width=0;
4397}
4398␌
4399/*
4400%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4401% %
4402% %
4403% %
4404% D r a w R o t a t e %
4405% %
4406% %
4407% %
4408%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4409%
4410% DrawRotate() applies the specified rotation to the current coordinate space.
4411%
4412% The format of the DrawRotate method is:
4413%
4414% void DrawRotate(DrawingWand *wand,const double degrees)
4415%
4416% A description of each parameter follows:
4417%
4418% o wand: the drawing wand.
4419%
4420% o degrees: degrees of rotation
4421%
4422*/
4423WandExport void DrawRotate(DrawingWand *wand,const double degrees)
4424{
4425 assert(wand != (DrawingWand *) NULL);
4426 assert(wand->signature == MagickWandSignature);
4427 if (wand->debug != MagickFalse)
4428 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4429 (void) MVGPrintf(wand,"rotate %.17g\n",degrees);
4430}
4431␌
4432/*
4433%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4434% %
4435% %
4436% %
4437% D r a w R o u n d R e c t a n g l e %
4438% %
4439% %
4440% %
4441%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4442%
4443% DrawRoundRectangle() draws a rounded rectangle given two coordinates,
4444% x & y corner radiuses and using the current stroke, stroke width,
4445% and fill settings.
4446%
4447% The format of the DrawRoundRectangle method is:
4448%
4449% void DrawRoundRectangle(DrawingWand *wand,double x1,double y1,
4450% double x2,double y2,double rx,double ry)
4451%
4452% A description of each parameter follows:
4453%
4454% o wand: the drawing wand.
4455%
4456% o x1: x ordinate of first coordinate
4457%
4458% o y1: y ordinate of first coordinate
4459%
4460% o x2: x ordinate of second coordinate
4461%
4462% o y2: y ordinate of second coordinate
4463%
4464% o rx: radius of corner in horizontal direction
4465%
4466% o ry: radius of corner in vertical direction
4467%
4468*/
4469WandExport void DrawRoundRectangle(DrawingWand *wand,double x1,double y1,
4470 double x2,double y2,double rx,double ry)
4471{
4472 assert(wand != (DrawingWand *) NULL);
4473 assert(wand->signature == MagickWandSignature);
4474 if (wand->debug != MagickFalse)
4475 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4476 (void) MVGPrintf(wand,"roundrectangle %.17g %.17g %.17g %.17g %.17g %.17g\n",
4477 x1,y1,x2,y2,rx,ry);
4478}
4479␌
4480/*
4481%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4482% %
4483% %
4484% %
4485% D r a w S c a l e %
4486% %
4487% %
4488% %
4489%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4490%
4491% DrawScale() adjusts the scaling factor to apply in the horizontal and
4492% vertical directions to the current coordinate space.
4493%
4494% The format of the DrawScale method is:
4495%
4496% void DrawScale(DrawingWand *wand,const double x,const double y)
4497%
4498% A description of each parameter follows:
4499%
4500% o wand: the drawing wand.
4501%
4502% o x: horizontal scale factor
4503%
4504% o y: vertical scale factor
4505%
4506*/
4507WandExport void DrawScale(DrawingWand *wand,const double x,const double y)
4508{
4509 assert(wand != (DrawingWand *) NULL);
4510 assert(wand->signature == MagickWandSignature);
4511 if (wand->debug != MagickFalse)
4512 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4513 (void) MVGPrintf(wand,"scale %.17g %.17g\n",x,y);
4514}
4515␌
4516/*
4517%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4518% %
4519% %
4520% %
4521% D r a w S e t B o r d e r C o l o r %
4522% %
4523% %
4524% %
4525%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4526%
4527% DrawSetBorderColor() sets the border color to be used for drawing bordered
4528% objects.
4529%
4530% The format of the DrawSetBorderColor method is:
4531%
4532% void DrawSetBorderColor(DrawingWand *wand,const PixelWand *border_wand)
4533%
4534% A description of each parameter follows:
4535%
4536% o wand: the drawing wand.
4537%
4538% o border_wand: border wand.
4539%
4540*/
4541WandExport void DrawSetBorderColor(DrawingWand *wand,
4542 const PixelWand *border_wand)
4543{
4544 PixelInfo
4545 *current_border,
4546 border_color,
4547 new_border;
4548
4549 assert(wand != (DrawingWand *) NULL);
4550 assert(wand->signature == MagickWandSignature);
4551 if (wand->debug != MagickFalse)
4552 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4553 assert(border_wand != (const PixelWand *) NULL);
4554 PixelGetQuantumPacket(border_wand,&border_color);
4555 new_border=border_color;
4556 current_border=(&CurrentContext->border_color);
4557 if ((wand->filter_off != MagickFalse) ||
4558 (IsPixelInfoEquivalent(current_border,&new_border) == MagickFalse))
4559 {
4560 CurrentContext->border_color=new_border;
4561 (void) MVGPrintf(wand,"border-color '");
4562 MVGAppendColor(wand,&border_color);
4563 (void) MVGPrintf(wand,"'\n");
4564 }
4565}
4566␌
4567/*
4568%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4569% %
4570% %
4571% %
4572% D r a w S e t C l i p P a t h %
4573% %
4574% %
4575% %
4576%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4577%
4578% DrawSetClipPath() associates a named clipping path with the image. Only
4579% the areas drawn on by the clipping path will be modified as ssize_t as it
4580% remains in effect.
4581%
4582% The format of the DrawSetClipPath method is:
4583%
4584% MagickBooleanType DrawSetClipPath(DrawingWand *wand,
4585% const char *clip_mask)
4586%
4587% A description of each parameter follows:
4588%
4589% o wand: the drawing wand.
4590%
4591% o clip_mask: name of clipping path to associate with image
4592%
4593*/
4594WandExport MagickBooleanType DrawSetClipPath(DrawingWand *wand,
4595 const char *clip_mask)
4596{
4597 assert(wand != (DrawingWand *) NULL);
4598 if (wand->debug != MagickFalse)
4599 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",clip_mask);
4600 assert(wand->signature == MagickWandSignature);
4601 assert(clip_mask != (const char *) NULL);
4602 if ((CurrentContext->clip_mask == (const char *) NULL) ||
4603 (wand->filter_off != MagickFalse) ||
4604 (LocaleCompare(CurrentContext->clip_mask,clip_mask) != 0))
4605 {
4606 (void) CloneString(&CurrentContext->clip_mask,clip_mask);
4607#if DRAW_BINARY_IMPLEMENTATION
4608 if (wand->image == (Image *) NULL)
4609 {
4610 ThrowDrawException(WandError,"ContainsNoImages",wand->name);
4611 return(MagickFalse);
4612 }
4613 (void) DrawClipPath(wand->image,CurrentContext,CurrentContext->clip_mask,
4614 wand->exception);
4615#endif
4616 (void) MVGPrintf(wand,"clip-path url(#%s)\n",clip_mask);
4617 }
4618 return(MagickTrue);
4619}
4620␌
4621/*
4622%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4623% %
4624% %
4625% %
4626% D r a w S e t C l i p R u l e %
4627% %
4628% %
4629% %
4630%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4631%
4632% DrawSetClipRule() set the polygon fill rule to be used by the clipping path.
4633%
4634% The format of the DrawSetClipRule method is:
4635%
4636% void DrawSetClipRule(DrawingWand *wand,const FillRule fill_rule)
4637%
4638% A description of each parameter follows:
4639%
4640% o wand: the drawing wand.
4641%
4642% o fill_rule: fill rule (EvenOddRule or NonZeroRule)
4643%
4644*/
4645WandExport void DrawSetClipRule(DrawingWand *wand,const FillRule fill_rule)
4646{
4647 assert(wand != (DrawingWand *) NULL);
4648 assert(wand->signature == MagickWandSignature);
4649 if (wand->debug != MagickFalse)
4650 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4651 if ((wand->filter_off != MagickFalse) ||
4652 (CurrentContext->fill_rule != fill_rule))
4653 {
4654 CurrentContext->fill_rule=fill_rule;
4655 (void) MVGPrintf(wand, "clip-rule '%s'\n",CommandOptionToMnemonic(
4656 MagickFillRuleOptions,(ssize_t) fill_rule));
4657 }
4658}
4659␌
4660/*
4661%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4662% %
4663% %
4664% %
4665% D r a w S e t C l i p U n i t s %
4666% %
4667% %
4668% %
4669%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4670%
4671% DrawSetClipUnits() sets the interpretation of clip path units.
4672%
4673% The format of the DrawSetClipUnits method is:
4674%
4675% void DrawSetClipUnits(DrawingWand *wand,
4676% const ClipPathUnits clip_units)
4677%
4678% A description of each parameter follows:
4679%
4680% o wand: the drawing wand.
4681%
4682% o clip_units: units to use (UserSpace, UserSpaceOnUse, or
4683% ObjectBoundingBox)
4684%
4685*/
4686WandExport void DrawSetClipUnits(DrawingWand *wand,
4687 const ClipPathUnits clip_units)
4688{
4689 assert(wand != (DrawingWand *) NULL);
4690 assert(wand->signature == MagickWandSignature);
4691 if (wand->debug != MagickFalse)
4692 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4693 if ((wand->filter_off != MagickFalse) ||
4694 (CurrentContext->clip_units != clip_units))
4695 {
4696 CurrentContext->clip_units=clip_units;
4697 if (clip_units == ObjectBoundingBox)
4698 {
4699 AffineMatrix
4700 affine;
4701
4702 GetAffineMatrix(&affine);
4703 affine.sx=CurrentContext->bounds.x2;
4704 affine.sy=CurrentContext->bounds.y2;
4705 affine.tx=CurrentContext->bounds.x1;
4706 affine.ty=CurrentContext->bounds.y1;
4707 AdjustAffine(wand,&affine);
4708 }
4709 (void) MVGPrintf(wand, "clip-units '%s'\n",CommandOptionToMnemonic(
4710 MagickClipPathOptions,(ssize_t) clip_units));
4711 }
4712}
4713␌
4714/*
4715%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4716% %
4717% %
4718% %
4719% D r a w S e t D e n s i t y %
4720% %
4721% %
4722% %
4723%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4724%
4725% DrawSetDensity() sets the vertical and horizontal resolution.
4726%
4727% The format of the DrawSetDensity method is:
4728%
4729% MagickBooleanType DrawSetDensity(DrawingWand *wand,
4730% const char *density)
4731%
4732% A description of each parameter follows:
4733%
4734% o wand: the drawing wand.
4735%
4736% o density: the vertical and horizontal resolution.
4737%
4738*/
4739WandExport MagickBooleanType DrawSetDensity(DrawingWand *wand,
4740 const char *density)
4741{
4742 assert(wand != (DrawingWand *) NULL);
4743 if (wand->debug != MagickFalse)
4744 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",density);
4745 assert(wand->signature == MagickWandSignature);
4746 assert(density != (const char *) NULL);
4747 if ((CurrentContext->density == (const char *) NULL) ||
4748 (wand->filter_off != MagickFalse) ||
4749 (LocaleCompare(CurrentContext->density,density) != 0))
4750 {
4751 (void) CloneString(&CurrentContext->density,density);
4752 (void) MVGPrintf(wand,"density '%s'\n",density);
4753 }
4754 return(MagickTrue);
4755}
4756
4757/*
4758%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4759% %
4760% %
4761% %
4762% D r a w S e t F i l l C o l o r %
4763% %
4764% %
4765% %
4766%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4767%
4768% DrawSetFillColor() sets the fill color to be used for drawing filled objects.
4769%
4770% The format of the DrawSetFillColor method is:
4771%
4772% void DrawSetFillColor(DrawingWand *wand,const PixelWand *fill_wand)
4773%
4774% A description of each parameter follows:
4775%
4776% o wand: the drawing wand.
4777%
4778% o fill_wand: fill wand.
4779%
4780*/
4781WandExport void DrawSetFillColor(DrawingWand *wand,const PixelWand *fill_wand)
4782{
4783 PixelInfo
4784 *current_fill,
4785 fill_color,
4786 new_fill;
4787
4788 assert(wand != (DrawingWand *) NULL);
4789 assert(wand->signature == MagickWandSignature);
4790 if (wand->debug != MagickFalse)
4791 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4792 assert(fill_wand != (const PixelWand *) NULL);
4793 PixelGetQuantumPacket(fill_wand,&fill_color);
4794 new_fill=fill_color;
4795 current_fill=(&CurrentContext->fill);
4796 if ((wand->filter_off != MagickFalse) ||
4797 (IsPixelInfoEquivalent(current_fill,&new_fill) == MagickFalse))
4798 {
4799 CurrentContext->fill=new_fill;
4800 (void) MVGPrintf(wand,"fill '");
4801 MVGAppendColor(wand,&fill_color);
4802 (void) MVGPrintf(wand,"'\n");
4803 }
4804}
4805␌
4806/*
4807%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4808% %
4809% %
4810% %
4811% D r a w S e t F i l l O p a c i t y %
4812% %
4813% %
4814% %
4815%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4816%
4817% DrawSetFillOpacity() sets the alpha to use when drawing using the fill
4818% color or fill texture. Fully opaque is 1.0.
4819%
4820% The format of the DrawSetFillOpacity method is:
4821%
4822% void DrawSetFillOpacity(DrawingWand *wand,const double fill_alpha)
4823%
4824% A description of each parameter follows:
4825%
4826% o wand: the drawing wand.
4827%
4828% o fill_opacity: fill opacity
4829%
4830*/
4831WandExport void DrawSetFillOpacity(DrawingWand *wand,const double fill_opacity)
4832{
4833 double
4834 alpha;
4835
4836 assert(wand != (DrawingWand *) NULL);
4837 assert(wand->signature == MagickWandSignature);
4838 if (wand->debug != MagickFalse)
4839 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4840 alpha=(double) ClampToQuantum((double) QuantumRange*fill_opacity);
4841 if ((wand->filter_off != MagickFalse) ||
4842 (CurrentContext->fill.alpha != alpha))
4843 {
4844 CurrentContext->fill.alpha=alpha;
4845 (void) MVGPrintf(wand,"fill-opacity %.17g\n",fill_opacity);
4846 }
4847}
4848␌
4849/*
4850%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4851% %
4852% %
4853% %
4854% D r a w S e t F o n t R e s o l u t i o n %
4855% %
4856% %
4857% %
4858%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4859%
4860% DrawSetFontResolution() sets the image resolution.
4861%
4862% The format of the DrawSetFontResolution method is:
4863%
4864% MagickBooleanType DrawSetFontResolution(DrawingWand *wand,
4865% const double x_resolution,const double y_resolution)
4866%
4867% A description of each parameter follows:
4868%
4869% o wand: the magick wand.
4870%
4871% o x_resolution: the image x resolution.
4872%
4873% o y_resolution: the image y resolution.
4874%
4875*/
4876WandExport MagickBooleanType DrawSetFontResolution(DrawingWand *wand,
4877 const double x_resolution,const double y_resolution)
4878{
4879 char
4880 density[MagickPathExtent];
4881
4882 assert(wand != (DrawingWand *) NULL);
4883 assert(wand->signature == MagickWandSignature);
4884 if (wand->debug != MagickFalse)
4885 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4886 (void) FormatLocaleString(density,MagickPathExtent,"%.17gx%.17g",x_resolution,
4887 y_resolution);
4888 (void) CloneString(&CurrentContext->density,density);
4889 return(MagickTrue);
4890}
4891␌
4892/*
4893%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4894% %
4895% %
4896% %
4897% D r a w S e t O p a c i t y %
4898% %
4899% %
4900% %
4901%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4902%
4903% DrawSetOpacity() sets the alpha to use when drawing using the fill or
4904% stroke color or texture. Fully opaque is 1.0.
4905%
4906% The format of the DrawSetOpacity method is:
4907%
4908% void DrawSetOpacity(DrawingWand *wand,const double alpha)
4909%
4910% A description of each parameter follows:
4911%
4912% o wand: the drawing wand.
4913%
4914% o opacity: fill and stroke opacity. The value 1.0 is opaque.
4915%
4916*/
4917WandExport void DrawSetOpacity(DrawingWand *wand,const double opacity)
4918{
4919 Quantum
4920 quantum_alpha;
4921
4922 assert(wand != (DrawingWand *) NULL);
4923 assert(wand->signature == MagickWandSignature);
4924 if (wand->debug != MagickFalse)
4925 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
4926 quantum_alpha=ClampToQuantum((double) QuantumRange*opacity);
4927 if ((wand->filter_off != MagickFalse) ||
4928 (CurrentContext->alpha != quantum_alpha))
4929 {
4930 CurrentContext->alpha=quantum_alpha;
4931 (void) MVGPrintf(wand,"opacity %.17g\n",opacity);
4932 }
4933}
4934␌
4935/*
4936%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4937% %
4938% %
4939% %
4940% D r a w S e t F i l l P a t t e r n U R L %
4941% %
4942% %
4943% %
4944%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4945%
4946% DrawSetFillPatternURL() sets the URL to use as a fill pattern for filling
4947% objects. Only local URLs ("#identifier") are supported at this time. These
4948% local URLs are normally created by defining a named fill pattern with
4949% DrawPushPattern/DrawPopPattern.
4950%
4951% The format of the DrawSetFillPatternURL method is:
4952%
4953% MagickBooleanType DrawSetFillPatternURL(DrawingWand *wand,
4954% const char *fill_url)
4955%
4956% A description of each parameter follows:
4957%
4958% o wand: the drawing wand.
4959%
4960% o fill_url: URL to use to obtain fill pattern.
4961%
4962*/
4963WandExport MagickBooleanType DrawSetFillPatternURL(DrawingWand *wand,
4964 const char *fill_url)
4965{
4966 char
4967 pattern[MagickPathExtent],
4968 pattern_spec[MagickPathExtent];
4969
4970 assert(wand != (DrawingWand *) NULL);
4971 assert(wand->signature == MagickWandSignature);
4972 if (wand->debug != MagickFalse)
4973 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",fill_url);
4974 if (wand->image == (Image *) NULL)
4975 {
4976 ThrowDrawException(WandError,"ContainsNoImages",wand->name);
4977 return(MagickFalse);
4978 }
4979 assert(fill_url != (const char *) NULL);
4980 if (*fill_url != '#')
4981 {
4982 ThrowDrawException(DrawError,"NotARelativeURL",fill_url);
4983 return(MagickFalse);
4984 }
4985 (void) FormatLocaleString(pattern,MagickPathExtent,"%s",fill_url+1);
4986 if (GetImageArtifact(wand->image,pattern) == (const char *) NULL)
4987 {
4988 ThrowDrawException(DrawError,"URLNotFound",fill_url)
4989 return(MagickFalse);
4990 }
4991 (void) FormatLocaleString(pattern_spec,MagickPathExtent,"url(%s)",fill_url);
4992#if DRAW_BINARY_IMPLEMENTATION
4993 DrawPatternPath(wand->image,CurrentContext,pattern_spec,
4994 &CurrentContext->fill_pattern,wand->exception);
4995#endif
4996 if (CurrentContext->fill.alpha != (double) TransparentAlpha)
4997 CurrentContext->fill.alpha=(double) CurrentContext->alpha;
4998 (void) MVGPrintf(wand,"fill %s\n",pattern_spec);
4999 return(MagickTrue);
5000}
5001␌
5002/*
5003%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5004% %
5005% %
5006% %
5007% D r a w S e t F i l l R u l e %
5008% %
5009% %
5010% %
5011%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5012%
5013% DrawSetFillRule() sets the fill rule to use while drawing polygons.
5014%
5015% The format of the DrawSetFillRule method is:
5016%
5017% void DrawSetFillRule(DrawingWand *wand,const FillRule fill_rule)
5018%
5019% A description of each parameter follows:
5020%
5021% o wand: the drawing wand.
5022%
5023% o fill_rule: fill rule (EvenOddRule or NonZeroRule)
5024%
5025*/
5026WandExport void DrawSetFillRule(DrawingWand *wand,const FillRule fill_rule)
5027{
5028 assert(wand != (DrawingWand *) NULL);
5029 assert(wand->signature == MagickWandSignature);
5030 if (wand->debug != MagickFalse)
5031 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5032 if ((wand->filter_off != MagickFalse) ||
5033 (CurrentContext->fill_rule != fill_rule))
5034 {
5035 CurrentContext->fill_rule=fill_rule;
5036 (void) MVGPrintf(wand, "fill-rule '%s'\n",CommandOptionToMnemonic(
5037 MagickFillRuleOptions,(ssize_t) fill_rule));
5038 }
5039}
5040␌
5041/*
5042%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5043% %
5044% %
5045% %
5046% D r a w S e t F o n t %
5047% %
5048% %
5049% %
5050%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5051%
5052% DrawSetFont() sets the fully-specified font to use when annotating with
5053% text.
5054%
5055% The format of the DrawSetFont method is:
5056%
5057% MagickBooleanType DrawSetFont(DrawingWand *wand,const char *font_name)
5058%
5059% A description of each parameter follows:
5060%
5061% o wand: the drawing wand.
5062%
5063% o font_name: font name
5064%
5065*/
5066WandExport MagickBooleanType DrawSetFont(DrawingWand *wand,
5067 const char *font_name)
5068{
5069 assert(wand != (DrawingWand *) NULL);
5070 assert(wand->signature == MagickWandSignature);
5071 if (wand->debug != MagickFalse)
5072 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5073 assert(font_name != (const char *) NULL);
5074 if ((wand->filter_off != MagickFalse) ||
5075 (CurrentContext->font == (char *) NULL) ||
5076 (LocaleCompare(CurrentContext->font,font_name) != 0))
5077 {
5078 (void) CloneString(&CurrentContext->font,font_name);
5079 (void) MVGPrintf(wand,"font '%s'\n",font_name);
5080 }
5081 return(MagickTrue);
5082}
5083␌
5084/*
5085%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5086% %
5087% %
5088% %
5089% D r a w S e t F o n t F a m i l y %
5090% %
5091% %
5092% %
5093%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5094%
5095% DrawSetFontFamily() sets the font family to use when annotating with text.
5096%
5097% The format of the DrawSetFontFamily method is:
5098%
5099% MagickBooleanType DrawSetFontFamily(DrawingWand *wand,
5100% const char *font_family)
5101%
5102% A description of each parameter follows:
5103%
5104% o wand: the drawing wand.
5105%
5106% o font_family: font family
5107%
5108*/
5109WandExport MagickBooleanType DrawSetFontFamily(DrawingWand *wand,
5110 const char *font_family)
5111{
5112 assert(wand != (DrawingWand *) NULL);
5113 assert(wand->signature == MagickWandSignature);
5114 if (wand->debug != MagickFalse)
5115 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5116 assert(font_family != (const char *) NULL);
5117 if ((wand->filter_off != MagickFalse) ||
5118 (CurrentContext->family == (const char *) NULL) ||
5119 (LocaleCompare(CurrentContext->family,font_family) != 0))
5120 {
5121 (void) CloneString(&CurrentContext->family,font_family);
5122 (void) MVGPrintf(wand,"font-family '%s'\n",font_family);
5123 }
5124 return(MagickTrue);
5125}
5126␌
5127/*
5128%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5129% %
5130% %
5131% %
5132% D r a w S e t F o n t S i z e %
5133% %
5134% %
5135% %
5136%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5137%
5138% DrawSetFontSize() sets the font pointsize to use when annotating with text.
5139%
5140% The format of the DrawSetFontSize method is:
5141%
5142% void DrawSetFontSize(DrawingWand *wand,const double pointsize)
5143%
5144% A description of each parameter follows:
5145%
5146% o wand: the drawing wand.
5147%
5148% o pointsize: text pointsize
5149%
5150*/
5151WandExport void DrawSetFontSize(DrawingWand *wand,const double pointsize)
5152{
5153 assert(wand != (DrawingWand *) NULL);
5154 assert(wand->signature == MagickWandSignature);
5155 if (wand->debug != MagickFalse)
5156 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5157 if ((wand->filter_off != MagickFalse) ||
5158 (fabs(CurrentContext->pointsize-pointsize) >= MagickEpsilon))
5159 {
5160 CurrentContext->pointsize=pointsize;
5161 (void) MVGPrintf(wand,"font-size %.17g\n",pointsize);
5162 }
5163}
5164␌
5165/*
5166%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5167% %
5168% %
5169% %
5170% D r a w S e t F o n t S t r e t c h %
5171% %
5172% %
5173% %
5174%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5175%
5176% DrawSetFontStretch() sets the font stretch to use when annotating with text.
5177% The AnyStretch enumeration acts as a wild-card "don't care" option.
5178%
5179% The format of the DrawSetFontStretch method is:
5180%
5181% void DrawSetFontStretch(DrawingWand *wand,
5182% const StretchType font_stretch)
5183%
5184% A description of each parameter follows:
5185%
5186% o wand: the drawing wand.
5187%
5188% o font_stretch: font stretch (NormalStretch, UltraCondensedStretch,
5189% CondensedStretch, SemiCondensedStretch,
5190% SemiExpandedStretch, ExpandedStretch,
5191% ExtraExpandedStretch, UltraExpandedStretch, AnyStretch)
5192%
5193*/
5194WandExport void DrawSetFontStretch(DrawingWand *wand,
5195 const StretchType font_stretch)
5196{
5197 assert(wand != (DrawingWand *) NULL);
5198 assert(wand->signature == MagickWandSignature);
5199 if (wand->debug != MagickFalse)
5200 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5201 if ((wand->filter_off != MagickFalse) ||
5202 (CurrentContext->stretch != font_stretch))
5203 {
5204 CurrentContext->stretch=font_stretch;
5205 (void) MVGPrintf(wand, "font-stretch '%s'\n",CommandOptionToMnemonic(
5206 MagickStretchOptions,(ssize_t) font_stretch));
5207 }
5208}
5209␌
5210/*
5211%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5212% %
5213% %
5214% %
5215% D r a w S e t F o n t S t y l e %
5216% %
5217% %
5218% %
5219%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5220%
5221% DrawSetFontStyle() sets the font style to use when annotating with text.
5222% The AnyStyle enumeration acts as a wild-card "don't care" option.
5223%
5224% The format of the DrawSetFontStyle method is:
5225%
5226% void DrawSetFontStyle(DrawingWand *wand,const StyleType style)
5227%
5228% A description of each parameter follows:
5229%
5230% o wand: the drawing wand.
5231%
5232% o style: font style (NormalStyle, ItalicStyle, ObliqueStyle, AnyStyle)
5233%
5234*/
5235WandExport void DrawSetFontStyle(DrawingWand *wand,const StyleType style)
5236{
5237 assert(wand != (DrawingWand *) NULL);
5238 assert(wand->signature == MagickWandSignature);
5239 if (wand->debug != MagickFalse)
5240 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5241 if ((wand->filter_off != MagickFalse) ||
5242 (CurrentContext->style != style))
5243 {
5244 CurrentContext->style=style;
5245 (void) MVGPrintf(wand, "font-style '%s'\n",CommandOptionToMnemonic(
5246 MagickStyleOptions,(ssize_t) style));
5247 }
5248}
5249␌
5250/*
5251%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5252% %
5253% %
5254% %
5255% D r a w S e t F o n t W e i g h t %
5256% %
5257% %
5258% %
5259%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5260%
5261% DrawSetFontWeight() sets the font weight to use when annotating with text.
5262%
5263% The format of the DrawSetFontWeight method is:
5264%
5265% void DrawSetFontWeight(DrawingWand *wand,
5266% const size_t font_weight)
5267%
5268% A description of each parameter follows:
5269%
5270% o wand: the drawing wand.
5271%
5272% o font_weight: font weight (valid range 100-900)
5273%
5274*/
5275WandExport void DrawSetFontWeight(DrawingWand *wand,
5276 const size_t font_weight)
5277{
5278 assert(wand != (DrawingWand *) NULL);
5279 assert(wand->signature == MagickWandSignature);
5280 if (wand->debug != MagickFalse)
5281 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5282 if ((wand->filter_off != MagickFalse) ||
5283 (CurrentContext->weight != font_weight))
5284 {
5285 CurrentContext->weight=font_weight;
5286 (void) MVGPrintf(wand,"font-weight %.17g\n",(double) font_weight);
5287 }
5288}
5289␌
5290/*
5291%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5292% %
5293% %
5294% %
5295% D r a w S e t G r a v i t y %
5296% %
5297% %
5298% %
5299%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5300%
5301% DrawSetGravity() sets the text placement gravity to use when annotating
5302% with text.
5303%
5304% The format of the DrawSetGravity method is:
5305%
5306% void DrawSetGravity(DrawingWand *wand,const GravityType gravity)
5307%
5308% A description of each parameter follows:
5309%
5310% o wand: the drawing wand.
5311%
5312% o gravity: positioning gravity (NorthWestGravity, NorthGravity,
5313% NorthEastGravity, WestGravity, CenterGravity,
5314% EastGravity, SouthWestGravity, SouthGravity,
5315% SouthEastGravity)
5316%
5317*/
5318WandExport void DrawSetGravity(DrawingWand *wand,const GravityType gravity)
5319{
5320 assert(wand != (DrawingWand *) NULL);
5321 assert(wand->signature == MagickWandSignature);
5322 if (wand->debug != MagickFalse)
5323 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5324 if ((wand->filter_off != MagickFalse) ||
5325 (CurrentContext->gravity != gravity) || (gravity != ForgetGravity))
5326 {
5327 CurrentContext->gravity=gravity;
5328 (void) MVGPrintf(wand,"gravity '%s'\n",CommandOptionToMnemonic(
5329 MagickGravityOptions,(ssize_t) gravity));
5330 }
5331}
5332␌
5333/*
5334%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5335% %
5336% %
5337% %
5338% D r a w S e t S t r o k e C o l o r %
5339% %
5340% %
5341% %
5342%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5343%
5344% DrawSetStrokeColor() sets the color used for stroking object outlines.
5345%
5346% The format of the DrawSetStrokeColor method is:
5347%
5348% void DrawSetStrokeColor(DrawingWand *wand,
5349% const PixelWand *stroke_wand)
5350%
5351% A description of each parameter follows:
5352%
5353% o wand: the drawing wand.
5354%
5355% o stroke_wand: stroke wand.
5356%
5357*/
5358WandExport void DrawSetStrokeColor(DrawingWand *wand,
5359 const PixelWand *stroke_wand)
5360{
5361 PixelInfo
5362 *current_stroke,
5363 new_stroke,
5364 stroke_color;
5365
5366 assert(wand != (DrawingWand *) NULL);
5367 assert(wand->signature == MagickWandSignature);
5368 if (wand->debug != MagickFalse)
5369 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5370 assert(stroke_wand != (const PixelWand *) NULL);
5371 PixelGetQuantumPacket(stroke_wand,&stroke_color);
5372 new_stroke=stroke_color;
5373 current_stroke=(&CurrentContext->stroke);
5374 if ((wand->filter_off != MagickFalse) ||
5375 (IsPixelInfoEquivalent(current_stroke,&new_stroke) == MagickFalse))
5376 {
5377 CurrentContext->stroke=new_stroke;
5378 (void) MVGPrintf(wand,"stroke '");
5379 MVGAppendColor(wand,&stroke_color);
5380 (void) MVGPrintf(wand,"'\n");
5381 }
5382}
5383␌
5384/*
5385%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5386% %
5387% %
5388% %
5389% D r a w S e t S t r o k e P a t t e r n U R L %
5390% %
5391% %
5392% %
5393%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5394%
5395% DrawSetStrokePatternURL() sets the pattern used for stroking object outlines.
5396%
5397% The format of the DrawSetStrokePatternURL method is:
5398%
5399% MagickBooleanType DrawSetStrokePatternURL(DrawingWand *wand,
5400% const char *stroke_url)
5401%
5402% A description of each parameter follows:
5403%
5404% o wand: the drawing wand.
5405%
5406% o stroke_url: URL specifying pattern ID (e.g. "#pattern_id")
5407%
5408*/
5409WandExport MagickBooleanType DrawSetStrokePatternURL(DrawingWand *wand,
5410 const char *stroke_url)
5411{
5412 char
5413 pattern[MagickPathExtent],
5414 pattern_spec[MagickPathExtent];
5415
5416 assert(wand != (DrawingWand *) NULL);
5417 assert(wand->signature == MagickWandSignature);
5418 if (wand->debug != MagickFalse)
5419 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5420 if (wand->image == (Image *) NULL)
5421 {
5422 ThrowDrawException(WandError,"ContainsNoImages",wand->name);
5423 return(MagickFalse);
5424 }
5425 assert(stroke_url != NULL);
5426 if (stroke_url[0] != '#')
5427 {
5428 ThrowDrawException(DrawError,"NotARelativeURL",stroke_url);
5429 return(MagickFalse);
5430 }
5431 (void) FormatLocaleString(pattern,MagickPathExtent,"%s",stroke_url+1);
5432 if (GetImageArtifact(wand->image,pattern) == (const char *) NULL)
5433 {
5434 ThrowDrawException(DrawError,"URLNotFound",stroke_url)
5435 return(MagickFalse);
5436 }
5437 (void) FormatLocaleString(pattern_spec,MagickPathExtent,"url(%s)",stroke_url);
5438#if DRAW_BINARY_IMPLEMENTATION
5439 DrawPatternPath(wand->image,CurrentContext,pattern_spec,
5440 &CurrentContext->stroke_pattern,wand->exception);
5441#endif
5442 if (CurrentContext->stroke.alpha != (double) TransparentAlpha)
5443 CurrentContext->stroke.alpha=(double) CurrentContext->alpha;
5444 (void) MVGPrintf(wand,"stroke %s\n",pattern_spec);
5445 return(MagickTrue);
5446}
5447␌
5448/*
5449%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5450% %
5451% %
5452% %
5453% D r a w S e t S t r o k e A n t i a l i a s %
5454% %
5455% %
5456% %
5457%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5458%
5459% DrawSetStrokeAntialias() controls whether stroked outlines are antialiased.
5460% Stroked outlines are antialiased by default. When antialiasing is disabled
5461% stroked pixels are thresholded to determine if the stroke color or
5462% underlying canvas color should be used.
5463%
5464% The format of the DrawSetStrokeAntialias method is:
5465%
5466% void DrawSetStrokeAntialias(DrawingWand *wand,
5467% const MagickBooleanType stroke_antialias)
5468%
5469% A description of each parameter follows:
5470%
5471% o wand: the drawing wand.
5472%
5473% o stroke_antialias: set to false (zero) to disable antialiasing
5474%
5475*/
5476WandExport void DrawSetStrokeAntialias(DrawingWand *wand,
5477 const MagickBooleanType stroke_antialias)
5478{
5479 assert(wand != (DrawingWand *) NULL);
5480 assert(wand->signature == MagickWandSignature);
5481 if (wand->debug != MagickFalse)
5482 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5483 if ((wand->filter_off != MagickFalse) ||
5484 (CurrentContext->stroke_antialias != stroke_antialias))
5485 {
5486 CurrentContext->stroke_antialias=stroke_antialias;
5487 (void) MVGPrintf(wand,"stroke-antialias %i\n",stroke_antialias != 0 ?
5488 1 : 0);
5489 }
5490}
5491␌
5492/*
5493%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5494% %
5495% %
5496% %
5497% D r a w S e t S t r o k e D a s h A r r a y %
5498% %
5499% %
5500% %
5501%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5502%
5503% DrawSetStrokeDashArray() specifies the pattern of dashes and gaps used to
5504% stroke paths. The stroke dash array represents an array of numbers that
5505% specify the lengths of alternating dashes and gaps in pixels. If an odd
5506% number of values is provided, then the list of values is repeated to yield
5507% an even number of values. To remove an existing dash array, pass a zero
5508% number_elements argument and null dasharray. A typical stroke dash array
5509% might contain the members 5 3 2.
5510%
5511% The format of the DrawSetStrokeDashArray method is:
5512%
5513% MagickBooleanType DrawSetStrokeDashArray(DrawingWand *wand,
5514% const size_t number_elements,const double *dasharray)
5515%
5516% A description of each parameter follows:
5517%
5518% o wand: the drawing wand.
5519%
5520% o number_elements: number of elements in dash array
5521%
5522% o dasharray: dash array values
5523%
5524*/
5525WandExport MagickBooleanType DrawSetStrokeDashArray(DrawingWand *wand,
5526 const size_t number_elements,const double *dasharray)
5527{
5528 MagickBooleanType
5529 update;
5530
5531 const double
5532 *p;
5533
5534 double
5535 *q;
5536
5537 ssize_t
5538 i;
5539
5540 size_t
5541 n_new,
5542 n_old;
5543
5544 assert(wand != (DrawingWand *) NULL);
5545 assert(wand->signature == MagickWandSignature);
5546 if (wand->debug != MagickFalse)
5547 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5548 n_new=number_elements;
5549 if (dasharray == (const double *) NULL)
5550 n_new=0;
5551 n_old=0;
5552 update=MagickFalse;
5553 q=CurrentContext->dash_pattern;
5554 if (q != (const double *) NULL)
5555 while (fabs(*q++) >= MagickEpsilon)
5556 n_old++;
5557 if ((n_old == 0) && (n_new == 0))
5558 update=MagickFalse;
5559 else
5560 if (n_old != n_new)
5561 update=MagickTrue;
5562 else
5563 if ((CurrentContext->dash_pattern != (double *) NULL) &&
5564 (dasharray != (double *) NULL))
5565 {
5566 p=dasharray;
5567 q=CurrentContext->dash_pattern;
5568 for (i=0; i < (ssize_t) n_new; i++)
5569 {
5570 if (fabs((*p)-(*q)) >= MagickEpsilon)
5571 {
5572 update=MagickTrue;
5573 break;
5574 }
5575 p++;
5576 q++;
5577 }
5578 }
5579 if ((wand->filter_off != MagickFalse) || (update != MagickFalse))
5580 {
5581 if (CurrentContext->dash_pattern != (double *) NULL)
5582 CurrentContext->dash_pattern=(double *)
5583 RelinquishMagickMemory(CurrentContext->dash_pattern);
5584 if (n_new != 0)
5585 {
5586 CurrentContext->dash_pattern=(double *) AcquireQuantumMemory((size_t)
5587 n_new+1UL,sizeof(*CurrentContext->dash_pattern));
5588 if (CurrentContext->dash_pattern == (double *) NULL)
5589 {
5590 ThrowDrawException(ResourceLimitError,"MemoryAllocationFailed",
5591 wand->name);
5592 return(MagickFalse);
5593 }
5594 for (i=0; i < (ssize_t) n_new; i++)
5595 {
5596 CurrentContext->dash_pattern[i]=0.0;
5597 if (dasharray != (double *) NULL)
5598 CurrentContext->dash_pattern[i]=dasharray[i];
5599 }
5600 CurrentContext->dash_pattern[n_new]=0.0;
5601 }
5602 (void) MVGPrintf(wand,"stroke-dasharray ");
5603 if (n_new == 0)
5604 (void) MVGPrintf(wand,"none\n");
5605 else
5606 if (dasharray != (double *) NULL)
5607 {
5608 for (i=0; i < (ssize_t) n_new; i++)
5609 {
5610 if (i != 0)
5611 (void) MVGPrintf(wand,",");
5612 (void) MVGPrintf(wand,"%.17g",dasharray[i]);
5613 }
5614 (void) MVGPrintf(wand,"\n");
5615 }
5616 }
5617 return(MagickTrue);
5618}
5619␌
5620/*
5621%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5622% %
5623% %
5624% %
5625% D r a w S e t S t r o k e D a s h O f f s e t %
5626% %
5627% %
5628% %
5629%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5630%
5631% DrawSetStrokeDashOffset() specifies the offset into the dash pattern to
5632% start the dash.
5633%
5634% The format of the DrawSetStrokeDashOffset method is:
5635%
5636% void DrawSetStrokeDashOffset(DrawingWand *wand,
5637% const double dash_offset)
5638%
5639% A description of each parameter follows:
5640%
5641% o wand: the drawing wand.
5642%
5643% o dash_offset: dash offset
5644%
5645*/
5646WandExport void DrawSetStrokeDashOffset(DrawingWand *wand,
5647 const double dash_offset)
5648{
5649 assert(wand != (DrawingWand *) NULL);
5650 assert(wand->signature == MagickWandSignature);
5651 if (wand->debug != MagickFalse)
5652 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5653 if ((wand->filter_off != MagickFalse) ||
5654 (fabs(CurrentContext->dash_offset-dash_offset) >= MagickEpsilon))
5655 {
5656 CurrentContext->dash_offset=dash_offset;
5657 (void) MVGPrintf(wand,"stroke-dashoffset %.17g\n",dash_offset);
5658 }
5659}
5660␌
5661/*
5662%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5663% %
5664% %
5665% %
5666% D r a w S e t S t r o k e L i n e C a p %
5667% %
5668% %
5669% %
5670%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5671%
5672% DrawSetStrokeLineCap() specifies the shape to be used at the end of
5673% open subpaths when they are stroked. Values of LineCap are
5674% UndefinedCap, ButtCap, RoundCap, and SquareCap.
5675%
5676% The format of the DrawSetStrokeLineCap method is:
5677%
5678% void DrawSetStrokeLineCap(DrawingWand *wand,
5679% const LineCap linecap)
5680%
5681% A description of each parameter follows:
5682%
5683% o wand: the drawing wand.
5684%
5685% o linecap: linecap style
5686%
5687*/
5688WandExport void DrawSetStrokeLineCap(DrawingWand *wand,const LineCap linecap)
5689{
5690 assert(wand != (DrawingWand *) NULL);
5691 assert(wand->signature == MagickWandSignature);
5692 if (wand->debug != MagickFalse)
5693 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5694 if ((wand->filter_off != MagickFalse) || (CurrentContext->linecap != linecap))
5695 {
5696 CurrentContext->linecap=linecap;
5697 (void) MVGPrintf(wand,"stroke-linecap '%s'\n",CommandOptionToMnemonic(
5698 MagickLineCapOptions,(ssize_t) linecap));
5699 }
5700}
5701␌
5702/*
5703%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5704% %
5705% %
5706% %
5707% D r a w S e t S t r o k e L i n e J o i n %
5708% %
5709% %
5710% %
5711%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5712%
5713% DrawSetStrokeLineJoin() specifies the shape to be used at the corners of
5714% paths (or other vector shapes) when they are stroked. Values of LineJoin are
5715% UndefinedJoin, MiterJoin, RoundJoin, and BevelJoin.
5716%
5717% The format of the DrawSetStrokeLineJoin method is:
5718%
5719% void DrawSetStrokeLineJoin(DrawingWand *wand,
5720% const LineJoin linejoin)
5721%
5722% A description of each parameter follows:
5723%
5724% o wand: the drawing wand.
5725%
5726% o linejoin: line join style
5727%
5728*/
5729WandExport void DrawSetStrokeLineJoin(DrawingWand *wand,const LineJoin linejoin)
5730{
5731 assert(wand != (DrawingWand *) NULL);
5732 assert(wand->signature == MagickWandSignature);
5733 if (wand->debug != MagickFalse)
5734 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5735 if ((wand->filter_off != MagickFalse) ||
5736 (CurrentContext->linejoin != linejoin))
5737 {
5738 CurrentContext->linejoin=linejoin;
5739 (void) MVGPrintf(wand, "stroke-linejoin '%s'\n",CommandOptionToMnemonic(
5740 MagickLineJoinOptions,(ssize_t) linejoin));
5741 }
5742}
5743␌
5744/*
5745%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5746% %
5747% %
5748% %
5749% D r a w S e t S t r o k e M i t e r L i m i t %
5750% %
5751% %
5752% %
5753%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5754%
5755% DrawSetStrokeMiterLimit() specifies the miter limit. When two line
5756% segments meet at a sharp angle and miter joins have been specified for
5757% 'lineJoin', it is possible for the miter to extend far beyond the
5758% thickness of the line stroking the path. The miterLimit' imposes a
5759% limit on the ratio of the miter length to the 'lineWidth'.
5760%
5761% The format of the DrawSetStrokeMiterLimit method is:
5762%
5763% void DrawSetStrokeMiterLimit(DrawingWand *wand,
5764% const size_t miterlimit)
5765%
5766% A description of each parameter follows:
5767%
5768% o wand: the drawing wand.
5769%
5770% o miterlimit: miter limit
5771%
5772*/
5773WandExport void DrawSetStrokeMiterLimit(DrawingWand *wand,
5774 const size_t miterlimit)
5775{
5776 assert(wand != (DrawingWand *) NULL);
5777 assert(wand->signature == MagickWandSignature);
5778 if (wand->debug != MagickFalse)
5779 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5780 if (CurrentContext->miterlimit != miterlimit)
5781 {
5782 CurrentContext->miterlimit=miterlimit;
5783 (void) MVGPrintf(wand,"stroke-miterlimit %.17g\n",(double) miterlimit);
5784 }
5785}
5786␌
5787/*
5788%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5789% %
5790% %
5791% %
5792% D r a w S e t S t r o k e O p a c i t y %
5793% %
5794% %
5795% %
5796%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5797%
5798% DrawSetStrokeOpacity() specifies the alpha of stroked object outlines.
5799%
5800% The format of the DrawSetStrokeOpacity method is:
5801%
5802% void DrawSetStrokeOpacity(DrawingWand *wand,
5803% const double stroke_alpha)
5804%
5805% A description of each parameter follows:
5806%
5807% o wand: the drawing wand.
5808%
5809% o opacity: stroke opacity. The value 1.0 is opaque.
5810%
5811*/
5812WandExport void DrawSetStrokeOpacity(DrawingWand *wand,
5813 const double opacity)
5814{
5815 double
5816 alpha;
5817
5818 assert(wand != (DrawingWand *) NULL);
5819 assert(wand->signature == MagickWandSignature);
5820 if (wand->debug != MagickFalse)
5821 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5822 alpha=(double) ClampToQuantum((double) QuantumRange*opacity);
5823 if ((wand->filter_off != MagickFalse) ||
5824 (CurrentContext->stroke.alpha != alpha))
5825 {
5826 CurrentContext->stroke.alpha=alpha;
5827 (void) MVGPrintf(wand,"stroke-opacity %.17g\n",opacity);
5828 }
5829}
5830␌
5831/*
5832%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5833% %
5834% %
5835% %
5836% D r a w S e t S t r o k e W i d t h %
5837% %
5838% %
5839% %
5840%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5841%
5842% DrawSetStrokeWidth() sets the width of the stroke used to draw object
5843% outlines.
5844%
5845% The format of the DrawSetStrokeWidth method is:
5846%
5847% void DrawSetStrokeWidth(DrawingWand *wand,
5848% const double stroke_width)
5849%
5850% A description of each parameter follows:
5851%
5852% o wand: the drawing wand.
5853%
5854% o stroke_width: stroke width
5855%
5856*/
5857WandExport void DrawSetStrokeWidth(DrawingWand *wand,const double stroke_width)
5858{
5859 assert(wand != (DrawingWand *) NULL);
5860 assert(wand->signature == MagickWandSignature);
5861 if (wand->debug != MagickFalse)
5862 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5863 if ((wand->filter_off != MagickFalse) ||
5864 (fabs(CurrentContext->stroke_width-stroke_width) >= MagickEpsilon))
5865 {
5866 CurrentContext->stroke_width=stroke_width;
5867 (void) MVGPrintf(wand,"stroke-width %.17g\n",stroke_width);
5868 }
5869}
5870␌
5871/*
5872%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5873% %
5874% %
5875% %
5876% D r a w S e t T e x t A l i g n m e n t %
5877% %
5878% %
5879% %
5880%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5881%
5882% DrawSetTextAlignment() specifies a text alignment to be applied when
5883% annotating with text.
5884%
5885% The format of the DrawSetTextAlignment method is:
5886%
5887% void DrawSetTextAlignment(DrawingWand *wand,const AlignType alignment)
5888%
5889% A description of each parameter follows:
5890%
5891% o wand: the drawing wand.
5892%
5893% o alignment: text alignment. One of UndefinedAlign, LeftAlign,
5894% CenterAlign, or RightAlign.
5895%
5896*/
5897WandExport void DrawSetTextAlignment(DrawingWand *wand,
5898 const AlignType alignment)
5899{
5900 assert(wand != (DrawingWand *) NULL);
5901 assert(wand->signature == MagickWandSignature);
5902 if (wand->debug != MagickFalse)
5903 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5904 if ((wand->filter_off != MagickFalse) ||
5905 (CurrentContext->align != alignment))
5906 {
5907 CurrentContext->align=alignment;
5908 (void) MVGPrintf(wand,"text-align '%s'\n",CommandOptionToMnemonic(
5909 MagickAlignOptions,(ssize_t) alignment));
5910 }
5911}
5912␌
5913/*
5914%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5915% %
5916% %
5917% %
5918% D r a w S e t T e x t A n t i a l i a s %
5919% %
5920% %
5921% %
5922%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5923%
5924% DrawSetTextAntialias() controls whether text is antialiased. Text is
5925% antialiased by default.
5926%
5927% The format of the DrawSetTextAntialias method is:
5928%
5929% void DrawSetTextAntialias(DrawingWand *wand,
5930% const MagickBooleanType text_antialias)
5931%
5932% A description of each parameter follows:
5933%
5934% o wand: the drawing wand.
5935%
5936% o text_antialias: antialias boolean. Set to false (0) to disable
5937% antialiasing.
5938%
5939*/
5940WandExport void DrawSetTextAntialias(DrawingWand *wand,
5941 const MagickBooleanType text_antialias)
5942{
5943 assert(wand != (DrawingWand *) NULL);
5944 assert(wand->signature == MagickWandSignature);
5945 if (wand->debug != MagickFalse)
5946 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5947 if ((wand->filter_off != MagickFalse) ||
5948 (CurrentContext->text_antialias != text_antialias))
5949 {
5950 CurrentContext->text_antialias=text_antialias;
5951 (void) MVGPrintf(wand,"text-antialias %i\n",text_antialias != 0 ? 1 : 0);
5952 }
5953}
5954␌
5955/*
5956%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5957% %
5958% %
5959% %
5960% D r a w S e t T e x t D e c o r a t i o n %
5961% %
5962% %
5963% %
5964%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5965%
5966% DrawSetTextDecoration() specifies a decoration to be applied when
5967% annotating with text.
5968%
5969% The format of the DrawSetTextDecoration method is:
5970%
5971% void DrawSetTextDecoration(DrawingWand *wand,
5972% const DecorationType decoration)
5973%
5974% A description of each parameter follows:
5975%
5976% o wand: the drawing wand.
5977%
5978% o decoration: text decoration. One of NoDecoration, UnderlineDecoration,
5979% OverlineDecoration, or LineThroughDecoration
5980%
5981*/
5982WandExport void DrawSetTextDecoration(DrawingWand *wand,
5983 const DecorationType decoration)
5984{
5985 assert(wand != (DrawingWand *) NULL);
5986 assert(wand->signature == MagickWandSignature);
5987 if (wand->debug != MagickFalse)
5988 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
5989 if ((wand->filter_off != MagickFalse) ||
5990 (CurrentContext->decorate != decoration))
5991 {
5992 CurrentContext->decorate=decoration;
5993 (void) MVGPrintf(wand,"decorate '%s'\n",CommandOptionToMnemonic(
5994 MagickDecorateOptions,(ssize_t) decoration));
5995 }
5996}
5997␌
5998/*
5999%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6000% %
6001% %
6002% %
6003% D r a w S e t T e x t D i r e c t i o n %
6004% %
6005% %
6006% %
6007%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6008%
6009% DrawSetTextDirection() specifies the direction to be used when
6010% annotating with text.
6011%
6012% The format of the DrawSetTextDirection method is:
6013%
6014% void DrawSetTextDirection(DrawingWand *wand,
6015% const DirectionType direction)
6016%
6017% A description of each parameter follows:
6018%
6019% o wand: the drawing wand.
6020%
6021% o direction: text direction. One of RightToLeftDirection,
6022% LeftToRightDirection
6023%
6024*/
6025WandExport void DrawSetTextDirection(DrawingWand *wand,
6026 const DirectionType direction)
6027{
6028 assert(wand != (DrawingWand *) NULL);
6029 assert(wand->signature == MagickWandSignature);
6030
6031 if (wand->debug != MagickFalse)
6032 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
6033 if ((wand->filter_off != MagickFalse) ||
6034 (CurrentContext->direction != direction))
6035 {
6036 CurrentContext->direction=direction;
6037 (void) MVGPrintf(wand,"direction '%s'\n",CommandOptionToMnemonic(
6038 MagickDirectionOptions,(ssize_t) direction));
6039 }
6040}
6041
6042/*
6043%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6044% %
6045% %
6046% %
6047% D r a w S e t T e x t E n c o d i n g %
6048% %
6049% %
6050% %
6051%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6052%
6053% DrawSetTextEncoding() specifies the code set to use for text
6054% annotations. The only character encoding which may be specified
6055% at this time is "UTF-8" for representing Unicode as a sequence of
6056% bytes. Specify an empty string to set text encoding to the system's
6057% default. Successful text annotation using Unicode may require fonts
6058% designed to support Unicode.
6059%
6060% The format of the DrawSetTextEncoding method is:
6061%
6062% void DrawSetTextEncoding(DrawingWand *wand,const char *encoding)
6063%
6064% A description of each parameter follows:
6065%
6066% o wand: the drawing wand.
6067%
6068% o encoding: character string specifying text encoding
6069%
6070*/
6071WandExport void DrawSetTextEncoding(DrawingWand *wand,const char *encoding)
6072{
6073 assert(wand != (DrawingWand *) NULL);
6074 assert(wand->signature == MagickWandSignature);
6075 if (wand->debug != MagickFalse)
6076 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
6077 assert(encoding != (char *) NULL);
6078 if ((wand->filter_off != MagickFalse) ||
6079 (CurrentContext->encoding == (char *) NULL) ||
6080 (LocaleCompare(CurrentContext->encoding,encoding) != 0))
6081 {
6082 (void) CloneString(&CurrentContext->encoding,encoding);
6083 (void) MVGPrintf(wand,"encoding '%s'\n",encoding);
6084 }
6085}
6086␌
6087/*
6088%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6089% %
6090% %
6091% %
6092% D r a w S e t T e x t K e r n i n g %
6093% %
6094% %
6095% %
6096%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6097%
6098% DrawSetTextKerning() sets the spacing between characters in text.
6099%
6100% The format of the DrawSetTextKerning method is:
6101%
6102% void DrawSetTextKerning(DrawingWand *wand,const double kerning)
6103%
6104% A description of each parameter follows:
6105%
6106% o wand: the drawing wand.
6107%
6108% o kerning: text kerning
6109%
6110*/
6111WandExport void DrawSetTextKerning(DrawingWand *wand,const double kerning)
6112{
6113 assert(wand != (DrawingWand *) NULL);
6114 assert(wand->signature == MagickWandSignature);
6115
6116 if (wand->debug != MagickFalse)
6117 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
6118 if ((wand->filter_off != MagickFalse) &&
6119 (fabs((CurrentContext->kerning-kerning)) >= MagickEpsilon))
6120 {
6121 CurrentContext->kerning=kerning;
6122 (void) MVGPrintf(wand,"kerning %lf\n",kerning);
6123 }
6124}
6125␌
6126/*
6127%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6128% %
6129% %
6130% %
6131% D r a w S e t T e x t I n t e r l i n e S p a c i n g %
6132% %
6133% %
6134% %
6135%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6136%
6137% DrawSetTextInterlineSpacing() sets the spacing between line in text.
6138%
6139% The format of the DrawSetInterlineSpacing method is:
6140%
6141% void DrawSetTextInterlineSpacing(DrawingWand *wand,
6142% const double interline_spacing)
6143%
6144% A description of each parameter follows:
6145%
6146% o wand: the drawing wand.
6147%
6148% o interline_spacing: text line spacing
6149%
6150*/
6151WandExport void DrawSetTextInterlineSpacing(DrawingWand *wand,
6152 const double interline_spacing)
6153{
6154 assert(wand != (DrawingWand *) NULL);
6155 assert(wand->signature == MagickWandSignature);
6156
6157 if (wand->debug != MagickFalse)
6158 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
6159 if ((wand->filter_off != MagickFalse) ||
6160 (fabs((CurrentContext->interline_spacing-
6161 interline_spacing)) >= MagickEpsilon))
6162 {
6163 CurrentContext->interline_spacing=interline_spacing;
6164 (void) MVGPrintf(wand,"interline-spacing %lf\n",interline_spacing);
6165 }
6166}
6167␌
6168/*
6169%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6170% %
6171% %
6172% %
6173% D r a w S e t T e x t I n t e r w o r d S p a c i n g %
6174% %
6175% %
6176% %
6177%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6178%
6179% DrawSetTextInterwordSpacing() sets the spacing between words in text.
6180%
6181% The format of the DrawSetInterwordSpacing method is:
6182%
6183% void DrawSetTextInterwordSpacing(DrawingWand *wand,
6184% const double interword_spacing)
6185%
6186% A description of each parameter follows:
6187%
6188% o wand: the drawing wand.
6189%
6190% o interword_spacing: text word spacing
6191%
6192*/
6193WandExport void DrawSetTextInterwordSpacing(DrawingWand *wand,
6194 const double interword_spacing)
6195{
6196 assert(wand != (DrawingWand *) NULL);
6197 assert(wand->signature == MagickWandSignature);
6198
6199 if (wand->debug != MagickFalse)
6200 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
6201 if ((wand->filter_off != MagickFalse) ||
6202 (fabs((CurrentContext->interword_spacing-
6203 interword_spacing)) >= MagickEpsilon))
6204 {
6205 CurrentContext->interword_spacing=interword_spacing;
6206 (void) MVGPrintf(wand,"interword-spacing %lf\n",interword_spacing);
6207 }
6208}
6209␌
6210/*
6211%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6212% %
6213% %
6214% %
6215% D r a w S e t T e x t U n d e r C o l o r %
6216% %
6217% %
6218% %
6219%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6220%
6221% DrawSetTextUnderColor() specifies the color of a background rectangle
6222% to place under text annotations.
6223%
6224% The format of the DrawSetTextUnderColor method is:
6225%
6226% void DrawSetTextUnderColor(DrawingWand *wand,
6227% const PixelWand *under_wand)
6228%
6229% A description of each parameter follows:
6230%
6231% o wand: the drawing wand.
6232%
6233% o under_wand: text under wand.
6234%
6235*/
6236WandExport void DrawSetTextUnderColor(DrawingWand *wand,
6237 const PixelWand *under_wand)
6238{
6239 PixelInfo
6240 under_color;
6241
6242 assert(wand != (DrawingWand *) NULL);
6243 assert(wand->signature == MagickWandSignature);
6244 if (wand->debug != MagickFalse)
6245 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
6246 assert(under_wand != (const PixelWand *) NULL);
6247 PixelGetQuantumPacket(under_wand,&under_color);
6248 if ((wand->filter_off != MagickFalse) ||
6249 (IsPixelInfoEquivalent(&CurrentContext->undercolor,&under_color) == MagickFalse))
6250 {
6251 CurrentContext->undercolor=under_color;
6252 (void) MVGPrintf(wand,"text-undercolor '");
6253 MVGAppendColor(wand,&under_color);
6254 (void) MVGPrintf(wand,"'\n");
6255 }
6256}
6257␌
6258/*
6259%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6260% %
6261% %
6262% %
6263% D r a w S e t V e c t o r G r a p h i c s %
6264% %
6265% %
6266% %
6267%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6268%
6269% DrawSetVectorGraphics() sets the vector graphics associated with the
6270% specified wand. Use this method with DrawGetVectorGraphics() as a method
6271% to persist the vector graphics state.
6272%
6273% The format of the DrawSetVectorGraphics method is:
6274%
6275% MagickBooleanType DrawSetVectorGraphics(DrawingWand *wand,
6276% const char *xml)
6277%
6278% A description of each parameter follows:
6279%
6280% o wand: the drawing wand.
6281%
6282% o xml: the drawing wand XML.
6283%
6284*/
6285
6286static inline MagickBooleanType IsPoint(const char *point)
6287{
6288 char
6289 *p;
6290
6291 long
6292 value;
6293
6294 value=strtol(point,&p,10);
6295 (void) value;
6296 return(p != point ? MagickTrue : MagickFalse);
6297}
6298
6299WandExport MagickBooleanType DrawSetVectorGraphics(DrawingWand *wand,
6300 const char *xml)
6301{
6302 const char
6303 *value;
6304
6305 XMLTreeInfo
6306 *child,
6307 *xml_info;
6308
6309 assert(wand != (DrawingWand *) NULL);
6310 assert(wand->signature == MagickWandSignature);
6311 if (wand->debug != MagickFalse)
6312 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
6313 CurrentContext=DestroyDrawInfo(CurrentContext);
6314 CurrentContext=CloneDrawInfo((ImageInfo *) NULL,(DrawInfo *) NULL);
6315 if (xml == (const char *) NULL)
6316 return(MagickFalse);
6317 xml_info=NewXMLTree(xml,wand->exception);
6318 if (xml_info == (XMLTreeInfo *) NULL)
6319 return(MagickFalse);
6320 child=GetXMLTreeChild(xml_info,"clip-path");
6321 if (child != (XMLTreeInfo *) NULL)
6322 (void) CloneString(&CurrentContext->clip_mask,GetXMLTreeContent(child));
6323 child=GetXMLTreeChild(xml_info,"clip-units");
6324 if (child != (XMLTreeInfo *) NULL)
6325 {
6326 value=GetXMLTreeContent(child);
6327 if (value != (const char *) NULL)
6328 CurrentContext->clip_units=(ClipPathUnits) ParseCommandOption(
6329 MagickClipPathOptions,MagickFalse,value);
6330 }
6331 child=GetXMLTreeChild(xml_info,"decorate");
6332 if (child != (XMLTreeInfo *) NULL)
6333 {
6334 value=GetXMLTreeContent(child);
6335 if (value != (const char *) NULL)
6336 CurrentContext->decorate=(DecorationType) ParseCommandOption(
6337 MagickDecorateOptions,MagickFalse,value);
6338 }
6339 child=GetXMLTreeChild(xml_info,"encoding");
6340 if (child != (XMLTreeInfo *) NULL)
6341 (void) CloneString(&CurrentContext->encoding,GetXMLTreeContent(child));
6342 child=GetXMLTreeChild(xml_info,"fill");
6343 if (child != (XMLTreeInfo *) NULL)
6344 {
6345 value=GetXMLTreeContent(child);
6346 if (value != (const char *) NULL)
6347 (void) QueryColorCompliance(value,AllCompliance,&CurrentContext->fill,
6348 wand->exception);
6349 }
6350 child=GetXMLTreeChild(xml_info,"fill-opacity");
6351 if (child != (XMLTreeInfo *) NULL)
6352 {
6353 value=GetXMLTreeContent(child);
6354 if (value != (const char *) NULL)
6355 CurrentContext->fill.alpha=(double) ClampToQuantum((double)
6356 QuantumRange*(1.0-StringToDouble(value,(char **) NULL)));
6357 }
6358 child=GetXMLTreeChild(xml_info,"fill-rule");
6359 if (child != (XMLTreeInfo *) NULL)
6360 {
6361 value=GetXMLTreeContent(child);
6362 if (value != (const char *) NULL)
6363 CurrentContext->fill_rule=(FillRule) ParseCommandOption(
6364 MagickFillRuleOptions,MagickFalse,value);
6365 }
6366 child=GetXMLTreeChild(xml_info,"font");
6367 if (child != (XMLTreeInfo *) NULL)
6368 (void) CloneString(&CurrentContext->font,GetXMLTreeContent(child));
6369 child=GetXMLTreeChild(xml_info,"font-family");
6370 if (child != (XMLTreeInfo *) NULL)
6371 (void) CloneString(&CurrentContext->family,GetXMLTreeContent(child));
6372 child=GetXMLTreeChild(xml_info,"font-size");
6373 if (child != (XMLTreeInfo *) NULL)
6374 {
6375 value=GetXMLTreeContent(child);
6376 if (value != (const char *) NULL)
6377 CurrentContext->pointsize=StringToDouble(value,(char **) NULL);
6378 }
6379 child=GetXMLTreeChild(xml_info,"font-stretch");
6380 if (child != (XMLTreeInfo *) NULL)
6381 {
6382 value=GetXMLTreeContent(child);
6383 if (value != (const char *) NULL)
6384 CurrentContext->stretch=(StretchType) ParseCommandOption(
6385 MagickStretchOptions,MagickFalse,value);
6386 }
6387 child=GetXMLTreeChild(xml_info,"font-style");
6388 if (child != (XMLTreeInfo *) NULL)
6389 {
6390 value=GetXMLTreeContent(child);
6391 if (value != (const char *) NULL)
6392 CurrentContext->style=(StyleType) ParseCommandOption(MagickStyleOptions,
6393 MagickFalse,value);
6394 }
6395 child=GetXMLTreeChild(xml_info,"font-weight");
6396 if (child != (XMLTreeInfo *) NULL)
6397 {
6398 value=GetXMLTreeContent(child);
6399 if (value != (const char *) NULL)
6400 {
6401 ssize_t
6402 weight;
6403
6404 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,value);
6405 if (weight == -1)
6406 weight=(ssize_t) StringToUnsignedLong(value);
6407 CurrentContext->weight=(size_t) weight;
6408 }
6409 }
6410 child=GetXMLTreeChild(xml_info,"gravity");
6411 if (child != (XMLTreeInfo *) NULL)
6412 {
6413 value=GetXMLTreeContent(child);
6414 if (value != (const char *) NULL)
6415 CurrentContext->gravity=(GravityType) ParseCommandOption(
6416 MagickGravityOptions,MagickFalse,value);
6417 }
6418 child=GetXMLTreeChild(xml_info,"stroke");
6419 if (child != (XMLTreeInfo *) NULL)
6420 {
6421 value=GetXMLTreeContent(child);
6422 if (value != (const char *) NULL)
6423 (void) QueryColorCompliance(value,AllCompliance,&CurrentContext->stroke,
6424 wand->exception);
6425 }
6426 child=GetXMLTreeChild(xml_info,"stroke-antialias");
6427 if (child != (XMLTreeInfo *) NULL)
6428 {
6429 value=GetXMLTreeContent(child);
6430 if (value != (const char *) NULL)
6431 CurrentContext->stroke_antialias=StringToLong(value) != 0 ? MagickTrue :
6432 MagickFalse;
6433 }
6434 child=GetXMLTreeChild(xml_info,"stroke-dasharray");
6435 if (child != (XMLTreeInfo *) NULL)
6436 {
6437 char
6438 token[MagickPathExtent];
6439
6440 const char
6441 *q;
6442
6443 ssize_t
6444 x;
6445
6446 ssize_t
6447 j;
6448
6449 value=GetXMLTreeContent(child);
6450 if (value != (const char *) NULL)
6451 {
6452 if (CurrentContext->dash_pattern != (double *) NULL)
6453 CurrentContext->dash_pattern=(double *) RelinquishMagickMemory(
6454 CurrentContext->dash_pattern);
6455 q=(char *) value;
6456 if (IsPoint(q) != MagickFalse)
6457 {
6458 const char
6459 *p;
6460
6461 p=q;
6462 (void) GetNextToken(p,&p,MagickPathExtent,token);
6463 if (*token == ',')
6464 (void) GetNextToken(p,&p,MagickPathExtent,token);
6465 for (x=0; IsPoint(token) != MagickFalse; x++)
6466 {
6467 (void) GetNextToken(p,&p,MagickPathExtent,token);
6468 if (*token == ',')
6469 (void) GetNextToken(p,&p,MagickPathExtent,token);
6470 }
6471 CurrentContext->dash_pattern=(double *) AcquireQuantumMemory(
6472 (size_t) (2*x)+1UL,sizeof(*CurrentContext->dash_pattern));
6473 if (CurrentContext->dash_pattern == (double *) NULL)
6474 ThrowWandFatalException(ResourceLimitFatalError,
6475 "MemoryAllocationFailed",wand->name);
6476 for (j=0; j < x; j++)
6477 {
6478 (void) GetNextToken(q,&q,MagickPathExtent,token);
6479 if (*token == ',')
6480 (void) GetNextToken(q,&q,MagickPathExtent,token);
6481 CurrentContext->dash_pattern[j]=StringToDouble(token,
6482 (char **) NULL);
6483 }
6484 if (((x & 0x01) != 0) && (j == x))
6485 for ( ; j < (2*x); j++)
6486 CurrentContext->dash_pattern[j]=
6487 CurrentContext->dash_pattern[j-x];
6488 CurrentContext->dash_pattern[j]=0.0;
6489 }
6490 }
6491 }
6492 child=GetXMLTreeChild(xml_info,"stroke-dashoffset");
6493 if (child != (XMLTreeInfo *) NULL)
6494 {
6495 value=GetXMLTreeContent(child);
6496 if (value != (const char *) NULL)
6497 CurrentContext->dash_offset=StringToDouble(value,(char **) NULL);
6498 }
6499 child=GetXMLTreeChild(xml_info,"stroke-linecap");
6500 if (child != (XMLTreeInfo *) NULL)
6501 {
6502 value=GetXMLTreeContent(child);
6503 if (value != (const char *) NULL)
6504 CurrentContext->linecap=(LineCap) ParseCommandOption(
6505 MagickLineCapOptions,MagickFalse,value);
6506 }
6507 child=GetXMLTreeChild(xml_info,"stroke-linejoin");
6508 if (child != (XMLTreeInfo *) NULL)
6509 {
6510 value=GetXMLTreeContent(child);
6511 if (value != (const char *) NULL)
6512 CurrentContext->linejoin=(LineJoin) ParseCommandOption(
6513 MagickLineJoinOptions,MagickFalse,value);
6514 }
6515 child=GetXMLTreeChild(xml_info,"stroke-miterlimit");
6516 if (child != (XMLTreeInfo *) NULL)
6517 {
6518 value=GetXMLTreeContent(child);
6519 if (value != (const char *) NULL)
6520 CurrentContext->miterlimit=StringToUnsignedLong(value);
6521 }
6522 child=GetXMLTreeChild(xml_info,"stroke-opacity");
6523 if (child != (XMLTreeInfo *) NULL)
6524 {
6525 value=GetXMLTreeContent(child);
6526 if (value != (const char *) NULL)
6527 CurrentContext->stroke.alpha=(double) ClampToQuantum((double)
6528 QuantumRange*(1.0-StringToDouble(value,(char **) NULL)));
6529 }
6530 child=GetXMLTreeChild(xml_info,"stroke-width");
6531 if (child != (XMLTreeInfo *) NULL)
6532 {
6533 value=GetXMLTreeContent(child);
6534 if (value != (const char *) NULL)
6535 {
6536 ssize_t
6537 weight;
6538
6539 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,value);
6540 if (weight == -1)
6541 weight=(ssize_t) StringToUnsignedLong(value);
6542 CurrentContext->stroke_width=(double) weight;
6543 }
6544 }
6545 child=GetXMLTreeChild(xml_info,"text-align");
6546 if (child != (XMLTreeInfo *) NULL)
6547 {
6548 value=GetXMLTreeContent(child);
6549 if (value != (const char *) NULL)
6550 CurrentContext->align=(AlignType) ParseCommandOption(MagickAlignOptions,
6551 MagickFalse,value);
6552 }
6553 child=GetXMLTreeChild(xml_info,"text-antialias");
6554 if (child != (XMLTreeInfo *) NULL)
6555 {
6556 value=GetXMLTreeContent(child);
6557 if (value != (const char *) NULL)
6558 CurrentContext->text_antialias=StringToLong(value) != 0 ? MagickTrue :
6559 MagickFalse;
6560 }
6561 child=GetXMLTreeChild(xml_info,"text-undercolor");
6562 if (child != (XMLTreeInfo *) NULL)
6563 {
6564 value=GetXMLTreeContent(child);
6565 if (value != (const char *) NULL)
6566 (void) QueryColorCompliance(value,AllCompliance,
6567 &CurrentContext->undercolor,wand->exception);
6568 }
6569 child=GetXMLTreeChild(xml_info,"vector-graphics");
6570 if (child != (XMLTreeInfo *) NULL)
6571 {
6572 (void) CloneString(&wand->mvg,GetXMLTreeContent(child));
6573 wand->mvg_length=strlen(wand->mvg);
6574 wand->mvg_alloc=wand->mvg_length+1;
6575 }
6576 xml_info=DestroyXMLTree(xml_info);
6577 return(MagickTrue);
6578}
6579␌
6580/*
6581%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6582% %
6583% %
6584% %
6585% D r a w S k e w X %
6586% %
6587% %
6588% %
6589%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6590%
6591% DrawSkewX() skews the current coordinate system in the horizontal
6592% direction.
6593%
6594% The format of the DrawSkewX method is:
6595%
6596% void DrawSkewX(DrawingWand *wand,const double degrees)
6597%
6598% A description of each parameter follows:
6599%
6600% o wand: the drawing wand.
6601%
6602% o degrees: number of degrees to skew the coordinates
6603%
6604*/
6605WandExport void DrawSkewX(DrawingWand *wand,const double degrees)
6606{
6607 assert(wand != (DrawingWand *) NULL);
6608 assert(wand->signature == MagickWandSignature);
6609 if (wand->debug != MagickFalse)
6610 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
6611 (void) MVGPrintf(wand,"skewX %.17g\n",degrees);
6612}
6613␌
6614/*
6615%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6616% %
6617% %
6618% %
6619% D r a w S k e w Y %
6620% %
6621% %
6622% %
6623%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6624%
6625% DrawSkewY() skews the current coordinate system in the vertical
6626% direction.
6627%
6628% The format of the DrawSkewY method is:
6629%
6630% void DrawSkewY(DrawingWand *wand,const double degrees)
6631%
6632% A description of each parameter follows:
6633%
6634% o wand: the drawing wand.
6635%
6636% o degrees: number of degrees to skew the coordinates
6637%
6638*/
6639WandExport void DrawSkewY(DrawingWand *wand,const double degrees)
6640{
6641 assert(wand != (DrawingWand *) NULL);
6642 assert(wand->signature == MagickWandSignature);
6643 if (wand->debug != MagickFalse)
6644 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
6645 (void) MVGPrintf(wand,"skewY %.17g\n",degrees);
6646}
6647␌
6648/*
6649%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6650% %
6651% %
6652% %
6653% D r a w T r a n s l a t e %
6654% %
6655% %
6656% %
6657%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6658%
6659% DrawTranslate() applies a translation to the current coordinate
6660% system which moves the coordinate system origin to the specified
6661% coordinate.
6662%
6663% The format of the DrawTranslate method is:
6664%
6665% void DrawTranslate(DrawingWand *wand,const double x,
6666% const double y)
6667%
6668% A description of each parameter follows:
6669%
6670% o wand: the drawing wand.
6671%
6672% o x: new x ordinate for coordinate system origin
6673%
6674% o y: new y ordinate for coordinate system origin
6675%
6676*/
6677WandExport void DrawTranslate(DrawingWand *wand,const double x,const double y)
6678{
6679 assert(wand != (DrawingWand *) NULL);
6680 assert(wand->signature == MagickWandSignature);
6681 if (wand->debug != MagickFalse)
6682 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
6683 (void) MVGPrintf(wand,"translate %.17g %.17g\n",x,y);
6684}
6685␌
6686/*
6687%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6688% %
6689% %
6690% %
6691% D r a w S e t V i e w b o x %
6692% %
6693% %
6694% %
6695%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6696%
6697% DrawSetViewbox() sets the overall canvas size to be recorded with the
6698% drawing vector data. Usually this will be specified using the same
6699% size as the canvas image. When the vector data is saved to SVG or MVG
6700% formats, the viewbox is use to specify the size of the canvas image that
6701% a viewer will render the vector data on.
6702%
6703% The format of the DrawSetViewbox method is:
6704%
6705% void DrawSetViewbox(DrawingWand *wand,const double x1,const double y1,
6706% const double x2,const double y2)
6707%
6708% A description of each parameter follows:
6709%
6710% o wand: the drawing wand.
6711%
6712% o x1: left x ordinate
6713%
6714% o y1: top y ordinate
6715%
6716% o x2: right x ordinate
6717%
6718% o y2: bottom y ordinate
6719%
6720*/
6721WandExport void DrawSetViewbox(DrawingWand *wand,const double x1,
6722 const double y1,const double x2,const double y2)
6723{
6724 assert(wand != (DrawingWand *) NULL);
6725 assert(wand->signature == MagickWandSignature);
6726 if (wand->debug != MagickFalse)
6727 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
6728 (void) MVGPrintf(wand,"viewbox %.17g %.17g %.17g %.17g\n",x1,y1,x2,y2);
6729}
6730␌
6731/*
6732%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6733% %
6734% %
6735% %
6736% I s D r a w i n g W a n d %
6737% %
6738% %
6739% %
6740%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6741%
6742% IsDrawingWand() returns MagickTrue if the wand is verified as a drawing wand.
6743%
6744% The format of the IsDrawingWand method is:
6745%
6746% MagickBooleanType IsDrawingWand(const DrawingWand *wand)
6747%
6748% A description of each parameter follows:
6749%
6750% o wand: the drawing wand.
6751%
6752*/
6753WandExport MagickBooleanType IsDrawingWand(const DrawingWand *wand)
6754{
6755 if (wand == (const DrawingWand *) NULL)
6756 return(MagickFalse);
6757 if (wand->signature != MagickWandSignature)
6758 return(MagickFalse);
6759 if (LocaleNCompare(wand->name,DrawingWandId,strlen(DrawingWandId)) != 0)
6760 return(MagickFalse);
6761 return(MagickTrue);
6762}
6763␌
6764/*
6765%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6766% %
6767% %
6768% %
6769% N e w D r a w i n g W a n d %
6770% %
6771% %
6772% %
6773%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6774%
6775% NewDrawingWand() returns a drawing wand required for all other methods in
6776% the API.
6777%
6778% The format of the NewDrawingWand method is:
6779%
6780% DrawingWand *NewDrawingWand(void)
6781%
6782*/
6783WandExport DrawingWand *NewDrawingWand(void)
6784{
6785 DrawingWand
6786 *wand;
6787
6788 CheckMagickCoreCompatibility();
6789 wand=(DrawingWand *) AcquireMagickMemory(sizeof(*wand));
6790 if (wand == (DrawingWand *) NULL)
6791 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
6792 (char *) NULL);
6793 (void) memset(wand,0,sizeof(*wand));
6794 wand->id=AcquireWandId();
6795 (void) FormatLocaleString(wand->name,MagickPathExtent,"%s-%.17g",
6796 DrawingWandId,(double) wand->id);
6797 if (wand->debug != MagickFalse)
6798 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
6799 wand->mvg=(char *) NULL;
6800 wand->mvg_alloc=0;
6801 wand->mvg_length=0;
6802 wand->mvg_width=0;
6803 wand->pattern_id=(char *) NULL;
6804 wand->pattern_offset=0;
6805 wand->pattern_bounds.x=0;
6806 wand->pattern_bounds.y=0;
6807 wand->pattern_bounds.width=0;
6808 wand->pattern_bounds.height=0;
6809 wand->index=0;
6810 wand->graphic_context=(DrawInfo **) AcquireMagickMemory(sizeof(
6811 *wand->graphic_context));
6812 if (wand->graphic_context == (DrawInfo **) NULL)
6813 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
6814 (char *) NULL);
6815 wand->filter_off=MagickTrue;
6816 wand->indent_depth=0;
6817 wand->path_operation=PathDefaultOperation;
6818 wand->path_mode=DefaultPathMode;
6819 wand->exception=AcquireExceptionInfo();
6820 wand->image=AcquireImage((const ImageInfo *) NULL,wand->exception);
6821 wand->destroy=MagickTrue;
6822 wand->debug=IsEventLogging();
6823 wand->signature=MagickWandSignature;
6824 CurrentContext=CloneDrawInfo((ImageInfo *) NULL,(DrawInfo *) NULL);
6825 return(wand);
6826}
6827␌
6828/*
6829%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6830% %
6831% %
6832% %
6833% P e e k D r a w i n g W a n d %
6834% %
6835% %
6836% %
6837%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6838%
6839% PeekDrawingWand() returns the current drawing wand.
6840%
6841% The format of the PeekDrawingWand method is:
6842%
6843% DrawInfo *PeekDrawingWand(const DrawingWand *wand)
6844%
6845% A description of each parameter follows:
6846%
6847% o wand: the drawing wand.
6848%
6849*/
6850WandExport DrawInfo *PeekDrawingWand(const DrawingWand *wand)
6851{
6852 DrawInfo
6853 *draw_info;
6854
6855 assert(wand != (const DrawingWand *) NULL);
6856 assert(wand->signature == MagickWandSignature);
6857 if (wand->debug != MagickFalse)
6858 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
6859 draw_info=CloneDrawInfo((ImageInfo *) NULL,CurrentContext);
6860 (void) CloneString(&draw_info->primitive,wand->mvg);
6861 return(draw_info);
6862}
6863␌
6864/*
6865%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6866% %
6867% %
6868% %
6869% P o p D r a w i n g W a n d %
6870% %
6871% %
6872% %
6873%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6874%
6875% PopDrawingWand() destroys the current drawing wand and returns to the
6876% previously pushed drawing wand. Multiple drawing wands may exist. It is an
6877% error to attempt to pop more drawing wands than have been pushed, and it is
6878% proper form to pop all drawing wands which have been pushed.
6879%
6880% The format of the PopDrawingWand method is:
6881%
6882% MagickBooleanType PopDrawingWand(DrawingWand *wand)
6883%
6884% A description of each parameter follows:
6885%
6886% o wand: the drawing wand.
6887%
6888*/
6889WandExport MagickBooleanType PopDrawingWand(DrawingWand *wand)
6890{
6891 assert(wand != (DrawingWand *) NULL);
6892 assert(wand->signature == MagickWandSignature);
6893 if (wand->debug != MagickFalse)
6894 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
6895 if (wand->index == 0)
6896 {
6897 ThrowDrawException(DrawError,"UnbalancedGraphicContextPushPop",wand->name)
6898 return(MagickFalse);
6899 }
6900 /*
6901 Destroy clip path if not same in preceding wand.
6902 */
6903#if DRAW_BINARY_IMPLEMENTATION
6904 if (wand->image == (Image *) NULL)
6905 {
6906 ThrowDrawException(WandError,"ContainsNoImages",wand->name);
6907 return(MagickFalse);
6908 }
6909 if (CurrentContext->clip_mask != (char *) NULL)
6910 if (LocaleCompare(CurrentContext->clip_mask,
6911 wand->graphic_context[wand->index-1]->clip_mask) != 0)
6912 (void) SetImageMask(wand->image,WritePixelMask,(Image *) NULL,
6913 wand->exception);
6914#endif
6915 CurrentContext=DestroyDrawInfo(CurrentContext);
6916 wand->index--;
6917 if (wand->indent_depth > 0)
6918 wand->indent_depth--;
6919 (void) MVGPrintf(wand,"pop graphic-context\n");
6920 return(MagickTrue);
6921}
6922␌
6923/*
6924%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6925% %
6926% %
6927% %
6928% P u s h D r a w i n g W a n d %
6929% %
6930% %
6931% %
6932%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6933%
6934% PushDrawingWand() clones the current drawing wand to create a new drawing
6935% wand. The original drawing wand(s) may be returned to by invoking
6936% PopDrawingWand(). The drawing wands are stored on a drawing wand stack.
6937% For every Pop there must have already been an equivalent Push.
6938%
6939% The format of the PushDrawingWand method is:
6940%
6941% MagickBooleanType PushDrawingWand(DrawingWand *wand)
6942%
6943% A description of each parameter follows:
6944%
6945% o wand: the drawing wand.
6946%
6947*/
6948WandExport MagickBooleanType PushDrawingWand(DrawingWand *wand)
6949{
6950 assert(wand != (DrawingWand *) NULL);
6951 assert(wand->signature == MagickWandSignature);
6952 if (wand->debug != MagickFalse)
6953 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
6954 wand->index++;
6955 wand->graphic_context=(DrawInfo **) ResizeQuantumMemory(wand->graphic_context,
6956 (size_t) wand->index+1UL,sizeof(*wand->graphic_context));
6957 if (wand->graphic_context == (DrawInfo **) NULL)
6958 {
6959 wand->index--;
6960 ThrowDrawException(ResourceLimitError,"MemoryAllocationFailed",
6961 wand->name);
6962 return(MagickFalse);
6963 }
6964 CurrentContext=CloneDrawInfo((ImageInfo *) NULL,
6965 wand->graphic_context[wand->index-1]);
6966 (void) MVGPrintf(wand,"push graphic-context\n");
6967 wand->indent_depth++;
6968 return(MagickTrue);
6969}