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"
59#define DRAW_BINARY_IMPLEMENTATION 0
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);
74 PathCurveToQuadraticBezierOperation,
75 PathCurveToQuadraticBezierSmoothOperation,
76 PathCurveToSmoothOperation,
77 PathEllipticArcOperation,
78 PathLineToHorizontalOperation,
80 PathLineToVerticalOperation,
97 name[MagickPathExtent];
160 MVGPrintf(
DrawingWand *,
const char *,...) wand_attribute((format
162 MVGAutoWrapPrintf(
DrawingWand *,const
char *,...) wand_attribute((format
171static
int MVGPrintf(
DrawingWand *wand,const
char *format,...)
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)
183 wand->mvg=(
char *) AcquireQuantumMemory(extent,
sizeof(*wand->mvg));
184 if (wand->mvg == (
char *) NULL)
186 ThrowDrawException(ResourceLimitError,
"MemoryAllocationFailed",
190 wand->mvg_alloc=extent;
193 if (wand->mvg_alloc < (wand->mvg_length+10*MagickPathExtent))
195 extent+=wand->mvg_alloc;
196 wand->mvg=(
char *) ResizeQuantumMemory(wand->mvg,extent,
198 if (wand->mvg == (
char *) NULL)
200 ThrowDrawException(ResourceLimitError,
"MemoryAllocationFailed",
204 wand->mvg_alloc=extent;
216 while (wand->mvg_width < wand->indent_depth)
218 wand->mvg[wand->mvg_length]=
' ';
222 wand->mvg[wand->mvg_length]=
'\0';
224 offset=(ssize_t) (wand->mvg_alloc-wand->mvg_length-1);
227 va_start(argp,format);
228#if defined(MAGICKCORE_HAVE_VSNPRINTF)
229 count=vsnprintf(wand->mvg+wand->mvg_length,(
size_t) offset,format,argp);
231 count=vsprintf(wand->mvg+wand->mvg_length,format,argp);
235 if ((count < 0) || (count > (
int) offset))
236 ThrowDrawException(DrawError,
"UnableToPrint",format)
239 wand->mvg_length+=(size_t) count;
240 wand->mvg_width+=(size_t) count;
242 wand->mvg[wand->mvg_length]=
'\0';
243 if ((wand->mvg_length > 1) && (wand->mvg[wand->mvg_length-1] ==
'\n'))
245 assert((wand->mvg_length+1) < wand->mvg_alloc);
250static int MVGAutoWrapPrintf(
DrawingWand *wand,
const char *format,...)
253 buffer[MagickPathExtent];
261 va_start(argp,format);
262#if defined(MAGICKCORE_HAVE_VSNPRINTF)
263 count=vsnprintf(buffer,
sizeof(buffer)-1,format,argp);
265 count=vsprintf(buffer,format,argp);
268 buffer[
sizeof(buffer)-1]=
'\0';
270 ThrowDrawException(DrawError,
"UnableToPrint",format)
273 if (((wand->mvg_width+(
size_t) count) > 78) && (buffer[count-1] !=
'\n'))
274 (void) MVGPrintf(wand,
"\n");
275 (void) MVGPrintf(wand,
"%s",buffer);
280static void MVGAppendColor(
DrawingWand *wand,
const PixelInfo *packet)
282 if ((packet->red == 0) && (packet->green == 0) && (packet->blue == 0) &&
283 (packet->alpha == (Quantum) TransparentAlpha))
284 (void) MVGPrintf(wand,
"none");
288 tuple[MagickPathExtent];
290 GetColorTuple(packet,packet->colorspace != sRGBColorspace ? MagickFalse :
292 (void) MVGPrintf(wand,
"%s",tuple);
296static void MVGAppendPointsCommand(
DrawingWand *wand,
const char *command,
297 const size_t number_coordinates,
const PointInfo *coordinates)
305 (void) MVGPrintf(wand,
"%s",command);
306 for (i=number_coordinates, coordinate=coordinates; i != 0; i--)
308 (void) MVGAutoWrapPrintf(wand,
" %.20g %.20g",coordinate->x,coordinate->y);
311 (void) MVGPrintf(wand,
"\n");
314static void AdjustAffine(
DrawingWand *wand,
const AffineMatrix *affine)
317 assert(wand->signature == MagickWandSignature);
318 if (wand->debug != MagickFalse)
319 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
320 if ((affine->sx != 1.0) || (affine->rx != 0.0) || (affine->ry != 0.0) ||
321 (affine->sy != 1.0) || (affine->tx != 0.0) || (affine->ty != 0.0))
326 current=CurrentContext->affine;
327 CurrentContext->affine.sx=affine->sx*current.sx+affine->ry*current.rx;
328 CurrentContext->affine.rx=affine->rx*current.sx+affine->sy*current.rx;
329 CurrentContext->affine.ry=affine->sx*current.ry+affine->ry*current.sy;
330 CurrentContext->affine.sy=affine->rx*current.ry+affine->sy*current.sy;
331 CurrentContext->affine.tx=affine->sx*current.tx+affine->ry*current.ty+
333 CurrentContext->affine.ty=affine->rx*current.tx+affine->sy*current.ty+
363WandExport
DrawingWand *AcquireDrawingWand(
const DrawInfo *draw_info,
369 wand=NewDrawingWand();
370 if (draw_info != (
const DrawInfo *) NULL)
372 CurrentContext=DestroyDrawInfo(CurrentContext);
373 CurrentContext=CloneDrawInfo((ImageInfo *) NULL,draw_info);
375 wand->image=DestroyImage(wand->image);
376 if (image != (Image *) NULL)
377 wand->destroy=MagickFalse;
407 assert(wand->signature == MagickWandSignature);
408 if (wand->debug != MagickFalse)
409 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
410 for ( ; wand->index > 0; wand->index--)
411 CurrentContext=DestroyDrawInfo(CurrentContext);
412 CurrentContext=DestroyDrawInfo(CurrentContext);
413 wand->graphic_context=(DrawInfo **) RelinquishMagickMemory(
414 wand->graphic_context);
415 if (wand->pattern_id != (
char *) NULL)
416 wand->pattern_id=DestroyString(wand->pattern_id);
417 wand->mvg=DestroyString(wand->mvg);
418 if ((wand->destroy != MagickFalse) && (wand->image != (Image *) NULL))
419 wand->image=DestroyImage(wand->image);
421 wand->image=(Image *) NULL;
422 wand->mvg=(
char *) NULL;
426 wand->pattern_id=(
char *) NULL;
427 wand->pattern_offset=0;
428 wand->pattern_bounds.x=0;
429 wand->pattern_bounds.y=0;
430 wand->pattern_bounds.width=0;
431 wand->pattern_bounds.height=0;
433 wand->graphic_context=(DrawInfo **) AcquireQuantumMemory(1,
434 sizeof(*wand->graphic_context));
435 if (wand->graphic_context == (DrawInfo **) NULL)
437 ThrowDrawException(ResourceLimitError,
"MemoryAllocationFailed",
441 CurrentContext=CloneDrawInfo((ImageInfo *) NULL,(DrawInfo *) NULL);
442 wand->filter_off=MagickTrue;
443 wand->indent_depth=0;
444 wand->path_operation=PathDefaultOperation;
445 wand->path_mode=DefaultPathMode;
446 wand->image=AcquireImage((
const ImageInfo *) NULL,wand->exception);
447 ClearMagickException(wand->exception);
448 wand->destroy=MagickTrue;
449 wand->debug=IsEventLogging();
483 assert(wand->signature == MagickWandSignature);
484 if (wand->debug != MagickFalse)
485 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
486 clone_wand=(
DrawingWand *) AcquireMagickMemory(
sizeof(*clone_wand));
488 ThrowWandFatalException(ResourceLimitFatalError,
489 "MemoryAllocationFailed",GetExceptionMessage(errno));
490 (void) memset(clone_wand,0,
sizeof(*clone_wand));
491 clone_wand->id=AcquireWandId();
492 (void) FormatLocaleString(clone_wand->name,MagickPathExtent,
493 "DrawingWand-%.20g",(
double) clone_wand->id);
494 clone_wand->exception=AcquireExceptionInfo();
495 InheritException(clone_wand->exception,wand->exception);
496 clone_wand->mvg=AcquireString(wand->mvg);
497 clone_wand->mvg_length=strlen(clone_wand->mvg);
498 clone_wand->mvg_alloc=wand->mvg_length+1;
499 clone_wand->mvg_width=wand->mvg_width;
500 clone_wand->pattern_id=AcquireString(wand->pattern_id);
501 clone_wand->pattern_offset=wand->pattern_offset;
502 clone_wand->pattern_bounds=wand->pattern_bounds;
503 clone_wand->index=wand->index;
504 clone_wand->graphic_context=(DrawInfo **) AcquireQuantumMemory((
size_t)
505 wand->index+1UL,
sizeof(*wand->graphic_context));
506 if (clone_wand->graphic_context == (DrawInfo **) NULL)
507 ThrowWandFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
508 GetExceptionMessage(errno));
509 for (i=0; i <= (ssize_t) wand->index; i++)
510 clone_wand->graphic_context[i]=CloneDrawInfo((ImageInfo *) NULL,
511 wand->graphic_context[i]);
512 clone_wand->filter_off=wand->filter_off;
513 clone_wand->indent_depth=wand->indent_depth;
514 clone_wand->path_operation=wand->path_operation;
515 clone_wand->path_mode=wand->path_mode;
516 clone_wand->image=wand->image;
517 if (wand->image != (Image *) NULL)
518 clone_wand->image=CloneImage(wand->image,0,0,MagickTrue,
519 clone_wand->exception);
520 clone_wand->destroy=MagickTrue;
521 clone_wand->debug=IsEventLogging();
522 if (clone_wand->debug != MagickFalse)
523 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",clone_wand->name);
524 clone_wand->signature=MagickWandSignature;
555 assert(wand->signature == MagickWandSignature);
556 if (wand->debug != MagickFalse)
557 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
558 for ( ; wand->index > 0; wand->index--)
559 CurrentContext=DestroyDrawInfo(CurrentContext);
560 CurrentContext=DestroyDrawInfo(CurrentContext);
561 wand->graphic_context=(DrawInfo **) RelinquishMagickMemory(
562 wand->graphic_context);
563 if (wand->pattern_id != (
char *) NULL)
564 wand->pattern_id=DestroyString(wand->pattern_id);
565 wand->mvg=DestroyString(wand->mvg);
566 if ((wand->destroy != MagickFalse) && (wand->image != (Image *) NULL))
567 wand->image=DestroyImage(wand->image);
568 wand->image=(Image *) NULL;
569 wand->exception=DestroyExceptionInfo(wand->exception);
570 wand->signature=(~MagickWandSignature);
571 RelinquishWandId(wand->id);
602WandExport
void DrawAffine(
DrawingWand *wand,
const AffineMatrix *affine)
605 assert(wand->signature == MagickWandSignature);
606 if (wand->debug != MagickFalse)
607 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
608 assert(affine != (
const AffineMatrix *) NULL);
609 AdjustAffine(wand,affine);
610 (void) MVGPrintf(wand,
"affine %.20g %.20g %.20g %.20g %.20g %.20g\n",
611 affine->sx,affine->rx,affine->ry,affine->sy,affine->tx,affine->ty);
651WandExport
void DrawAlpha(
DrawingWand *wand,
const double x,
const double y,
652 const PaintMethod paint_method)
655 assert(wand->signature == MagickWandSignature);
656 if (wand->debug != MagickFalse)
657 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
658 (void) MVGPrintf(wand,
"alpha %.20g %.20g '%s'\n",x,y,CommandOptionToMnemonic(
659 MagickMethodOptions,(ssize_t) paint_method));
691WandExport
void DrawAnnotation(
DrawingWand *wand,
const double x,
const double y,
692 const unsigned char *text)
698 assert(wand->signature == MagickWandSignature);
699 if (wand->debug != MagickFalse)
700 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
701 assert(text != (
const unsigned char *) NULL);
702 escaped_text=EscapeString((
const char *) text,
'\'');
703 if (escaped_text != (
char *) NULL)
705 (void) MVGPrintf(wand,
"text %.20g %.20g '%s'\n",x,y,escaped_text);
706 escaped_text=DestroyString(escaped_text);
746WandExport
void DrawArc(
DrawingWand *wand,
const double sx,
const double sy,
747 const double ex,
const double ey,
const double sd,
const double ed)
750 assert(wand->signature == MagickWandSignature);
751 if (wand->debug != MagickFalse)
752 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
753 (void) MVGPrintf(wand,
"arc %.20g %.20g %.20g %.20g %.20g %.20g\n",sx,sy,ex,
785 const size_t number_coordinates,
const PointInfo *coordinates)
788 assert(wand->signature == MagickWandSignature);
789 if (wand->debug != MagickFalse)
790 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
791 assert(coordinates != (
const PointInfo *) NULL);
792 MVGAppendPointsCommand(wand,
"bezier",number_coordinates,coordinates);
826WandExport
void DrawCircle(
DrawingWand *wand,
const double ox,
const double oy,
827 const double px,
const double py)
830 assert(wand->signature == MagickWandSignature);
831 if (wand->debug != MagickFalse)
832 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
833 (void) MVGPrintf(wand,
"circle %.20g %.20g %.20g %.20g\n",ox,oy,px,py);
858WandExport MagickBooleanType DrawClearException(
DrawingWand *wand)
861 assert(wand->signature == MagickWandSignature);
862 if (wand->debug != MagickFalse)
863 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
864 ClearMagickException(wand->exception);
890WandExport ExceptionInfo *DrawCloneExceptionInfo(
const DrawingWand *wand)
893 assert(wand->signature == MagickWandSignature);
894 if (wand->exception == (ExceptionInfo*) NULL)
895 return (ExceptionInfo*) NULL;
896 return CloneExceptionInfo(wand->exception);
935WandExport
void DrawColor(
DrawingWand *wand,
const double x,
const double y,
936 const PaintMethod paint_method)
939 assert(wand->signature == MagickWandSignature);
940 if (wand->debug != MagickFalse)
941 (void) LogMagickEvent(WandEvent, GetMagickModule(),
"%s", wand->name);
942 (void) MVGPrintf(wand,
"color %.20g %.20g '%s'\n",x,y,CommandOptionToMnemonic(
943 MagickMethodOptions,(ssize_t) paint_method));
987WandExport MagickBooleanType DrawComposite(
DrawingWand *wand,
988 const CompositeOperator compose,
const double x,
const double y,
989 const double width,
const double height,
MagickWand *magick_wand)
1019 assert(wand->signature == MagickWandSignature);
1020 if (wand->debug != MagickFalse)
1021 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1023 image=GetImageFromMagickWand(magick_wand);
1024 if (image == (Image *) NULL)
1025 return(MagickFalse);
1026 clone_image=CloneImage(image,0,0,MagickTrue,wand->exception);
1027 if (clone_image == (Image *) NULL)
1028 return(MagickFalse);
1029 image_info=AcquireImageInfo();
1030 (void) CopyMagickString(image_info->magick,
"MIFF",MagickPathExtent);
1032 blob=(
unsigned char *) ImageToBlob(image_info,clone_image,&blob_length,
1034 image_info=DestroyImageInfo(image_info);
1035 clone_image=DestroyImageList(clone_image);
1036 if (blob == (
void *) NULL)
1037 return(MagickFalse);
1039 base64=Base64Encode(blob,blob_length,&encoded_length);
1040 blob=(
unsigned char *) RelinquishMagickMemory(blob);
1041 if (base64 == (
char *) NULL)
1044 buffer[MagickPathExtent];
1046 (void) FormatLocaleString(buffer,MagickPathExtent,
"%.20g bytes",(
double)
1047 (4L*blob_length/3L+4L));
1048 ThrowDrawException(ResourceLimitWarning,
"MemoryAllocationFailed",
1050 return(MagickFalse);
1052 mode=CommandOptionToMnemonic(MagickComposeOptions,(ssize_t) compose);
1053 media_type=MagickToMime(image->magick);
1054 (void) MVGPrintf(wand,
"image %s %.20g %.20g %.20g %.20g 'data:%s;base64,\n",
1055 mode,x,y,width,height,media_type);
1057 for (i=(ssize_t) encoded_length; i > 0; i-=76)
1059 (void) MVGPrintf(wand,
"%.76s",p);
1062 (void) MVGPrintf(wand,
"\n");
1064 (void) MVGPrintf(wand,
"'\n");
1065 media_type=DestroyString(media_type);
1066 base64=DestroyString(base64);
1094WandExport
void DrawComment(
DrawingWand *wand,
const char *comment)
1096 (void) MVGPrintf(wand,
"#%s\n",comment);
1134WandExport
void DrawEllipse(
DrawingWand *wand,
const double ox,
const double oy,
1135 const double rx,
const double ry,
const double start,
const double end)
1138 assert(wand->signature == MagickWandSignature);
1139 if (wand->debug != MagickFalse)
1140 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1141 (void) MVGPrintf(wand,
"ellipse %.20g %.20g %.20g %.20g %.20g %.20g\n",ox,oy,
1171WandExport
void DrawGetBorderColor(
const DrawingWand *wand,
1175 assert(wand->signature == MagickWandSignature);
1176 assert(border_color != (
PixelWand *) NULL);
1177 if (wand->debug != MagickFalse)
1178 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1179 PixelSetPixelColor(border_color,&CurrentContext->border_color);
1205WandExport
char *DrawGetClipPath(
const DrawingWand *wand)
1208 assert(wand->signature == MagickWandSignature);
1209 if (wand->debug != MagickFalse)
1210 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1211 if (CurrentContext->clip_mask != (
char *) NULL)
1212 return((
char *) AcquireString(CurrentContext->clip_mask));
1213 return((
char *) NULL);
1239WandExport FillRule DrawGetClipRule(
const DrawingWand *wand)
1242 assert(wand->signature == MagickWandSignature);
1243 if (wand->debug != MagickFalse)
1244 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1245 return(CurrentContext->fill_rule);
1270WandExport ClipPathUnits DrawGetClipUnits(
const DrawingWand *wand)
1273 assert(wand->signature == MagickWandSignature);
1274 if (wand->debug != MagickFalse)
1275 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1276 return(CurrentContext->clip_units);
1302WandExport
char *DrawGetDensity(
const DrawingWand *wand)
1305 assert(wand->signature == MagickWandSignature);
1306 if (wand->debug != MagickFalse)
1307 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1308 if (CurrentContext->density != (
char *) NULL)
1309 return((
char *) AcquireString(CurrentContext->density));
1310 return((
char *) NULL);
1339WandExport
char *DrawGetException(
const DrawingWand *wand,
1340 ExceptionType *severity)
1346 assert(wand->signature == MagickWandSignature);
1347 if (wand->debug != MagickFalse)
1348 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1349 assert(severity != (ExceptionType *) NULL);
1350 *severity=wand->exception->severity;
1351 description=(
char *) AcquireQuantumMemory(2UL*MagickPathExtent,
1352 sizeof(*description));
1353 if (description == (
char *) NULL)
1354 ThrowWandFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
1357 if (wand->exception->reason != (
char *) NULL)
1358 (void) CopyMagickString(description,GetLocaleExceptionMessage(
1359 wand->exception->severity,wand->exception->reason),
1361 if (wand->exception->description != (
char *) NULL)
1363 (void) ConcatenateMagickString(description,
" (",MagickPathExtent);
1364 (void) ConcatenateMagickString(description,GetLocaleExceptionMessage(
1365 wand->exception->severity,wand->exception->description),
1367 (void) ConcatenateMagickString(description,
")",MagickPathExtent);
1369 return(description);
1395WandExport ExceptionType DrawGetExceptionType(
const DrawingWand *wand)
1398 assert(wand->signature == MagickWandSignature);
1399 if (wand->debug != MagickFalse)
1400 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1401 return(wand->exception->severity);
1432 assert(wand->signature == MagickWandSignature);
1433 assert(fill_color != (
PixelWand *) NULL);
1434 if (wand->debug != MagickFalse)
1435 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1436 PixelSetPixelColor(fill_color,&CurrentContext->fill);
1462WandExport
double DrawGetFillOpacity(
const DrawingWand *wand)
1468 assert(wand->signature == MagickWandSignature);
1469 if (wand->debug != MagickFalse)
1470 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1471 alpha=(double) QuantumScale*CurrentContext->fill.alpha;
1497WandExport FillRule DrawGetFillRule(
const DrawingWand *wand)
1500 assert(wand->signature == MagickWandSignature);
1501 if (wand->debug != MagickFalse)
1502 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1503 return(CurrentContext->fill_rule);
1530WandExport
char *DrawGetFont(
const DrawingWand *wand)
1533 assert(wand->signature == MagickWandSignature);
1534 if (wand->debug != MagickFalse)
1535 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1536 if (CurrentContext->font != (
char *) NULL)
1537 return(AcquireString(CurrentContext->font));
1538 return((
char *) NULL);
1564WandExport
char *DrawGetFontFamily(
const DrawingWand *wand)
1567 assert(wand->signature == MagickWandSignature);
1568 if (wand->debug != MagickFalse)
1569 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1570 if (CurrentContext->family != NULL)
1571 return(AcquireString(CurrentContext->family));
1572 return((
char *) NULL);
1602WandExport MagickBooleanType DrawGetFontResolution(
const DrawingWand *wand,
1603 double *x,
double *y)
1606 assert(wand->signature == MagickWandSignature);
1607 if (wand->debug != MagickFalse)
1608 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1609 *x=DefaultResolution;
1610 *y=DefaultResolution;
1611 if (CurrentContext->density != (
char *) NULL)
1619 flags=ParseGeometry(CurrentContext->density,&geometry_info);
1620 *x=geometry_info.rho;
1621 *y=geometry_info.sigma;
1622 if ((flags & SigmaValue) == MagickFalse)
1650WandExport
double DrawGetFontSize(
const DrawingWand *wand)
1653 assert(wand->signature == MagickWandSignature);
1654 if (wand->debug != MagickFalse)
1655 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1656 return(CurrentContext->pointsize);
1681WandExport StretchType DrawGetFontStretch(
const DrawingWand *wand)
1684 assert(wand->signature == MagickWandSignature);
1685 if (wand->debug != MagickFalse)
1686 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1687 return(CurrentContext->stretch);
1712WandExport StyleType DrawGetFontStyle(
const DrawingWand *wand)
1715 assert(wand->signature == MagickWandSignature);
1716 if (wand->debug != MagickFalse)
1717 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1718 return(CurrentContext->style);
1743WandExport
size_t DrawGetFontWeight(
const DrawingWand *wand)
1746 assert(wand->signature == MagickWandSignature);
1747 if (wand->debug != MagickFalse)
1748 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1749 return(CurrentContext->weight);
1775WandExport GravityType DrawGetGravity(
const DrawingWand *wand)
1778 assert(wand->signature == MagickWandSignature);
1779 if (wand->debug != MagickFalse)
1780 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1781 return(CurrentContext->gravity);
1807WandExport
double DrawGetOpacity(
const DrawingWand *wand)
1813 assert(wand->signature == MagickWandSignature);
1814 if (wand->debug != MagickFalse)
1815 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1816 alpha=QuantumScale*(double) CurrentContext->alpha;
1845WandExport MagickBooleanType DrawGetStrokeAntialias(
const DrawingWand *wand)
1848 assert(wand->signature == MagickWandSignature);
1849 if (wand->debug != MagickFalse)
1850 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1851 return(CurrentContext->stroke_antialias);
1879WandExport
void DrawGetStrokeColor(
const DrawingWand *wand,
1883 assert(wand->signature == MagickWandSignature);
1884 assert(stroke_color != (
PixelWand *) NULL);
1885 if (wand->debug != MagickFalse)
1886 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1887 PixelSetPixelColor(stroke_color,&CurrentContext->stroke);
1917WandExport
double *DrawGetStrokeDashArray(
const DrawingWand *wand,
1918 size_t *number_elements)
1934 assert(wand->signature == MagickWandSignature);
1935 if (wand->debug != MagickFalse)
1936 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1937 assert(number_elements != (
size_t *) NULL);
1938 p=CurrentContext->dash_pattern;
1939 if (p != (
const double *) NULL)
1940 while (fabs(*p++) >= MagickEpsilon)
1943 dasharray=(
double *) NULL;
1946 dasharray=(
double *) AcquireQuantumMemory((
size_t) n+1UL,
1947 sizeof(*dasharray));
1948 if (dasharray != (
double *) NULL)
1950 p=CurrentContext->dash_pattern;
1952 for (i=0; i < (ssize_t) n; i++)
1983WandExport
double DrawGetStrokeDashOffset(
const DrawingWand *wand)
1986 assert(wand->signature == MagickWandSignature);
1987 if (wand->debug != MagickFalse)
1988 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1989 return(CurrentContext->dash_offset);
2016WandExport LineCap DrawGetStrokeLineCap(
const DrawingWand *wand)
2019 assert(wand->signature == MagickWandSignature);
2020 if (wand->debug != MagickFalse)
2021 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2022 return(CurrentContext->linecap);
2050WandExport LineJoin DrawGetStrokeLineJoin(
const DrawingWand *wand)
2053 assert(wand->signature == MagickWandSignature);
2054 if (wand->debug != MagickFalse)
2055 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2056 return(CurrentContext->linejoin);
2085WandExport
size_t DrawGetStrokeMiterLimit(
const DrawingWand *wand)
2088 assert(wand->signature == MagickWandSignature);
2089 if (wand->debug != MagickFalse)
2090 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2091 return CurrentContext->miterlimit;
2116WandExport
double DrawGetStrokeOpacity(
const DrawingWand *wand)
2122 assert(wand->signature == MagickWandSignature);
2123 if (wand->debug != MagickFalse)
2124 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2125 alpha=(double) QuantumScale*CurrentContext->stroke.alpha;
2152WandExport
double DrawGetStrokeWidth(
const DrawingWand *wand)
2155 assert(wand->signature == MagickWandSignature);
2156 if (wand->debug != MagickFalse)
2157 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2158 return(CurrentContext->stroke_width);
2184WandExport AlignType DrawGetTextAlignment(
const DrawingWand *wand)
2187 assert(wand->signature == MagickWandSignature);
2188 if (wand->debug != MagickFalse)
2189 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2190 return(CurrentContext->align);
2216WandExport MagickBooleanType DrawGetTextAntialias(
const DrawingWand *wand)
2219 assert(wand->signature == MagickWandSignature);
2220 if (wand->debug != MagickFalse)
2221 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2222 return(CurrentContext->text_antialias);
2248WandExport DecorationType DrawGetTextDecoration(
const DrawingWand *wand)
2251 assert(wand->signature == MagickWandSignature);
2252 if (wand->debug != MagickFalse)
2253 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2254 return(CurrentContext->decorate);
2280WandExport DirectionType DrawGetTextDirection(
const DrawingWand *wand)
2283 assert(wand->signature == MagickWandSignature);
2284 if (wand->debug != MagickFalse)
2285 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2286 return(CurrentContext->direction);
2313WandExport
char *DrawGetTextEncoding(
const DrawingWand *wand)
2316 assert(wand->signature == MagickWandSignature);
2317 if (wand->debug != MagickFalse)
2318 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2319 if (CurrentContext->encoding != (
char *) NULL)
2320 return((
char *) AcquireString(CurrentContext->encoding));
2321 return((
char *) NULL);
2346WandExport
double DrawGetTextKerning(
DrawingWand *wand)
2349 assert(wand->signature == MagickWandSignature);
2351 if (wand->debug != MagickFalse)
2352 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2353 return(CurrentContext->kerning);
2378WandExport
double DrawGetTextInterlineSpacing(
DrawingWand *wand)
2381 assert(wand->signature == MagickWandSignature);
2382 if (wand->debug != MagickFalse)
2383 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2384 return(CurrentContext->interline_spacing);
2409WandExport
double DrawGetTextInterwordSpacing(
DrawingWand *wand)
2412 assert(wand->signature == MagickWandSignature);
2413 if (wand->debug != MagickFalse)
2414 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2415 return(CurrentContext->interword_spacing);
2467WandExport MagickBooleanType DrawGetTypeMetrics(
const DrawingWand *wand,
2468 const char *text,MagickBooleanType ignore_newlines,TypeMetric *metrics)
2477 assert(wand->signature == MagickWandSignature);
2478 if (wand->debug != MagickFalse)
2479 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2480 draw_info=PeekDrawingWand(wand);
2481 if (draw_info == (DrawInfo *) NULL)
2482 return(MagickFalse);
2483 (void) CloneString(&draw_info->text,text);
2484 if (ignore_newlines != MagickFalse)
2485 status=GetTypeMetrics(wand->image,draw_info,metrics,wand->exception);
2487 status=GetMultilineTypeMetrics(wand->image,draw_info,metrics,
2489 draw_info=DestroyDrawInfo(draw_info);
2518WandExport
char *DrawGetVectorGraphics(
DrawingWand *wand)
2521 value[MagickPathExtent],
2535 assert(wand->signature == MagickWandSignature);
2536 if (wand->debug != MagickFalse)
2537 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2538 xml_info=NewXMLTreeTag(
"drawing-wand");
2539 if (xml_info == (XMLTreeInfo *) NULL)
2540 return((
char *) NULL);
2541 (void) SetXMLTreeContent(xml_info,
" ");
2542 GetPixelInfo(wand->image,&pixel);
2543 child=AddChildToXMLTree(xml_info,
"clip-path",0);
2544 if (child != (XMLTreeInfo *) NULL)
2545 (void) SetXMLTreeContent(child,CurrentContext->clip_mask);
2546 child=AddChildToXMLTree(xml_info,
"clip-units",0);
2547 if (child != (XMLTreeInfo *) NULL)
2549 (void) CopyMagickString(value,CommandOptionToMnemonic(
2550 MagickClipPathOptions,(ssize_t) CurrentContext->clip_units),
2552 (void) SetXMLTreeContent(child,value);
2554 child=AddChildToXMLTree(xml_info,
"decorate",0);
2555 if (child != (XMLTreeInfo *) NULL)
2557 (void) CopyMagickString(value,CommandOptionToMnemonic(
2558 MagickDecorateOptions,(ssize_t) CurrentContext->decorate),
2560 (void) SetXMLTreeContent(child,value);
2562 child=AddChildToXMLTree(xml_info,
"encoding",0);
2563 if (child != (XMLTreeInfo *) NULL)
2564 (void) SetXMLTreeContent(child,CurrentContext->encoding);
2565 child=AddChildToXMLTree(xml_info,
"fill",0);
2566 if (child != (XMLTreeInfo *) NULL)
2568 if (CurrentContext->fill.alpha != (
double) OpaqueAlpha)
2569 pixel.alpha_trait=CurrentContext->fill.alpha != (double) OpaqueAlpha ?
2570 BlendPixelTrait : UndefinedPixelTrait;
2571 pixel=CurrentContext->fill;
2572 GetColorTuple(&pixel,MagickTrue,value);
2573 (void) SetXMLTreeContent(child,value);
2575 child=AddChildToXMLTree(xml_info,
"fill-opacity",0);
2576 if (child != (XMLTreeInfo *) NULL)
2578 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2579 (
double) (QuantumScale*CurrentContext->fill.alpha));
2580 (void) SetXMLTreeContent(child,value);
2582 child=AddChildToXMLTree(xml_info,
"fill-rule",0);
2583 if (child != (XMLTreeInfo *) NULL)
2585 (void) CopyMagickString(value,CommandOptionToMnemonic(
2586 MagickFillRuleOptions,(ssize_t) CurrentContext->fill_rule),
2588 (void) SetXMLTreeContent(child,value);
2590 child=AddChildToXMLTree(xml_info,
"font",0);
2591 if (child != (XMLTreeInfo *) NULL)
2592 (void) SetXMLTreeContent(child,CurrentContext->font);
2593 child=AddChildToXMLTree(xml_info,
"font-family",0);
2594 if (child != (XMLTreeInfo *) NULL)
2595 (void) SetXMLTreeContent(child,CurrentContext->family);
2596 child=AddChildToXMLTree(xml_info,
"font-size",0);
2597 if (child != (XMLTreeInfo *) NULL)
2599 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2600 CurrentContext->pointsize);
2601 (void) SetXMLTreeContent(child,value);
2603 child=AddChildToXMLTree(xml_info,
"font-stretch",0);
2604 if (child != (XMLTreeInfo *) NULL)
2606 (void) CopyMagickString(value,CommandOptionToMnemonic(
2607 MagickStretchOptions,(ssize_t) CurrentContext->stretch),
2609 (void) SetXMLTreeContent(child,value);
2611 child=AddChildToXMLTree(xml_info,
"font-style",0);
2612 if (child != (XMLTreeInfo *) NULL)
2614 (void) CopyMagickString(value,CommandOptionToMnemonic(
2615 MagickStyleOptions,(ssize_t) CurrentContext->style),MagickPathExtent);
2616 (void) SetXMLTreeContent(child,value);
2618 child=AddChildToXMLTree(xml_info,
"font-weight",0);
2619 if (child != (XMLTreeInfo *) NULL)
2621 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2622 CurrentContext->weight);
2623 (void) SetXMLTreeContent(child,value);
2625 child=AddChildToXMLTree(xml_info,
"gravity",0);
2626 if (child != (XMLTreeInfo *) NULL)
2628 (void) CopyMagickString(value,CommandOptionToMnemonic(
2629 MagickGravityOptions,(ssize_t) CurrentContext->gravity),
2631 (void) SetXMLTreeContent(child,value);
2633 child=AddChildToXMLTree(xml_info,
"stroke",0);
2634 if (child != (XMLTreeInfo *) NULL)
2636 if (CurrentContext->stroke.alpha != (
double) OpaqueAlpha)
2637 pixel.alpha_trait=CurrentContext->stroke.alpha != (double) OpaqueAlpha ?
2638 BlendPixelTrait : UndefinedPixelTrait;
2639 pixel=CurrentContext->stroke;
2640 GetColorTuple(&pixel,MagickTrue,value);
2641 (void) SetXMLTreeContent(child,value);
2643 child=AddChildToXMLTree(xml_info,
"stroke-antialias",0);
2644 if (child != (XMLTreeInfo *) NULL)
2646 (void) FormatLocaleString(value,MagickPathExtent,
"%d",
2647 CurrentContext->stroke_antialias != MagickFalse ? 1 : 0);
2648 (void) SetXMLTreeContent(child,value);
2650 child=AddChildToXMLTree(xml_info,
"stroke-dasharray",0);
2651 if ((child != (XMLTreeInfo *) NULL) &&
2652 (CurrentContext->dash_pattern != (
double *) NULL))
2657 dash_pattern=AcquireString((
char *) NULL);
2658 for (i=0; fabs(CurrentContext->dash_pattern[i]) >= MagickEpsilon; i++)
2661 (void) ConcatenateString(&dash_pattern,
",");
2662 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2663 CurrentContext->dash_pattern[i]);
2664 (void) ConcatenateString(&dash_pattern,value);
2666 (void) SetXMLTreeContent(child,dash_pattern);
2667 dash_pattern=DestroyString(dash_pattern);
2669 child=AddChildToXMLTree(xml_info,
"stroke-dashoffset",0);
2670 if (child != (XMLTreeInfo *) NULL)
2672 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2673 CurrentContext->dash_offset);
2674 (void) SetXMLTreeContent(child,value);
2676 child=AddChildToXMLTree(xml_info,
"stroke-linecap",0);
2677 if (child != (XMLTreeInfo *) NULL)
2679 (void) CopyMagickString(value,CommandOptionToMnemonic(
2680 MagickLineCapOptions,(ssize_t) CurrentContext->linecap),
2682 (void) SetXMLTreeContent(child,value);
2684 child=AddChildToXMLTree(xml_info,
"stroke-linejoin",0);
2685 if (child != (XMLTreeInfo *) NULL)
2687 (void) CopyMagickString(value,CommandOptionToMnemonic(
2688 MagickLineJoinOptions,(ssize_t) CurrentContext->linejoin),
2690 (void) SetXMLTreeContent(child,value);
2692 child=AddChildToXMLTree(xml_info,
"stroke-miterlimit",0);
2693 if (child != (XMLTreeInfo *) NULL)
2695 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2696 CurrentContext->miterlimit);
2697 (void) SetXMLTreeContent(child,value);
2699 child=AddChildToXMLTree(xml_info,
"stroke-opacity",0);
2700 if (child != (XMLTreeInfo *) NULL)
2702 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2703 (
double) (QuantumScale*CurrentContext->stroke.alpha));
2704 (void) SetXMLTreeContent(child,value);
2706 child=AddChildToXMLTree(xml_info,
"stroke-width",0);
2707 if (child != (XMLTreeInfo *) NULL)
2709 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2710 CurrentContext->stroke_width);
2711 (void) SetXMLTreeContent(child,value);
2713 child=AddChildToXMLTree(xml_info,
"text-align",0);
2714 if (child != (XMLTreeInfo *) NULL)
2716 (void) CopyMagickString(value,CommandOptionToMnemonic(MagickAlignOptions,
2717 (ssize_t) CurrentContext->align),MagickPathExtent);
2718 (void) SetXMLTreeContent(child,value);
2720 child=AddChildToXMLTree(xml_info,
"text-antialias",0);
2721 if (child != (XMLTreeInfo *) NULL)
2723 (void) FormatLocaleString(value,MagickPathExtent,
"%d",
2724 CurrentContext->text_antialias != MagickFalse ? 1 : 0);
2725 (void) SetXMLTreeContent(child,value);
2727 child=AddChildToXMLTree(xml_info,
"text-undercolor",0);
2728 if (child != (XMLTreeInfo *) NULL)
2730 if (CurrentContext->undercolor.alpha != (
double) OpaqueAlpha)
2731 pixel.alpha_trait=CurrentContext->undercolor.alpha != (double) OpaqueAlpha ?
2732 BlendPixelTrait : UndefinedPixelTrait;
2733 pixel=CurrentContext->undercolor;
2734 GetColorTuple(&pixel,MagickTrue,value);
2735 (void) SetXMLTreeContent(child,value);
2737 child=AddChildToXMLTree(xml_info,
"vector-graphics",0);
2738 if (child != (XMLTreeInfo *) NULL)
2739 (void) SetXMLTreeContent(child,wand->mvg);
2740 xml=XMLTreeInfoToXML(xml_info);
2741 xml_info=DestroyXMLTree(xml_info);
2771WandExport
void DrawGetTextUnderColor(
const DrawingWand *wand,
2775 assert(wand->signature == MagickWandSignature);
2776 assert(under_color != (
PixelWand *) NULL);
2777 if (wand->debug != MagickFalse)
2778 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2779 PixelSetPixelColor(under_color,&CurrentContext->undercolor);
2814WandExport
void DrawLine(
DrawingWand *wand,
const double sx,
const double sy,
2815 const double ex,
const double ey)
2818 assert(wand->signature == MagickWandSignature);
2819 if (wand->debug != MagickFalse)
2820 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2821 (void) MVGPrintf(wand,
"line %.20g %.20g %.20g %.20g\n",sx,sy,ex,ey);
2852 assert(wand->signature == MagickWandSignature);
2853 if (wand->debug != MagickFalse)
2854 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2855 (void) MVGAutoWrapPrintf(wand,
"%s",wand->path_mode == AbsolutePathMode ?
2900static void DrawPathCurveTo(
DrawingWand *wand,
const PathMode mode,
2901 const double x1,
const double y1,
const double x2,
const double y2,
2902 const double x,
const double y)
2905 assert(wand->signature == MagickWandSignature);
2906 if (wand->debug != MagickFalse)
2907 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2908 if ((wand->path_operation != PathCurveToOperation) ||
2909 (wand->path_mode != mode))
2911 wand->path_operation=PathCurveToOperation;
2912 wand->path_mode=mode;
2913 (void) MVGAutoWrapPrintf(wand,
"%c%.20g %.20g %.20g %.20g %.20g %.20g",
2914 mode == AbsolutePathMode ?
'C' :
'c',x1,y1,x2,y2,x,y);
2917 (
void) MVGAutoWrapPrintf(wand,
" %.20g %.20g %.20g %.20g %.20g %.20g",x1,y1,
2921WandExport
void DrawPathCurveToAbsolute(
DrawingWand *wand,
const double x1,
2922 const double y1,
const double x2,
const double y2,
const double x,
const double y)
2925 assert(wand->signature == MagickWandSignature);
2926 if (wand->debug != MagickFalse)
2927 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2928 DrawPathCurveTo(wand,AbsolutePathMode,x1,y1,x2,y2,x,y);
2971WandExport
void DrawPathCurveToRelative(
DrawingWand *wand,
const double x1,
2972 const double y1,
const double x2,
const double y2,
const double x,
const double y)
2975 assert(wand->signature == MagickWandSignature);
2976 if (wand->debug != MagickFalse)
2977 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2978 DrawPathCurveTo(wand,RelativePathMode,x1,y1,x2,y2,x,y);
3016static void DrawPathCurveToQuadraticBezier(
DrawingWand *wand,
3017 const PathMode mode,
const double x1,
double y1,
const double x,
const double y)
3020 assert(wand->signature == MagickWandSignature);
3021 if (wand->debug != MagickFalse)
3022 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3023 if ((wand->path_operation != PathCurveToQuadraticBezierOperation) ||
3024 (wand->path_mode != mode))
3026 wand->path_operation=PathCurveToQuadraticBezierOperation;
3027 wand->path_mode=mode;
3028 (void) MVGAutoWrapPrintf(wand,
"%c%.20g %.20g %.20g %.20g",
3029 mode == AbsolutePathMode ?
'Q' :
'q',x1,y1,x,y);
3032 (
void) MVGAutoWrapPrintf(wand,
" %.20g %.20g %.20g %.20g",x1,y1,x,y);
3035WandExport
void DrawPathCurveToQuadraticBezierAbsolute(
DrawingWand *wand,
3036 const double x1,
const double y1,
const double x,
const double y)
3039 assert(wand->signature == MagickWandSignature);
3040 if (wand->debug != MagickFalse)
3041 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3042 DrawPathCurveToQuadraticBezier(wand,AbsolutePathMode,x1,y1,x,y);
3079WandExport
void DrawPathCurveToQuadraticBezierRelative(
DrawingWand *wand,
3080 const double x1,
const double y1,
const double x,
const double y)
3083 assert(wand->signature == MagickWandSignature);
3084 if (wand->debug != MagickFalse)
3085 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3086 DrawPathCurveToQuadraticBezier(wand,RelativePathMode,x1,y1,x,y);
3128static void DrawPathCurveToQuadraticBezierSmooth(
DrawingWand *wand,
3129 const PathMode mode,
const double x,
const double y)
3132 assert(wand->signature == MagickWandSignature);
3133 if (wand->debug != MagickFalse)
3134 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3135 if ((wand->path_operation != PathCurveToQuadraticBezierSmoothOperation) ||
3136 (wand->path_mode != mode))
3138 wand->path_operation=PathCurveToQuadraticBezierSmoothOperation;
3139 wand->path_mode=mode;
3140 (void) MVGAutoWrapPrintf(wand,
"%c%.20g %.20g",mode == AbsolutePathMode ?
3144 (
void) MVGAutoWrapPrintf(wand,
" %.20g %.20g",x,y);
3147WandExport
void DrawPathCurveToQuadraticBezierSmoothAbsolute(
DrawingWand *wand,
3148 const double x,
const double y)
3151 assert(wand->signature == MagickWandSignature);
3152 if (wand->debug != MagickFalse)
3153 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3154 DrawPathCurveToQuadraticBezierSmooth(wand,AbsolutePathMode,x,y);
3194WandExport
void DrawPathCurveToQuadraticBezierSmoothRelative(
DrawingWand *wand,
3195 const double x,
const double y)
3197 DrawPathCurveToQuadraticBezierSmooth(wand,RelativePathMode,x,y);
3242static void DrawPathCurveToSmooth(
DrawingWand *wand,
const PathMode mode,
3243 const double x2,
const double y2,
const double x,
const double y)
3246 assert(wand->signature == MagickWandSignature);
3247 if (wand->debug != MagickFalse)
3248 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3249 if ((wand->path_operation != PathCurveToSmoothOperation) ||
3250 (wand->path_mode != mode))
3252 wand->path_operation=PathCurveToSmoothOperation;
3253 wand->path_mode=mode;
3254 (void) MVGAutoWrapPrintf(wand,
"%c%.20g %.20g %.20g %.20g",
3255 mode == AbsolutePathMode ?
'S' :
's',x2,y2,x,y);
3258 (
void) MVGAutoWrapPrintf(wand,
" %.20g %.20g %.20g %.20g",x2,y2,x,y);
3261WandExport
void DrawPathCurveToSmoothAbsolute(
DrawingWand *wand,
const double x2,
3262 const double y2,
const double x,
const double y)
3265 assert(wand->signature == MagickWandSignature);
3266 if (wand->debug != MagickFalse)
3267 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3268 DrawPathCurveToSmooth(wand,AbsolutePathMode,x2,y2,x,y);
3311WandExport
void DrawPathCurveToSmoothRelative(
DrawingWand *wand,
const double x2,
3312 const double y2,
const double x,
const double y)
3315 assert(wand->signature == MagickWandSignature);
3316 if (wand->debug != MagickFalse)
3317 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3318 DrawPathCurveToSmooth(wand,RelativePathMode,x2,y2,x,y);
3370static void DrawPathEllipticArc(
DrawingWand *wand,
const PathMode mode,
3371 const double rx,
const double ry,
const double x_axis_rotation,
3372 const MagickBooleanType large_arc_flag,
const MagickBooleanType sweep_flag,
3373 const double x,
const double y)
3376 assert(wand->signature == MagickWandSignature);
3377 if (wand->debug != MagickFalse)
3378 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3379 if ((wand->path_operation != PathEllipticArcOperation) ||
3380 (wand->path_mode != mode))
3382 wand->path_operation=PathEllipticArcOperation;
3383 wand->path_mode=mode;
3384 (void) MVGAutoWrapPrintf(wand,
"%c%.20g %.20g %.20g %u %u %.20g %.20g",
3385 mode == AbsolutePathMode ?
'A' :
'a',rx,ry,x_axis_rotation,
3386 large_arc_flag,sweep_flag,x,y);
3389 (
void) MVGAutoWrapPrintf(wand,
" %.20g %.20g %.20g %u %u %.20g %.20g",rx,ry,
3390 x_axis_rotation,large_arc_flag,sweep_flag,x,y);
3393WandExport
void DrawPathEllipticArcAbsolute(
DrawingWand *wand,
const double rx,
3394 const double ry,
const double x_axis_rotation,
3395 const MagickBooleanType large_arc_flag,
const MagickBooleanType sweep_flag,
3396 const double x,
const double y)
3399 assert(wand->signature == MagickWandSignature);
3400 if (wand->debug != MagickFalse)
3401 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3402 DrawPathEllipticArc(wand,AbsolutePathMode,rx,ry,x_axis_rotation,
3403 large_arc_flag,sweep_flag,x,y);
3453WandExport
void DrawPathEllipticArcRelative(
DrawingWand *wand,
const double rx,
3454 const double ry,
const double x_axis_rotation,
3455 const MagickBooleanType large_arc_flag,
const MagickBooleanType sweep_flag,
3456 const double x,
const double y)
3458 DrawPathEllipticArc(wand,RelativePathMode,rx,ry,x_axis_rotation,
3459 large_arc_flag,sweep_flag,x,y);
3487 assert(wand->signature == MagickWandSignature);
3488 if (wand->debug != MagickFalse)
3489 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3490 (void) MVGPrintf(wand,
"'\n");
3491 wand->path_operation=PathDefaultOperation;
3492 wand->path_mode=DefaultPathMode;
3524static void DrawPathLineTo(
DrawingWand *wand,
const PathMode mode,
3525 const double x,
const double y)
3528 assert(wand->signature == MagickWandSignature);
3529 if (wand->debug != MagickFalse)
3530 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3531 if ((wand->path_operation != PathLineToOperation) ||
3532 (wand->path_mode != mode))
3534 wand->path_operation=PathLineToOperation;
3535 wand->path_mode=mode;
3536 (void) MVGAutoWrapPrintf(wand,
"%c%.20g %.20g",mode == AbsolutePathMode ?
3540 (
void) MVGAutoWrapPrintf(wand,
" %.20g %.20g",x,y);
3543WandExport
void DrawPathLineToAbsolute(
DrawingWand *wand,
const double x,
3547 assert(wand->signature == MagickWandSignature);
3548 if (wand->debug != MagickFalse)
3549 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3550 DrawPathLineTo(wand,AbsolutePathMode,x,y);
3582WandExport
void DrawPathLineToRelative(
DrawingWand *wand,
const double x,
3586 assert(wand->signature == MagickWandSignature);
3587 if (wand->debug != MagickFalse)
3588 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3589 DrawPathLineTo(wand,RelativePathMode,x,y);
3619static void DrawPathLineToHorizontal(
DrawingWand *wand,
const PathMode mode,
3623 assert(wand->signature == MagickWandSignature);
3624 if (wand->debug != MagickFalse)
3625 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3626 if ((wand->path_operation != PathLineToHorizontalOperation) ||
3627 (wand->path_mode != mode))
3629 wand->path_operation=PathLineToHorizontalOperation;
3630 wand->path_mode=mode;
3631 (void) MVGAutoWrapPrintf(wand,
"%c%.20g",mode == AbsolutePathMode ?
3635 (
void) MVGAutoWrapPrintf(wand,
" %.20g",x);
3638WandExport
void DrawPathLineToHorizontalAbsolute(
DrawingWand *wand,
3642 assert(wand->signature == MagickWandSignature);
3643 if (wand->debug != MagickFalse)
3644 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3645 DrawPathLineToHorizontal(wand,AbsolutePathMode,x);
3675WandExport
void DrawPathLineToHorizontalRelative(
DrawingWand *wand,
3678 DrawPathLineToHorizontal(wand,RelativePathMode,x);
3709static void DrawPathLineToVertical(
DrawingWand *wand,
const PathMode mode,
3713 assert(wand->signature == MagickWandSignature);
3714 if (wand->debug != MagickFalse)
3715 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3716 if ((wand->path_operation != PathLineToVerticalOperation) ||
3717 (wand->path_mode != mode))
3719 wand->path_operation=PathLineToVerticalOperation;
3720 wand->path_mode=mode;
3721 (void) MVGAutoWrapPrintf(wand,
"%c%.20g",mode == AbsolutePathMode ?
3725 (
void) MVGAutoWrapPrintf(wand,
" %.20g",y);
3728WandExport
void DrawPathLineToVerticalAbsolute(
DrawingWand *wand,
const double y)
3731 assert(wand->signature == MagickWandSignature);
3732 if (wand->debug != MagickFalse)
3733 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3734 DrawPathLineToVertical(wand,AbsolutePathMode,y);
3764WandExport
void DrawPathLineToVerticalRelative(
DrawingWand *wand,
const double y)
3767 assert(wand->signature == MagickWandSignature);
3768 if (wand->debug != MagickFalse)
3769 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3770 DrawPathLineToVertical(wand,RelativePathMode,y);
3802static void DrawPathMoveTo(
DrawingWand *wand,
const PathMode mode,
const double x,
3806 assert(wand->signature == MagickWandSignature);
3807 if (wand->debug != MagickFalse)
3808 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3809 if ((wand->path_operation != PathMoveToOperation) ||
3810 (wand->path_mode != mode))
3812 wand->path_operation=PathMoveToOperation;
3813 wand->path_mode=mode;
3814 (void) MVGAutoWrapPrintf(wand,
"%c%.20g %.20g",mode == AbsolutePathMode ?
3818 (
void) MVGAutoWrapPrintf(wand,
" %.20g %.20g",x,y);
3821WandExport
void DrawPathMoveToAbsolute(
DrawingWand *wand,
const double x,
3825 assert(wand->signature == MagickWandSignature);
3826 if (wand->debug != MagickFalse)
3827 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3828 DrawPathMoveTo(wand,AbsolutePathMode,x,y);
3860WandExport
void DrawPathMoveToRelative(
DrawingWand *wand,
const double x,
3864 assert(wand->signature == MagickWandSignature);
3865 if (wand->debug != MagickFalse)
3866 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3867 DrawPathMoveTo(wand,RelativePathMode,x,y);
3899 assert(wand->signature == MagickWandSignature);
3900 if (wand->debug != MagickFalse)
3901 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3902 (void) MVGPrintf(wand,
"path '");
3903 wand->path_operation=PathDefaultOperation;
3904 wand->path_mode=DefaultPathMode;
3933WandExport
void DrawPoint(
DrawingWand *wand,
const double x,
const double y)
3936 assert(wand->signature == MagickWandSignature);
3937 if (wand->debug != MagickFalse)
3938 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3939 (void) MVGPrintf(wand,
"point %.20g %.20g\n",x,y);
3971 const size_t number_coordinates,
const PointInfo *coordinates)
3974 assert(wand->signature == MagickWandSignature);
3975 if (wand->debug != MagickFalse)
3976 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3977 MVGAppendPointsCommand(wand,
"polygon",number_coordinates,coordinates);
4009 const size_t number_coordinates,
const PointInfo *coordinates)
4012 assert(wand->signature == MagickWandSignature);
4013 if (wand->debug != MagickFalse)
4014 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4015 MVGAppendPointsCommand(wand,
"polyline",number_coordinates,coordinates);
4043 assert(wand->signature == MagickWandSignature);
4044 if (wand->debug != MagickFalse)
4045 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4046 if (wand->indent_depth > 0)
4047 wand->indent_depth--;
4048 (void) MVGPrintf(wand,
"pop clip-path\n");
4076 assert(wand->signature == MagickWandSignature);
4077 if (wand->debug != MagickFalse)
4078 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4079 if (wand->indent_depth > 0)
4080 wand->indent_depth--;
4081 (void) MVGPrintf(wand,
"pop defs\n");
4106WandExport MagickBooleanType DrawPopPattern(
DrawingWand *wand)
4109 geometry[MagickPathExtent],
4110 key[MagickPathExtent];
4113 assert(wand->signature == MagickWandSignature);
4114 if (wand->debug != MagickFalse)
4115 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4116 if (wand->image == (Image *) NULL)
4117 ThrowDrawException(WandError,
"ContainsNoImages",wand->name);
4118 if (wand->pattern_id == (
const char *) NULL)
4120 ThrowDrawException(DrawWarning,
"NotCurrentlyPushingPatternDefinition",
4122 return(MagickFalse);
4124 (void) FormatLocaleString(key,MagickPathExtent,
"%s",wand->pattern_id);
4125 (void) SetImageArtifact(wand->image,key,wand->mvg+wand->pattern_offset);
4126 (void) FormatLocaleString(geometry,MagickPathExtent,
"%.20gx%.20g%+.20g%+.20g",
4127 (
double) wand->pattern_bounds.width,(
double) wand->pattern_bounds.height,
4128 (
double) wand->pattern_bounds.x,(
double) wand->pattern_bounds.y);
4129 (void) SetImageArtifact(wand->image,key,geometry);
4130 wand->pattern_id=DestroyString(wand->pattern_id);
4131 wand->pattern_offset=0;
4132 wand->pattern_bounds.x=0;
4133 wand->pattern_bounds.y=0;
4134 wand->pattern_bounds.width=0;
4135 wand->pattern_bounds.height=0;
4136 wand->filter_off=MagickTrue;
4137 if (wand->indent_depth > 0)
4138 wand->indent_depth--;
4139 (void) MVGPrintf(wand,
"pop pattern\n");
4169WandExport
void DrawPushClipPath(
DrawingWand *wand,
const char *clip_mask_id)
4172 assert(wand->signature == MagickWandSignature);
4173 if (wand->debug != MagickFalse)
4174 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4175 assert(clip_mask_id != (
const char *) NULL);
4176 (void) MVGPrintf(wand,
"push clip-path \"%s\"\n",clip_mask_id);
4177 wand->indent_depth++;
4207 assert(wand->signature == MagickWandSignature);
4208 if (wand->debug != MagickFalse)
4209 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4210 (void) MVGPrintf(wand,
"push defs\n");
4211 wand->indent_depth++;
4253WandExport MagickBooleanType DrawPushPattern(
DrawingWand *wand,
4254 const char *pattern_id,
const double x,
const double y,
const double width,
4255 const double height)
4258 assert(wand->signature == MagickWandSignature);
4259 if (wand->debug != MagickFalse)
4260 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4261 assert(pattern_id != (
const char *) NULL);
4262 if (wand->pattern_id != NULL)
4264 ThrowDrawException(DrawError,
"AlreadyPushingPatternDefinition",
4266 return(MagickFalse);
4268 wand->filter_off=MagickTrue;
4269 (void) MVGPrintf(wand,
"push pattern %s %.20g %.20g %.20g %.20g\n",pattern_id,
4271 wand->indent_depth++;
4272 wand->pattern_id=AcquireString(pattern_id);
4273 wand->pattern_bounds.x=CastDoubleToLong(ceil(x-0.5));
4274 wand->pattern_bounds.y=CastDoubleToLong(ceil(y-0.5));
4275 wand->pattern_bounds.width=(size_t) CastDoubleToLong(floor(width+0.5));
4276 wand->pattern_bounds.height=(size_t) CastDoubleToLong(floor(height+0.5));
4277 wand->pattern_offset=wand->mvg_length;
4311WandExport
void DrawRectangle(
DrawingWand *wand,
const double x1,
const double y1,
4312 const double x2,
const double y2)
4315 assert(wand->signature == MagickWandSignature);
4316 if (wand->debug != MagickFalse)
4317 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4318 if ((fabs(x2-x1) < MagickEpsilon) && (fabs(y2-y1) < MagickEpsilon))
4319 (void) MVGPrintf(wand,
"point %.20g %.20g\n",x1,y1);
4321 (
void) MVGPrintf(wand,
"rectangle %.20g %.20g %.20g %.20g\n",x1,y1,x2,y2);
4346WandExport MagickBooleanType DrawRender(
DrawingWand *wand)
4352 assert(wand->signature == MagickWandSignature);
4353 if (wand->debug != MagickFalse)
4354 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4355 CurrentContext->primitive=wand->mvg;
4356 if (wand->debug != MagickFalse)
4357 (void) LogMagickEvent(DrawEvent,GetMagickModule(),
"MVG:\n'%s'\n",wand->mvg);
4358 if (wand->image == (Image *) NULL)
4359 ThrowDrawException(WandError,
"ContainsNoImages",wand->name);
4360 status=DrawImage(wand->image,CurrentContext,wand->exception);
4361 CurrentContext->primitive=(
char *) NULL;
4388WandExport
void DrawResetVectorGraphics(
DrawingWand *wand)
4391 assert(wand->signature == MagickWandSignature);
4392 if (wand->debug != MagickFalse)
4393 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4394 if (wand->mvg != (
char *) NULL)
4395 wand->mvg=DestroyString(wand->mvg);
4425WandExport
void DrawRotate(
DrawingWand *wand,
const double degrees)
4428 assert(wand->signature == MagickWandSignature);
4429 if (wand->debug != MagickFalse)
4430 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4431 (void) MVGPrintf(wand,
"rotate %.20g\n",degrees);
4471WandExport
void DrawRoundRectangle(
DrawingWand *wand,
double x1,
double y1,
4472 double x2,
double y2,
double rx,
double ry)
4475 assert(wand->signature == MagickWandSignature);
4476 if (wand->debug != MagickFalse)
4477 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4478 (void) MVGPrintf(wand,
"roundrectangle %.20g %.20g %.20g %.20g %.20g %.20g\n",
4509WandExport
void DrawScale(
DrawingWand *wand,
const double x,
const double y)
4512 assert(wand->signature == MagickWandSignature);
4513 if (wand->debug != MagickFalse)
4514 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4515 (void) MVGPrintf(wand,
"scale %.20g %.20g\n",x,y);
4543WandExport
void DrawSetBorderColor(
DrawingWand *wand,
4552 assert(wand->signature == MagickWandSignature);
4553 if (wand->debug != MagickFalse)
4554 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4555 assert(border_wand != (
const PixelWand *) NULL);
4556 PixelGetQuantumPacket(border_wand,&border_color);
4557 new_border=border_color;
4558 current_border=(&CurrentContext->border_color);
4559 if ((wand->filter_off != MagickFalse) ||
4560 (IsPixelInfoEquivalent(current_border,&new_border) == MagickFalse))
4562 CurrentContext->border_color=new_border;
4563 (void) MVGPrintf(wand,
"border-color '");
4564 MVGAppendColor(wand,&border_color);
4565 (void) MVGPrintf(wand,
"'\n");
4596WandExport MagickBooleanType DrawSetClipPath(
DrawingWand *wand,
4597 const char *clip_mask)
4600 if (wand->debug != MagickFalse)
4601 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",clip_mask);
4602 assert(wand->signature == MagickWandSignature);
4603 assert(clip_mask != (
const char *) NULL);
4604 if ((CurrentContext->clip_mask == (
const char *) NULL) ||
4605 (wand->filter_off != MagickFalse) ||
4606 (LocaleCompare(CurrentContext->clip_mask,clip_mask) != 0))
4608 (void) CloneString(&CurrentContext->clip_mask,clip_mask);
4609#if DRAW_BINARY_IMPLEMENTATION
4610 if (wand->image == (Image *) NULL)
4611 ThrowDrawException(WandError,
"ContainsNoImages",wand->name);
4612 (void) DrawClipPath(wand->image,CurrentContext,CurrentContext->clip_mask,
4615 (void) MVGPrintf(wand,
"clip-path url(#%s)\n",clip_mask);
4644WandExport
void DrawSetClipRule(
DrawingWand *wand,
const FillRule fill_rule)
4647 assert(wand->signature == MagickWandSignature);
4648 if (wand->debug != MagickFalse)
4649 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4650 if ((wand->filter_off != MagickFalse) ||
4651 (CurrentContext->fill_rule != fill_rule))
4653 CurrentContext->fill_rule=fill_rule;
4654 (void) MVGPrintf(wand,
"clip-rule '%s'\n",CommandOptionToMnemonic(
4655 MagickFillRuleOptions,(ssize_t) fill_rule));
4685WandExport
void DrawSetClipUnits(
DrawingWand *wand,
4686 const ClipPathUnits clip_units)
4689 assert(wand->signature == MagickWandSignature);
4690 if (wand->debug != MagickFalse)
4691 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4692 if ((wand->filter_off != MagickFalse) ||
4693 (CurrentContext->clip_units != clip_units))
4695 CurrentContext->clip_units=clip_units;
4696 if (clip_units == ObjectBoundingBox)
4701 GetAffineMatrix(&affine);
4702 affine.sx=CurrentContext->bounds.x2;
4703 affine.sy=CurrentContext->bounds.y2;
4704 affine.tx=CurrentContext->bounds.x1;
4705 affine.ty=CurrentContext->bounds.y1;
4706 AdjustAffine(wand,&affine);
4708 (void) MVGPrintf(wand,
"clip-units '%s'\n",CommandOptionToMnemonic(
4709 MagickClipPathOptions,(ssize_t) clip_units));
4738WandExport MagickBooleanType DrawSetDensity(
DrawingWand *wand,
4739 const char *density)
4742 if (wand->debug != MagickFalse)
4743 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",density);
4744 assert(wand->signature == MagickWandSignature);
4745 assert(density != (
const char *) NULL);
4746 if ((CurrentContext->density == (
const char *) NULL) ||
4747 (wand->filter_off != MagickFalse) ||
4748 (LocaleCompare(CurrentContext->density,density) != 0))
4750 (void) CloneString(&CurrentContext->density,density);
4751 (void) MVGPrintf(wand,
"density '%s'\n",density);
4788 assert(wand->signature == MagickWandSignature);
4789 if (wand->debug != MagickFalse)
4790 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4791 assert(fill_wand != (
const PixelWand *) NULL);
4792 PixelGetQuantumPacket(fill_wand,&fill_color);
4793 new_fill=fill_color;
4794 current_fill=(&CurrentContext->fill);
4795 if ((wand->filter_off != MagickFalse) ||
4796 (IsPixelInfoEquivalent(current_fill,&new_fill) == MagickFalse))
4798 CurrentContext->fill=new_fill;
4799 (void) MVGPrintf(wand,
"fill '");
4800 MVGAppendColor(wand,&fill_color);
4801 (void) MVGPrintf(wand,
"'\n");
4830WandExport
void DrawSetFillOpacity(
DrawingWand *wand,
const double fill_opacity)
4836 assert(wand->signature == MagickWandSignature);
4837 if (wand->debug != MagickFalse)
4838 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4839 alpha=(double) ClampToQuantum((
double) QuantumRange*fill_opacity);
4840 if ((wand->filter_off != MagickFalse) ||
4841 (CurrentContext->fill.alpha != alpha))
4843 CurrentContext->fill.alpha=alpha;
4844 (void) MVGPrintf(wand,
"fill-opacity %.20g\n",fill_opacity);
4875WandExport MagickBooleanType DrawSetFontResolution(
DrawingWand *wand,
4876 const double x_resolution,
const double y_resolution)
4879 density[MagickPathExtent];
4882 assert(wand->signature == MagickWandSignature);
4883 if (wand->debug != MagickFalse)
4884 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4885 (void) FormatLocaleString(density,MagickPathExtent,
"%.20gx%.20g",x_resolution,
4887 (void) CloneString(&CurrentContext->density,density);
4916WandExport
void DrawSetOpacity(
DrawingWand *wand,
const double opacity)
4922 assert(wand->signature == MagickWandSignature);
4923 if (wand->debug != MagickFalse)
4924 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4925 quantum_alpha=ClampToQuantum((
double) QuantumRange*opacity);
4926 if ((wand->filter_off != MagickFalse) ||
4927 (CurrentContext->alpha != quantum_alpha))
4929 CurrentContext->alpha=quantum_alpha;
4930 (void) MVGPrintf(wand,
"opacity %.20g\n",opacity);
4962WandExport MagickBooleanType DrawSetFillPatternURL(
DrawingWand *wand,
4963 const char *fill_url)
4966 pattern[MagickPathExtent],
4967 pattern_spec[MagickPathExtent];
4970 assert(wand->signature == MagickWandSignature);
4971 if (wand->debug != MagickFalse)
4972 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",fill_url);
4973 if (wand->image == (Image *) NULL)
4974 ThrowDrawException(WandError,
"ContainsNoImages",wand->name);
4975 assert(fill_url != (
const char *) NULL);
4976 if (*fill_url !=
'#')
4978 ThrowDrawException(DrawError,
"NotARelativeURL",fill_url);
4979 return(MagickFalse);
4981 (void) FormatLocaleString(pattern,MagickPathExtent,
"%s",fill_url+1);
4982 if (GetImageArtifact(wand->image,pattern) == (
const char *) NULL)
4984 ThrowDrawException(DrawError,
"URLNotFound",fill_url)
4985 return(MagickFalse);
4987 (void) FormatLocaleString(pattern_spec,MagickPathExtent,
"url(%s)",fill_url);
4988#if DRAW_BINARY_IMPLEMENTATION
4989 DrawPatternPath(wand->image,CurrentContext,pattern_spec,
4990 &CurrentContext->fill_pattern,wand->exception);
4992 if (CurrentContext->fill.alpha != (
double) TransparentAlpha)
4993 CurrentContext->fill.alpha=(double) CurrentContext->alpha;
4994 (void) MVGPrintf(wand,
"fill %s\n",pattern_spec);
5022WandExport
void DrawSetFillRule(
DrawingWand *wand,
const FillRule fill_rule)
5025 assert(wand->signature == MagickWandSignature);
5026 if (wand->debug != MagickFalse)
5027 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5028 if ((wand->filter_off != MagickFalse) ||
5029 (CurrentContext->fill_rule != fill_rule))
5031 CurrentContext->fill_rule=fill_rule;
5032 (void) MVGPrintf(wand,
"fill-rule '%s'\n",CommandOptionToMnemonic(
5033 MagickFillRuleOptions,(ssize_t) fill_rule));
5062WandExport MagickBooleanType DrawSetFont(
DrawingWand *wand,
5063 const char *font_name)
5066 assert(wand->signature == MagickWandSignature);
5067 if (wand->debug != MagickFalse)
5068 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5069 assert(font_name != (
const char *) NULL);
5070 if ((wand->filter_off != MagickFalse) ||
5071 (CurrentContext->font == (
char *) NULL) ||
5072 (LocaleCompare(CurrentContext->font,font_name) != 0))
5074 (void) CloneString(&CurrentContext->font,font_name);
5075 (void) MVGPrintf(wand,
"font '%s'\n",font_name);
5105WandExport MagickBooleanType DrawSetFontFamily(
DrawingWand *wand,
5106 const char *font_family)
5109 assert(wand->signature == MagickWandSignature);
5110 if (wand->debug != MagickFalse)
5111 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5112 assert(font_family != (
const char *) NULL);
5113 if ((wand->filter_off != MagickFalse) ||
5114 (CurrentContext->family == (
const char *) NULL) ||
5115 (LocaleCompare(CurrentContext->family,font_family) != 0))
5117 (void) CloneString(&CurrentContext->family,font_family);
5118 (void) MVGPrintf(wand,
"font-family '%s'\n",font_family);
5147WandExport
void DrawSetFontSize(
DrawingWand *wand,
const double pointsize)
5150 assert(wand->signature == MagickWandSignature);
5151 if (wand->debug != MagickFalse)
5152 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5153 if ((wand->filter_off != MagickFalse) ||
5154 (fabs(CurrentContext->pointsize-pointsize) >= MagickEpsilon))
5156 CurrentContext->pointsize=pointsize;
5157 (void) MVGPrintf(wand,
"font-size %.20g\n",pointsize);
5190WandExport
void DrawSetFontStretch(
DrawingWand *wand,
5191 const StretchType font_stretch)
5194 assert(wand->signature == MagickWandSignature);
5195 if (wand->debug != MagickFalse)
5196 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5197 if ((wand->filter_off != MagickFalse) ||
5198 (CurrentContext->stretch != font_stretch))
5200 CurrentContext->stretch=font_stretch;
5201 (void) MVGPrintf(wand,
"font-stretch '%s'\n",CommandOptionToMnemonic(
5202 MagickStretchOptions,(ssize_t) font_stretch));
5231WandExport
void DrawSetFontStyle(
DrawingWand *wand,
const StyleType style)
5234 assert(wand->signature == MagickWandSignature);
5235 if (wand->debug != MagickFalse)
5236 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5237 if ((wand->filter_off != MagickFalse) ||
5238 (CurrentContext->style != style))
5240 CurrentContext->style=style;
5241 (void) MVGPrintf(wand,
"font-style '%s'\n",CommandOptionToMnemonic(
5242 MagickStyleOptions,(ssize_t) style));
5271WandExport
void DrawSetFontWeight(
DrawingWand *wand,
5272 const size_t font_weight)
5275 assert(wand->signature == MagickWandSignature);
5276 if (wand->debug != MagickFalse)
5277 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5278 if ((wand->filter_off != MagickFalse) ||
5279 (CurrentContext->weight != font_weight))
5281 CurrentContext->weight=font_weight;
5282 (void) MVGPrintf(wand,
"font-weight %.20g\n",(
double) font_weight);
5314WandExport
void DrawSetGravity(
DrawingWand *wand,
const GravityType gravity)
5317 assert(wand->signature == MagickWandSignature);
5318 if (wand->debug != MagickFalse)
5319 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5320 if ((wand->filter_off != MagickFalse) ||
5321 (CurrentContext->gravity != gravity) || (gravity != ForgetGravity))
5323 CurrentContext->gravity=gravity;
5324 (void) MVGPrintf(wand,
"gravity '%s'\n",CommandOptionToMnemonic(
5325 MagickGravityOptions,(ssize_t) gravity));
5354WandExport
void DrawSetStrokeColor(
DrawingWand *wand,
5363 assert(wand->signature == MagickWandSignature);
5364 if (wand->debug != MagickFalse)
5365 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5366 assert(stroke_wand != (
const PixelWand *) NULL);
5367 PixelGetQuantumPacket(stroke_wand,&stroke_color);
5368 new_stroke=stroke_color;
5369 current_stroke=(&CurrentContext->stroke);
5370 if ((wand->filter_off != MagickFalse) ||
5371 (IsPixelInfoEquivalent(current_stroke,&new_stroke) == MagickFalse))
5373 CurrentContext->stroke=new_stroke;
5374 (void) MVGPrintf(wand,
"stroke '");
5375 MVGAppendColor(wand,&stroke_color);
5376 (void) MVGPrintf(wand,
"'\n");
5405WandExport MagickBooleanType DrawSetStrokePatternURL(
DrawingWand *wand,
5406 const char *stroke_url)
5409 pattern[MagickPathExtent],
5410 pattern_spec[MagickPathExtent];
5413 assert(wand->signature == MagickWandSignature);
5414 if (wand->debug != MagickFalse)
5415 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5416 if (wand->image == (Image *) NULL)
5417 ThrowDrawException(WandError,
"ContainsNoImages",wand->name);
5418 assert(stroke_url != NULL);
5419 if (stroke_url[0] !=
'#')
5420 ThrowDrawException(DrawError,
"NotARelativeURL",stroke_url);
5421 (void) FormatLocaleString(pattern,MagickPathExtent,
"%s",stroke_url+1);
5422 if (GetImageArtifact(wand->image,pattern) == (
const char *) NULL)
5424 ThrowDrawException(DrawError,
"URLNotFound",stroke_url)
5425 return(MagickFalse);
5427 (void) FormatLocaleString(pattern_spec,MagickPathExtent,
"url(%s)",stroke_url);
5428#if DRAW_BINARY_IMPLEMENTATION
5429 DrawPatternPath(wand->image,CurrentContext,pattern_spec,
5430 &CurrentContext->stroke_pattern,wand->exception);
5432 if (CurrentContext->stroke.alpha != (
double) TransparentAlpha)
5433 CurrentContext->stroke.alpha=(double) CurrentContext->alpha;
5434 (void) MVGPrintf(wand,
"stroke %s\n",pattern_spec);
5466WandExport
void DrawSetStrokeAntialias(
DrawingWand *wand,
5467 const MagickBooleanType stroke_antialias)
5470 assert(wand->signature == MagickWandSignature);
5471 if (wand->debug != MagickFalse)
5472 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5473 if ((wand->filter_off != MagickFalse) ||
5474 (CurrentContext->stroke_antialias != stroke_antialias))
5476 CurrentContext->stroke_antialias=stroke_antialias;
5477 (void) MVGPrintf(wand,
"stroke-antialias %i\n",stroke_antialias != 0 ?
5515WandExport MagickBooleanType DrawSetStrokeDashArray(
DrawingWand *wand,
5516 const size_t number_elements,
const double *dasharray)
5535 assert(wand->signature == MagickWandSignature);
5536 if (wand->debug != MagickFalse)
5537 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5538 n_new=number_elements;
5539 if (dasharray == (
const double *) NULL)
5543 q=CurrentContext->dash_pattern;
5544 if (q != (
const double *) NULL)
5545 while (fabs(*q++) < MagickEpsilon)
5547 if ((n_old == 0) && (n_new == 0))
5553 if ((CurrentContext->dash_pattern != (
double *) NULL) &&
5554 (dasharray != (
double *) NULL))
5557 q=CurrentContext->dash_pattern;
5558 for (i=0; i < (ssize_t) n_new; i++)
5560 if (fabs((*p)-(*q)) >= MagickEpsilon)
5569 if ((wand->filter_off != MagickFalse) || (update != MagickFalse))
5571 if (CurrentContext->dash_pattern != (
double *) NULL)
5572 CurrentContext->dash_pattern=(
double *)
5573 RelinquishMagickMemory(CurrentContext->dash_pattern);
5576 CurrentContext->dash_pattern=(
double *) AcquireQuantumMemory((
size_t)
5577 n_new+1UL,
sizeof(*CurrentContext->dash_pattern));
5578 if (CurrentContext->dash_pattern == (
double *) NULL)
5580 ThrowDrawException(ResourceLimitError,
"MemoryAllocationFailed",
5582 return(MagickFalse);
5584 for (i=0; i < (ssize_t) n_new; i++)
5586 CurrentContext->dash_pattern[i]=0.0;
5587 if (dasharray != (
double *) NULL)
5588 CurrentContext->dash_pattern[i]=dasharray[i];
5590 CurrentContext->dash_pattern[n_new]=0.0;
5592 (void) MVGPrintf(wand,
"stroke-dasharray ");
5594 (void) MVGPrintf(wand,
"none\n");
5596 if (dasharray != (
double *) NULL)
5598 for (i=0; i < (ssize_t) n_new; i++)
5601 (void) MVGPrintf(wand,
",");
5602 (void) MVGPrintf(wand,
"%.20g",dasharray[i]);
5604 (void) MVGPrintf(wand,
"\n");
5636WandExport
void DrawSetStrokeDashOffset(
DrawingWand *wand,
5637 const double dash_offset)
5640 assert(wand->signature == MagickWandSignature);
5641 if (wand->debug != MagickFalse)
5642 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5643 if ((wand->filter_off != MagickFalse) ||
5644 (fabs(CurrentContext->dash_offset-dash_offset) >= MagickEpsilon))
5646 CurrentContext->dash_offset=dash_offset;
5647 (void) MVGPrintf(wand,
"stroke-dashoffset %.20g\n",dash_offset);
5678WandExport
void DrawSetStrokeLineCap(
DrawingWand *wand,
const LineCap linecap)
5681 assert(wand->signature == MagickWandSignature);
5682 if (wand->debug != MagickFalse)
5683 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5684 if ((wand->filter_off != MagickFalse) || (CurrentContext->linecap != linecap))
5686 CurrentContext->linecap=linecap;
5687 (void) MVGPrintf(wand,
"stroke-linecap '%s'\n",CommandOptionToMnemonic(
5688 MagickLineCapOptions,(ssize_t) linecap));
5719WandExport
void DrawSetStrokeLineJoin(
DrawingWand *wand,
const LineJoin linejoin)
5722 assert(wand->signature == MagickWandSignature);
5723 if (wand->debug != MagickFalse)
5724 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5725 if ((wand->filter_off != MagickFalse) ||
5726 (CurrentContext->linejoin != linejoin))
5728 CurrentContext->linejoin=linejoin;
5729 (void) MVGPrintf(wand,
"stroke-linejoin '%s'\n",CommandOptionToMnemonic(
5730 MagickLineJoinOptions,(ssize_t) linejoin));
5763WandExport
void DrawSetStrokeMiterLimit(
DrawingWand *wand,
5764 const size_t miterlimit)
5767 assert(wand->signature == MagickWandSignature);
5768 if (wand->debug != MagickFalse)
5769 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5770 if (CurrentContext->miterlimit != miterlimit)
5772 CurrentContext->miterlimit=miterlimit;
5773 (void) MVGPrintf(wand,
"stroke-miterlimit %.20g\n",(
double) miterlimit);
5802WandExport
void DrawSetStrokeOpacity(
DrawingWand *wand,
5803 const double opacity)
5809 assert(wand->signature == MagickWandSignature);
5810 if (wand->debug != MagickFalse)
5811 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5812 alpha=(double) ClampToQuantum((
double) QuantumRange*opacity);
5813 if ((wand->filter_off != MagickFalse) ||
5814 (CurrentContext->stroke.alpha != alpha))
5816 CurrentContext->stroke.alpha=alpha;
5817 (void) MVGPrintf(wand,
"stroke-opacity %.20g\n",opacity);
5847WandExport
void DrawSetStrokeWidth(
DrawingWand *wand,
const double stroke_width)
5850 assert(wand->signature == MagickWandSignature);
5851 if (wand->debug != MagickFalse)
5852 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5853 if ((wand->filter_off != MagickFalse) ||
5854 (fabs(CurrentContext->stroke_width-stroke_width) >= MagickEpsilon))
5856 CurrentContext->stroke_width=stroke_width;
5857 (void) MVGPrintf(wand,
"stroke-width %.20g\n",stroke_width);
5887WandExport
void DrawSetTextAlignment(
DrawingWand *wand,
5888 const AlignType alignment)
5891 assert(wand->signature == MagickWandSignature);
5892 if (wand->debug != MagickFalse)
5893 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5894 if ((wand->filter_off != MagickFalse) ||
5895 (CurrentContext->align != alignment))
5897 CurrentContext->align=alignment;
5898 (void) MVGPrintf(wand,
"text-align '%s'\n",CommandOptionToMnemonic(
5899 MagickAlignOptions,(ssize_t) alignment));
5930WandExport
void DrawSetTextAntialias(
DrawingWand *wand,
5931 const MagickBooleanType text_antialias)
5934 assert(wand->signature == MagickWandSignature);
5935 if (wand->debug != MagickFalse)
5936 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5937 if ((wand->filter_off != MagickFalse) ||
5938 (CurrentContext->text_antialias != text_antialias))
5940 CurrentContext->text_antialias=text_antialias;
5941 (void) MVGPrintf(wand,
"text-antialias %i\n",text_antialias != 0 ? 1 : 0);
5972WandExport
void DrawSetTextDecoration(
DrawingWand *wand,
5973 const DecorationType decoration)
5976 assert(wand->signature == MagickWandSignature);
5977 if (wand->debug != MagickFalse)
5978 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5979 if ((wand->filter_off != MagickFalse) ||
5980 (CurrentContext->decorate != decoration))
5982 CurrentContext->decorate=decoration;
5983 (void) MVGPrintf(wand,
"decorate '%s'\n",CommandOptionToMnemonic(
5984 MagickDecorateOptions,(ssize_t) decoration));
6015WandExport
void DrawSetTextDirection(
DrawingWand *wand,
6016 const DirectionType direction)
6019 assert(wand->signature == MagickWandSignature);
6021 if (wand->debug != MagickFalse)
6022 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6023 if ((wand->filter_off != MagickFalse) ||
6024 (CurrentContext->direction != direction))
6026 CurrentContext->direction=direction;
6027 (void) MVGPrintf(wand,
"direction '%s'\n",CommandOptionToMnemonic(
6028 MagickDirectionOptions,(ssize_t) direction));
6061WandExport
void DrawSetTextEncoding(
DrawingWand *wand,
const char *encoding)
6064 assert(wand->signature == MagickWandSignature);
6065 if (wand->debug != MagickFalse)
6066 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6067 assert(encoding != (
char *) NULL);
6068 if ((wand->filter_off != MagickFalse) ||
6069 (CurrentContext->encoding == (
char *) NULL) ||
6070 (LocaleCompare(CurrentContext->encoding,encoding) != 0))
6072 (void) CloneString(&CurrentContext->encoding,encoding);
6073 (void) MVGPrintf(wand,
"encoding '%s'\n",encoding);
6101WandExport
void DrawSetTextKerning(
DrawingWand *wand,
const double kerning)
6104 assert(wand->signature == MagickWandSignature);
6106 if (wand->debug != MagickFalse)
6107 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6108 if ((wand->filter_off != MagickFalse) &&
6109 (fabs((CurrentContext->kerning-kerning)) >= MagickEpsilon))
6111 CurrentContext->kerning=kerning;
6112 (void) MVGPrintf(wand,
"kerning %lf\n",kerning);
6141WandExport
void DrawSetTextInterlineSpacing(
DrawingWand *wand,
6142 const double interline_spacing)
6145 assert(wand->signature == MagickWandSignature);
6147 if (wand->debug != MagickFalse)
6148 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6149 if ((wand->filter_off != MagickFalse) ||
6150 (fabs((CurrentContext->interline_spacing-
6151 interline_spacing)) >= MagickEpsilon))
6153 CurrentContext->interline_spacing=interline_spacing;
6154 (void) MVGPrintf(wand,
"interline-spacing %lf\n",interline_spacing);
6183WandExport
void DrawSetTextInterwordSpacing(
DrawingWand *wand,
6184 const double interword_spacing)
6187 assert(wand->signature == MagickWandSignature);
6189 if (wand->debug != MagickFalse)
6190 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6191 if ((wand->filter_off != MagickFalse) ||
6192 (fabs((CurrentContext->interword_spacing-
6193 interword_spacing)) >= MagickEpsilon))
6195 CurrentContext->interword_spacing=interword_spacing;
6196 (void) MVGPrintf(wand,
"interword-spacing %lf\n",interword_spacing);
6226WandExport
void DrawSetTextUnderColor(
DrawingWand *wand,
6233 assert(wand->signature == MagickWandSignature);
6234 if (wand->debug != MagickFalse)
6235 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6236 assert(under_wand != (
const PixelWand *) NULL);
6237 PixelGetQuantumPacket(under_wand,&under_color);
6238 if ((wand->filter_off != MagickFalse) ||
6239 (IsPixelInfoEquivalent(&CurrentContext->undercolor,&under_color) == MagickFalse))
6241 CurrentContext->undercolor=under_color;
6242 (void) MVGPrintf(wand,
"text-undercolor '");
6243 MVGAppendColor(wand,&under_color);
6244 (void) MVGPrintf(wand,
"'\n");
6276static inline MagickBooleanType IsPoint(
const char *point)
6284 value=strtol(point,&p,10);
6286 return(p != point ? MagickTrue : MagickFalse);
6289WandExport MagickBooleanType DrawSetVectorGraphics(
DrawingWand *wand,
6300 assert(wand->signature == MagickWandSignature);
6301 if (wand->debug != MagickFalse)
6302 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6303 CurrentContext=DestroyDrawInfo(CurrentContext);
6304 CurrentContext=CloneDrawInfo((ImageInfo *) NULL,(DrawInfo *) NULL);
6305 if (xml == (
const char *) NULL)
6306 return(MagickFalse);
6307 xml_info=NewXMLTree(xml,wand->exception);
6308 if (xml_info == (XMLTreeInfo *) NULL)
6309 return(MagickFalse);
6310 child=GetXMLTreeChild(xml_info,
"clip-path");
6311 if (child != (XMLTreeInfo *) NULL)
6312 (void) CloneString(&CurrentContext->clip_mask,GetXMLTreeContent(child));
6313 child=GetXMLTreeChild(xml_info,
"clip-units");
6314 if (child != (XMLTreeInfo *) NULL)
6316 value=GetXMLTreeContent(child);
6317 if (value != (
const char *) NULL)
6318 CurrentContext->clip_units=(ClipPathUnits) ParseCommandOption(
6319 MagickClipPathOptions,MagickFalse,value);
6321 child=GetXMLTreeChild(xml_info,
"decorate");
6322 if (child != (XMLTreeInfo *) NULL)
6324 value=GetXMLTreeContent(child);
6325 if (value != (
const char *) NULL)
6326 CurrentContext->decorate=(DecorationType) ParseCommandOption(
6327 MagickDecorateOptions,MagickFalse,value);
6329 child=GetXMLTreeChild(xml_info,
"encoding");
6330 if (child != (XMLTreeInfo *) NULL)
6331 (void) CloneString(&CurrentContext->encoding,GetXMLTreeContent(child));
6332 child=GetXMLTreeChild(xml_info,
"fill");
6333 if (child != (XMLTreeInfo *) NULL)
6335 value=GetXMLTreeContent(child);
6336 if (value != (
const char *) NULL)
6337 (void) QueryColorCompliance(value,AllCompliance,&CurrentContext->fill,
6340 child=GetXMLTreeChild(xml_info,
"fill-opacity");
6341 if (child != (XMLTreeInfo *) NULL)
6343 value=GetXMLTreeContent(child);
6344 if (value != (
const char *) NULL)
6345 CurrentContext->fill.alpha=(double) ClampToQuantum((
double)
6346 QuantumRange*(1.0-StringToDouble(value,(
char **) NULL)));
6348 child=GetXMLTreeChild(xml_info,
"fill-rule");
6349 if (child != (XMLTreeInfo *) NULL)
6351 value=GetXMLTreeContent(child);
6352 if (value != (
const char *) NULL)
6353 CurrentContext->fill_rule=(FillRule) ParseCommandOption(
6354 MagickFillRuleOptions,MagickFalse,value);
6356 child=GetXMLTreeChild(xml_info,
"font");
6357 if (child != (XMLTreeInfo *) NULL)
6358 (void) CloneString(&CurrentContext->font,GetXMLTreeContent(child));
6359 child=GetXMLTreeChild(xml_info,
"font-family");
6360 if (child != (XMLTreeInfo *) NULL)
6361 (void) CloneString(&CurrentContext->family,GetXMLTreeContent(child));
6362 child=GetXMLTreeChild(xml_info,
"font-size");
6363 if (child != (XMLTreeInfo *) NULL)
6365 value=GetXMLTreeContent(child);
6366 if (value != (
const char *) NULL)
6367 CurrentContext->pointsize=StringToDouble(value,(
char **) NULL);
6369 child=GetXMLTreeChild(xml_info,
"font-stretch");
6370 if (child != (XMLTreeInfo *) NULL)
6372 value=GetXMLTreeContent(child);
6373 if (value != (
const char *) NULL)
6374 CurrentContext->stretch=(StretchType) ParseCommandOption(
6375 MagickStretchOptions,MagickFalse,value);
6377 child=GetXMLTreeChild(xml_info,
"font-style");
6378 if (child != (XMLTreeInfo *) NULL)
6380 value=GetXMLTreeContent(child);
6381 if (value != (
const char *) NULL)
6382 CurrentContext->style=(StyleType) ParseCommandOption(MagickStyleOptions,
6385 child=GetXMLTreeChild(xml_info,
"font-weight");
6386 if (child != (XMLTreeInfo *) NULL)
6388 value=GetXMLTreeContent(child);
6389 if (value != (
const char *) NULL)
6394 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,value);
6396 weight=(ssize_t) StringToUnsignedLong(value);
6397 CurrentContext->weight=(size_t) weight;
6400 child=GetXMLTreeChild(xml_info,
"gravity");
6401 if (child != (XMLTreeInfo *) NULL)
6403 value=GetXMLTreeContent(child);
6404 if (value != (
const char *) NULL)
6405 CurrentContext->gravity=(GravityType) ParseCommandOption(
6406 MagickGravityOptions,MagickFalse,value);
6408 child=GetXMLTreeChild(xml_info,
"stroke");
6409 if (child != (XMLTreeInfo *) NULL)
6411 value=GetXMLTreeContent(child);
6412 if (value != (
const char *) NULL)
6413 (void) QueryColorCompliance(value,AllCompliance,&CurrentContext->stroke,
6416 child=GetXMLTreeChild(xml_info,
"stroke-antialias");
6417 if (child != (XMLTreeInfo *) NULL)
6419 value=GetXMLTreeContent(child);
6420 if (value != (
const char *) NULL)
6421 CurrentContext->stroke_antialias=StringToLong(value) != 0 ? MagickTrue :
6424 child=GetXMLTreeChild(xml_info,
"stroke-dasharray");
6425 if (child != (XMLTreeInfo *) NULL)
6428 token[MagickPathExtent];
6439 value=GetXMLTreeContent(child);
6440 if (value != (
const char *) NULL)
6442 if (CurrentContext->dash_pattern != (
double *) NULL)
6443 CurrentContext->dash_pattern=(
double *) RelinquishMagickMemory(
6444 CurrentContext->dash_pattern);
6446 if (IsPoint(q) != MagickFalse)
6452 (void) GetNextToken(p,&p,MagickPathExtent,token);
6454 (void) GetNextToken(p,&p,MagickPathExtent,token);
6455 for (x=0; IsPoint(token) != MagickFalse; x++)
6457 (void) GetNextToken(p,&p,MagickPathExtent,token);
6459 (void) GetNextToken(p,&p,MagickPathExtent,token);
6461 CurrentContext->dash_pattern=(
double *) AcquireQuantumMemory(
6462 (
size_t) (2*x)+1UL,
sizeof(*CurrentContext->dash_pattern));
6463 if (CurrentContext->dash_pattern == (
double *) NULL)
6464 ThrowWandFatalException(ResourceLimitFatalError,
6465 "MemoryAllocationFailed",wand->name);
6466 for (j=0; j < x; j++)
6468 (void) GetNextToken(q,&q,MagickPathExtent,token);
6470 (void) GetNextToken(q,&q,MagickPathExtent,token);
6471 CurrentContext->dash_pattern[j]=StringToDouble(token,
6474 if ((x & 0x01) != 0)
6475 for ( ; j < (2*x); j++)
6476 CurrentContext->dash_pattern[j]=
6477 CurrentContext->dash_pattern[j-x];
6478 CurrentContext->dash_pattern[j]=0.0;
6482 child=GetXMLTreeChild(xml_info,
"stroke-dashoffset");
6483 if (child != (XMLTreeInfo *) NULL)
6485 value=GetXMLTreeContent(child);
6486 if (value != (
const char *) NULL)
6487 CurrentContext->dash_offset=StringToDouble(value,(
char **) NULL);
6489 child=GetXMLTreeChild(xml_info,
"stroke-linecap");
6490 if (child != (XMLTreeInfo *) NULL)
6492 value=GetXMLTreeContent(child);
6493 if (value != (
const char *) NULL)
6494 CurrentContext->linecap=(LineCap) ParseCommandOption(
6495 MagickLineCapOptions,MagickFalse,value);
6497 child=GetXMLTreeChild(xml_info,
"stroke-linejoin");
6498 if (child != (XMLTreeInfo *) NULL)
6500 value=GetXMLTreeContent(child);
6501 if (value != (
const char *) NULL)
6502 CurrentContext->linejoin=(LineJoin) ParseCommandOption(
6503 MagickLineJoinOptions,MagickFalse,value);
6505 child=GetXMLTreeChild(xml_info,
"stroke-miterlimit");
6506 if (child != (XMLTreeInfo *) NULL)
6508 value=GetXMLTreeContent(child);
6509 if (value != (
const char *) NULL)
6510 CurrentContext->miterlimit=StringToUnsignedLong(value);
6512 child=GetXMLTreeChild(xml_info,
"stroke-opacity");
6513 if (child != (XMLTreeInfo *) NULL)
6515 value=GetXMLTreeContent(child);
6516 if (value != (
const char *) NULL)
6517 CurrentContext->stroke.alpha=(double) ClampToQuantum((
double)
6518 QuantumRange*(1.0-StringToDouble(value,(
char **) NULL)));
6520 child=GetXMLTreeChild(xml_info,
"stroke-width");
6521 if (child != (XMLTreeInfo *) NULL)
6523 value=GetXMLTreeContent(child);
6524 if (value != (
const char *) NULL)
6529 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,value);
6531 weight=(ssize_t) StringToUnsignedLong(value);
6532 CurrentContext->stroke_width=(double) weight;
6535 child=GetXMLTreeChild(xml_info,
"text-align");
6536 if (child != (XMLTreeInfo *) NULL)
6538 value=GetXMLTreeContent(child);
6539 if (value != (
const char *) NULL)
6540 CurrentContext->align=(AlignType) ParseCommandOption(MagickAlignOptions,
6543 child=GetXMLTreeChild(xml_info,
"text-antialias");
6544 if (child != (XMLTreeInfo *) NULL)
6546 value=GetXMLTreeContent(child);
6547 if (value != (
const char *) NULL)
6548 CurrentContext->text_antialias=StringToLong(value) != 0 ? MagickTrue :
6551 child=GetXMLTreeChild(xml_info,
"text-undercolor");
6552 if (child != (XMLTreeInfo *) NULL)
6554 value=GetXMLTreeContent(child);
6555 if (value != (
const char *) NULL)
6556 (void) QueryColorCompliance(value,AllCompliance,
6557 &CurrentContext->undercolor,wand->exception);
6559 child=GetXMLTreeChild(xml_info,
"vector-graphics");
6560 if (child != (XMLTreeInfo *) NULL)
6562 (void) CloneString(&wand->mvg,GetXMLTreeContent(child));
6563 wand->mvg_length=strlen(wand->mvg);
6564 wand->mvg_alloc=wand->mvg_length+1;
6566 xml_info=DestroyXMLTree(xml_info);
6595WandExport
void DrawSkewX(
DrawingWand *wand,
const double degrees)
6598 assert(wand->signature == MagickWandSignature);
6599 if (wand->debug != MagickFalse)
6600 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6601 (void) MVGPrintf(wand,
"skewX %.20g\n",degrees);
6629WandExport
void DrawSkewY(
DrawingWand *wand,
const double degrees)
6632 assert(wand->signature == MagickWandSignature);
6633 if (wand->debug != MagickFalse)
6634 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6635 (void) MVGPrintf(wand,
"skewY %.20g\n",degrees);
6667WandExport
void DrawTranslate(
DrawingWand *wand,
const double x,
const double y)
6670 assert(wand->signature == MagickWandSignature);
6671 if (wand->debug != MagickFalse)
6672 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6673 (void) MVGPrintf(wand,
"translate %.20g %.20g\n",x,y);
6711WandExport
void DrawSetViewbox(
DrawingWand *wand,
const double x1,
6712 const double y1,
const double x2,
const double y2)
6715 assert(wand->signature == MagickWandSignature);
6716 if (wand->debug != MagickFalse)
6717 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6718 (void) MVGPrintf(wand,
"viewbox %.20g %.20g %.20g %.20g\n",x1,y1,x2,y2);
6743WandExport MagickBooleanType IsDrawingWand(
const DrawingWand *wand)
6746 return(MagickFalse);
6747 if (wand->signature != MagickWandSignature)
6748 return(MagickFalse);
6749 if (LocaleNCompare(wand->name,DrawingWandId,strlen(DrawingWandId)) != 0)
6750 return(MagickFalse);
6778 CheckMagickCoreCompatibility();
6779 wand=(
DrawingWand *) AcquireMagickMemory(
sizeof(*wand));
6781 ThrowWandFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
6782 GetExceptionMessage(errno));
6783 (void) memset(wand,0,
sizeof(*wand));
6784 wand->id=AcquireWandId();
6785 (void) FormatLocaleString(wand->name,MagickPathExtent,
"%s-%.20g",
6786 DrawingWandId,(
double) wand->id);
6787 if (wand->debug != MagickFalse)
6788 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6789 wand->mvg=(
char *) NULL;
6793 wand->pattern_id=(
char *) NULL;
6794 wand->pattern_offset=0;
6795 wand->pattern_bounds.x=0;
6796 wand->pattern_bounds.y=0;
6797 wand->pattern_bounds.width=0;
6798 wand->pattern_bounds.height=0;
6800 wand->graphic_context=(DrawInfo **) AcquireMagickMemory(
sizeof(
6801 *wand->graphic_context));
6802 if (wand->graphic_context == (DrawInfo **) NULL)
6803 ThrowWandFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
6804 GetExceptionMessage(errno));
6805 wand->filter_off=MagickTrue;
6806 wand->indent_depth=0;
6807 wand->path_operation=PathDefaultOperation;
6808 wand->path_mode=DefaultPathMode;
6809 wand->exception=AcquireExceptionInfo();
6810 wand->image=AcquireImage((
const ImageInfo *) NULL,wand->exception);
6811 wand->destroy=MagickTrue;
6812 wand->debug=IsEventLogging();
6813 wand->signature=MagickWandSignature;
6814 CurrentContext=CloneDrawInfo((ImageInfo *) NULL,(DrawInfo *) NULL);
6840WandExport DrawInfo *PeekDrawingWand(
const DrawingWand *wand)
6846 assert(wand->signature == MagickWandSignature);
6847 if (wand->debug != MagickFalse)
6848 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6849 draw_info=CloneDrawInfo((ImageInfo *) NULL,CurrentContext);
6850 (void) CloneString(&draw_info->primitive,wand->mvg);
6879WandExport MagickBooleanType PopDrawingWand(
DrawingWand *wand)
6882 assert(wand->signature == MagickWandSignature);
6883 if (wand->debug != MagickFalse)
6884 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6885 if (wand->index == 0)
6887 ThrowDrawException(DrawError,
"UnbalancedGraphicContextPushPop",wand->name)
6888 return(MagickFalse);
6893#if DRAW_BINARY_IMPLEMENTATION
6894 if (wand->image == (Image *) NULL)
6895 ThrowDrawException(WandError,
"ContainsNoImages",wand->name);
6896 if (CurrentContext->clip_mask != (
char *) NULL)
6897 if (LocaleCompare(CurrentContext->clip_mask,
6898 wand->graphic_context[wand->index-1]->clip_mask) != 0)
6899 (
void) SetImageMask(wand->image,WritePixelMask,(Image *) NULL,
6902 CurrentContext=DestroyDrawInfo(CurrentContext);
6904 if (wand->indent_depth > 0)
6905 wand->indent_depth--;
6906 (
void) MVGPrintf(wand,
"pop graphic-context\n");
6935WandExport MagickBooleanType PushDrawingWand(
DrawingWand *wand)
6938 assert(wand->signature == MagickWandSignature);
6939 if (wand->debug != MagickFalse)
6940 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6942 wand->graphic_context=(DrawInfo **) ResizeQuantumMemory(wand->graphic_context,
6943 (
size_t) wand->index+1UL,
sizeof(*wand->graphic_context));
6944 if (wand->graphic_context == (DrawInfo **) NULL)
6947 ThrowDrawException(ResourceLimitError,
"MemoryAllocationFailed",
6949 return(MagickFalse);
6951 CurrentContext=CloneDrawInfo((ImageInfo *) NULL,
6952 wand->graphic_context[wand->index-1]);
6953 (void) MVGPrintf(wand,
"push graphic-context\n");
6954 wand->indent_depth++;