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)
1936 assert(wand->signature == MagickWandSignature);
1937 if (wand->debug != MagickFalse)
1938 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1939 assert(number_elements != (
size_t *) NULL);
1941 p=CurrentContext->dash_pattern;
1942 if (p != (
const double *) NULL)
1943 while (fabs(*p++) >= MagickEpsilon)
1946 dasharray=(
double *) NULL;
1949 dasharray=(
double *) AcquireQuantumMemory((
size_t) n+1UL,
1950 sizeof(*dasharray));
1951 if (dasharray != (
double *) NULL)
1953 p=CurrentContext->dash_pattern;
1955 for (i=0; i < (ssize_t) n; i++)
1986WandExport
double DrawGetStrokeDashOffset(
const DrawingWand *wand)
1989 assert(wand->signature == MagickWandSignature);
1990 if (wand->debug != MagickFalse)
1991 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1992 return(CurrentContext->dash_offset);
2019WandExport LineCap DrawGetStrokeLineCap(
const DrawingWand *wand)
2022 assert(wand->signature == MagickWandSignature);
2023 if (wand->debug != MagickFalse)
2024 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2025 return(CurrentContext->linecap);
2053WandExport LineJoin DrawGetStrokeLineJoin(
const DrawingWand *wand)
2056 assert(wand->signature == MagickWandSignature);
2057 if (wand->debug != MagickFalse)
2058 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2059 return(CurrentContext->linejoin);
2088WandExport
size_t DrawGetStrokeMiterLimit(
const DrawingWand *wand)
2091 assert(wand->signature == MagickWandSignature);
2092 if (wand->debug != MagickFalse)
2093 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2094 return CurrentContext->miterlimit;
2119WandExport
double DrawGetStrokeOpacity(
const DrawingWand *wand)
2125 assert(wand->signature == MagickWandSignature);
2126 if (wand->debug != MagickFalse)
2127 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2128 alpha=(double) QuantumScale*CurrentContext->stroke.alpha;
2155WandExport
double DrawGetStrokeWidth(
const DrawingWand *wand)
2158 assert(wand->signature == MagickWandSignature);
2159 if (wand->debug != MagickFalse)
2160 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2161 return(CurrentContext->stroke_width);
2187WandExport AlignType DrawGetTextAlignment(
const DrawingWand *wand)
2190 assert(wand->signature == MagickWandSignature);
2191 if (wand->debug != MagickFalse)
2192 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2193 return(CurrentContext->align);
2219WandExport MagickBooleanType DrawGetTextAntialias(
const DrawingWand *wand)
2222 assert(wand->signature == MagickWandSignature);
2223 if (wand->debug != MagickFalse)
2224 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2225 return(CurrentContext->text_antialias);
2251WandExport DecorationType DrawGetTextDecoration(
const DrawingWand *wand)
2254 assert(wand->signature == MagickWandSignature);
2255 if (wand->debug != MagickFalse)
2256 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2257 return(CurrentContext->decorate);
2283WandExport DirectionType DrawGetTextDirection(
const DrawingWand *wand)
2286 assert(wand->signature == MagickWandSignature);
2287 if (wand->debug != MagickFalse)
2288 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2289 return(CurrentContext->direction);
2316WandExport
char *DrawGetTextEncoding(
const DrawingWand *wand)
2319 assert(wand->signature == MagickWandSignature);
2320 if (wand->debug != MagickFalse)
2321 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2322 if (CurrentContext->encoding != (
char *) NULL)
2323 return((
char *) AcquireString(CurrentContext->encoding));
2324 return((
char *) NULL);
2349WandExport
double DrawGetTextKerning(
DrawingWand *wand)
2352 assert(wand->signature == MagickWandSignature);
2354 if (wand->debug != MagickFalse)
2355 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2356 return(CurrentContext->kerning);
2381WandExport
double DrawGetTextInterlineSpacing(
DrawingWand *wand)
2384 assert(wand->signature == MagickWandSignature);
2385 if (wand->debug != MagickFalse)
2386 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2387 return(CurrentContext->interline_spacing);
2412WandExport
double DrawGetTextInterwordSpacing(
DrawingWand *wand)
2415 assert(wand->signature == MagickWandSignature);
2416 if (wand->debug != MagickFalse)
2417 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2418 return(CurrentContext->interword_spacing);
2470WandExport MagickBooleanType DrawGetTypeMetrics(
const DrawingWand *wand,
2471 const char *text,MagickBooleanType ignore_newlines,TypeMetric *metrics)
2480 assert(wand->signature == MagickWandSignature);
2481 if (wand->debug != MagickFalse)
2482 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2483 draw_info=PeekDrawingWand(wand);
2484 if (draw_info == (DrawInfo *) NULL)
2485 return(MagickFalse);
2486 (void) CloneString(&draw_info->text,text);
2487 if (ignore_newlines != MagickFalse)
2488 status=GetTypeMetrics(wand->image,draw_info,metrics,wand->exception);
2490 status=GetMultilineTypeMetrics(wand->image,draw_info,metrics,
2492 draw_info=DestroyDrawInfo(draw_info);
2521WandExport
char *DrawGetVectorGraphics(
DrawingWand *wand)
2524 value[MagickPathExtent],
2538 assert(wand->signature == MagickWandSignature);
2539 if (wand->debug != MagickFalse)
2540 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2541 xml_info=NewXMLTreeTag(
"drawing-wand");
2542 if (xml_info == (XMLTreeInfo *) NULL)
2543 return((
char *) NULL);
2544 (void) SetXMLTreeContent(xml_info,
" ");
2545 GetPixelInfo(wand->image,&pixel);
2546 child=AddChildToXMLTree(xml_info,
"clip-path",0);
2547 if (child != (XMLTreeInfo *) NULL)
2548 (void) SetXMLTreeContent(child,CurrentContext->clip_mask);
2549 child=AddChildToXMLTree(xml_info,
"clip-units",0);
2550 if (child != (XMLTreeInfo *) NULL)
2552 (void) CopyMagickString(value,CommandOptionToMnemonic(
2553 MagickClipPathOptions,(ssize_t) CurrentContext->clip_units),
2555 (void) SetXMLTreeContent(child,value);
2557 child=AddChildToXMLTree(xml_info,
"decorate",0);
2558 if (child != (XMLTreeInfo *) NULL)
2560 (void) CopyMagickString(value,CommandOptionToMnemonic(
2561 MagickDecorateOptions,(ssize_t) CurrentContext->decorate),
2563 (void) SetXMLTreeContent(child,value);
2565 child=AddChildToXMLTree(xml_info,
"encoding",0);
2566 if (child != (XMLTreeInfo *) NULL)
2567 (void) SetXMLTreeContent(child,CurrentContext->encoding);
2568 child=AddChildToXMLTree(xml_info,
"fill",0);
2569 if (child != (XMLTreeInfo *) NULL)
2571 if (CurrentContext->fill.alpha != (
double) OpaqueAlpha)
2572 pixel.alpha_trait=CurrentContext->fill.alpha != (double) OpaqueAlpha ?
2573 BlendPixelTrait : UndefinedPixelTrait;
2574 pixel=CurrentContext->fill;
2575 GetColorTuple(&pixel,MagickTrue,value);
2576 (void) SetXMLTreeContent(child,value);
2578 child=AddChildToXMLTree(xml_info,
"fill-opacity",0);
2579 if (child != (XMLTreeInfo *) NULL)
2581 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2582 (
double) (QuantumScale*CurrentContext->fill.alpha));
2583 (void) SetXMLTreeContent(child,value);
2585 child=AddChildToXMLTree(xml_info,
"fill-rule",0);
2586 if (child != (XMLTreeInfo *) NULL)
2588 (void) CopyMagickString(value,CommandOptionToMnemonic(
2589 MagickFillRuleOptions,(ssize_t) CurrentContext->fill_rule),
2591 (void) SetXMLTreeContent(child,value);
2593 child=AddChildToXMLTree(xml_info,
"font",0);
2594 if (child != (XMLTreeInfo *) NULL)
2595 (void) SetXMLTreeContent(child,CurrentContext->font);
2596 child=AddChildToXMLTree(xml_info,
"font-family",0);
2597 if (child != (XMLTreeInfo *) NULL)
2598 (void) SetXMLTreeContent(child,CurrentContext->family);
2599 child=AddChildToXMLTree(xml_info,
"font-size",0);
2600 if (child != (XMLTreeInfo *) NULL)
2602 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2603 CurrentContext->pointsize);
2604 (void) SetXMLTreeContent(child,value);
2606 child=AddChildToXMLTree(xml_info,
"font-stretch",0);
2607 if (child != (XMLTreeInfo *) NULL)
2609 (void) CopyMagickString(value,CommandOptionToMnemonic(
2610 MagickStretchOptions,(ssize_t) CurrentContext->stretch),
2612 (void) SetXMLTreeContent(child,value);
2614 child=AddChildToXMLTree(xml_info,
"font-style",0);
2615 if (child != (XMLTreeInfo *) NULL)
2617 (void) CopyMagickString(value,CommandOptionToMnemonic(
2618 MagickStyleOptions,(ssize_t) CurrentContext->style),MagickPathExtent);
2619 (void) SetXMLTreeContent(child,value);
2621 child=AddChildToXMLTree(xml_info,
"font-weight",0);
2622 if (child != (XMLTreeInfo *) NULL)
2624 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2625 CurrentContext->weight);
2626 (void) SetXMLTreeContent(child,value);
2628 child=AddChildToXMLTree(xml_info,
"gravity",0);
2629 if (child != (XMLTreeInfo *) NULL)
2631 (void) CopyMagickString(value,CommandOptionToMnemonic(
2632 MagickGravityOptions,(ssize_t) CurrentContext->gravity),
2634 (void) SetXMLTreeContent(child,value);
2636 child=AddChildToXMLTree(xml_info,
"stroke",0);
2637 if (child != (XMLTreeInfo *) NULL)
2639 if (CurrentContext->stroke.alpha != (
double) OpaqueAlpha)
2640 pixel.alpha_trait=CurrentContext->stroke.alpha != (double) OpaqueAlpha ?
2641 BlendPixelTrait : UndefinedPixelTrait;
2642 pixel=CurrentContext->stroke;
2643 GetColorTuple(&pixel,MagickTrue,value);
2644 (void) SetXMLTreeContent(child,value);
2646 child=AddChildToXMLTree(xml_info,
"stroke-antialias",0);
2647 if (child != (XMLTreeInfo *) NULL)
2649 (void) FormatLocaleString(value,MagickPathExtent,
"%d",
2650 CurrentContext->stroke_antialias != MagickFalse ? 1 : 0);
2651 (void) SetXMLTreeContent(child,value);
2653 child=AddChildToXMLTree(xml_info,
"stroke-dasharray",0);
2654 if ((child != (XMLTreeInfo *) NULL) &&
2655 (CurrentContext->dash_pattern != (
double *) NULL))
2660 dash_pattern=AcquireString((
char *) NULL);
2661 for (i=0; fabs(CurrentContext->dash_pattern[i]) >= MagickEpsilon; i++)
2664 (void) ConcatenateString(&dash_pattern,
",");
2665 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2666 CurrentContext->dash_pattern[i]);
2667 (void) ConcatenateString(&dash_pattern,value);
2669 (void) SetXMLTreeContent(child,dash_pattern);
2670 dash_pattern=DestroyString(dash_pattern);
2672 child=AddChildToXMLTree(xml_info,
"stroke-dashoffset",0);
2673 if (child != (XMLTreeInfo *) NULL)
2675 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2676 CurrentContext->dash_offset);
2677 (void) SetXMLTreeContent(child,value);
2679 child=AddChildToXMLTree(xml_info,
"stroke-linecap",0);
2680 if (child != (XMLTreeInfo *) NULL)
2682 (void) CopyMagickString(value,CommandOptionToMnemonic(
2683 MagickLineCapOptions,(ssize_t) CurrentContext->linecap),
2685 (void) SetXMLTreeContent(child,value);
2687 child=AddChildToXMLTree(xml_info,
"stroke-linejoin",0);
2688 if (child != (XMLTreeInfo *) NULL)
2690 (void) CopyMagickString(value,CommandOptionToMnemonic(
2691 MagickLineJoinOptions,(ssize_t) CurrentContext->linejoin),
2693 (void) SetXMLTreeContent(child,value);
2695 child=AddChildToXMLTree(xml_info,
"stroke-miterlimit",0);
2696 if (child != (XMLTreeInfo *) NULL)
2698 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2699 CurrentContext->miterlimit);
2700 (void) SetXMLTreeContent(child,value);
2702 child=AddChildToXMLTree(xml_info,
"stroke-opacity",0);
2703 if (child != (XMLTreeInfo *) NULL)
2705 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2706 (
double) (QuantumScale*CurrentContext->stroke.alpha));
2707 (void) SetXMLTreeContent(child,value);
2709 child=AddChildToXMLTree(xml_info,
"stroke-width",0);
2710 if (child != (XMLTreeInfo *) NULL)
2712 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2713 CurrentContext->stroke_width);
2714 (void) SetXMLTreeContent(child,value);
2716 child=AddChildToXMLTree(xml_info,
"text-align",0);
2717 if (child != (XMLTreeInfo *) NULL)
2719 (void) CopyMagickString(value,CommandOptionToMnemonic(MagickAlignOptions,
2720 (ssize_t) CurrentContext->align),MagickPathExtent);
2721 (void) SetXMLTreeContent(child,value);
2723 child=AddChildToXMLTree(xml_info,
"text-antialias",0);
2724 if (child != (XMLTreeInfo *) NULL)
2726 (void) FormatLocaleString(value,MagickPathExtent,
"%d",
2727 CurrentContext->text_antialias != MagickFalse ? 1 : 0);
2728 (void) SetXMLTreeContent(child,value);
2730 child=AddChildToXMLTree(xml_info,
"text-undercolor",0);
2731 if (child != (XMLTreeInfo *) NULL)
2733 if (CurrentContext->undercolor.alpha != (
double) OpaqueAlpha)
2734 pixel.alpha_trait=CurrentContext->undercolor.alpha != (double) OpaqueAlpha ?
2735 BlendPixelTrait : UndefinedPixelTrait;
2736 pixel=CurrentContext->undercolor;
2737 GetColorTuple(&pixel,MagickTrue,value);
2738 (void) SetXMLTreeContent(child,value);
2740 child=AddChildToXMLTree(xml_info,
"vector-graphics",0);
2741 if (child != (XMLTreeInfo *) NULL)
2742 (void) SetXMLTreeContent(child,wand->mvg);
2743 xml=XMLTreeInfoToXML(xml_info);
2744 xml_info=DestroyXMLTree(xml_info);
2774WandExport
void DrawGetTextUnderColor(
const DrawingWand *wand,
2778 assert(wand->signature == MagickWandSignature);
2779 assert(under_color != (
PixelWand *) NULL);
2780 if (wand->debug != MagickFalse)
2781 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2782 PixelSetPixelColor(under_color,&CurrentContext->undercolor);
2817WandExport
void DrawLine(
DrawingWand *wand,
const double sx,
const double sy,
2818 const double ex,
const double ey)
2821 assert(wand->signature == MagickWandSignature);
2822 if (wand->debug != MagickFalse)
2823 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2824 (void) MVGPrintf(wand,
"line %.20g %.20g %.20g %.20g\n",sx,sy,ex,ey);
2855 assert(wand->signature == MagickWandSignature);
2856 if (wand->debug != MagickFalse)
2857 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2858 (void) MVGAutoWrapPrintf(wand,
"%s",wand->path_mode == AbsolutePathMode ?
2903static void DrawPathCurveTo(
DrawingWand *wand,
const PathMode mode,
2904 const double x1,
const double y1,
const double x2,
const double y2,
2905 const double x,
const double y)
2908 assert(wand->signature == MagickWandSignature);
2909 if (wand->debug != MagickFalse)
2910 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2911 if ((wand->path_operation != PathCurveToOperation) ||
2912 (wand->path_mode != mode))
2914 wand->path_operation=PathCurveToOperation;
2915 wand->path_mode=mode;
2916 (void) MVGAutoWrapPrintf(wand,
"%c%.20g %.20g %.20g %.20g %.20g %.20g",
2917 mode == AbsolutePathMode ?
'C' :
'c',x1,y1,x2,y2,x,y);
2920 (
void) MVGAutoWrapPrintf(wand,
" %.20g %.20g %.20g %.20g %.20g %.20g",x1,y1,
2924WandExport
void DrawPathCurveToAbsolute(
DrawingWand *wand,
const double x1,
2925 const double y1,
const double x2,
const double y2,
const double x,
const double y)
2928 assert(wand->signature == MagickWandSignature);
2929 if (wand->debug != MagickFalse)
2930 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2931 DrawPathCurveTo(wand,AbsolutePathMode,x1,y1,x2,y2,x,y);
2974WandExport
void DrawPathCurveToRelative(
DrawingWand *wand,
const double x1,
2975 const double y1,
const double x2,
const double y2,
const double x,
const double y)
2978 assert(wand->signature == MagickWandSignature);
2979 if (wand->debug != MagickFalse)
2980 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2981 DrawPathCurveTo(wand,RelativePathMode,x1,y1,x2,y2,x,y);
3019static void DrawPathCurveToQuadraticBezier(
DrawingWand *wand,
3020 const PathMode mode,
const double x1,
double y1,
const double x,
const double y)
3023 assert(wand->signature == MagickWandSignature);
3024 if (wand->debug != MagickFalse)
3025 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3026 if ((wand->path_operation != PathCurveToQuadraticBezierOperation) ||
3027 (wand->path_mode != mode))
3029 wand->path_operation=PathCurveToQuadraticBezierOperation;
3030 wand->path_mode=mode;
3031 (void) MVGAutoWrapPrintf(wand,
"%c%.20g %.20g %.20g %.20g",
3032 mode == AbsolutePathMode ?
'Q' :
'q',x1,y1,x,y);
3035 (
void) MVGAutoWrapPrintf(wand,
" %.20g %.20g %.20g %.20g",x1,y1,x,y);
3038WandExport
void DrawPathCurveToQuadraticBezierAbsolute(
DrawingWand *wand,
3039 const double x1,
const double y1,
const double x,
const double y)
3042 assert(wand->signature == MagickWandSignature);
3043 if (wand->debug != MagickFalse)
3044 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3045 DrawPathCurveToQuadraticBezier(wand,AbsolutePathMode,x1,y1,x,y);
3082WandExport
void DrawPathCurveToQuadraticBezierRelative(
DrawingWand *wand,
3083 const double x1,
const double y1,
const double x,
const double y)
3086 assert(wand->signature == MagickWandSignature);
3087 if (wand->debug != MagickFalse)
3088 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3089 DrawPathCurveToQuadraticBezier(wand,RelativePathMode,x1,y1,x,y);
3131static void DrawPathCurveToQuadraticBezierSmooth(
DrawingWand *wand,
3132 const PathMode mode,
const double x,
const double y)
3135 assert(wand->signature == MagickWandSignature);
3136 if (wand->debug != MagickFalse)
3137 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3138 if ((wand->path_operation != PathCurveToQuadraticBezierSmoothOperation) ||
3139 (wand->path_mode != mode))
3141 wand->path_operation=PathCurveToQuadraticBezierSmoothOperation;
3142 wand->path_mode=mode;
3143 (void) MVGAutoWrapPrintf(wand,
"%c%.20g %.20g",mode == AbsolutePathMode ?
3147 (
void) MVGAutoWrapPrintf(wand,
" %.20g %.20g",x,y);
3150WandExport
void DrawPathCurveToQuadraticBezierSmoothAbsolute(
DrawingWand *wand,
3151 const double x,
const double y)
3154 assert(wand->signature == MagickWandSignature);
3155 if (wand->debug != MagickFalse)
3156 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3157 DrawPathCurveToQuadraticBezierSmooth(wand,AbsolutePathMode,x,y);
3197WandExport
void DrawPathCurveToQuadraticBezierSmoothRelative(
DrawingWand *wand,
3198 const double x,
const double y)
3200 DrawPathCurveToQuadraticBezierSmooth(wand,RelativePathMode,x,y);
3245static void DrawPathCurveToSmooth(
DrawingWand *wand,
const PathMode mode,
3246 const double x2,
const double y2,
const double x,
const double y)
3249 assert(wand->signature == MagickWandSignature);
3250 if (wand->debug != MagickFalse)
3251 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3252 if ((wand->path_operation != PathCurveToSmoothOperation) ||
3253 (wand->path_mode != mode))
3255 wand->path_operation=PathCurveToSmoothOperation;
3256 wand->path_mode=mode;
3257 (void) MVGAutoWrapPrintf(wand,
"%c%.20g %.20g %.20g %.20g",
3258 mode == AbsolutePathMode ?
'S' :
's',x2,y2,x,y);
3261 (
void) MVGAutoWrapPrintf(wand,
" %.20g %.20g %.20g %.20g",x2,y2,x,y);
3264WandExport
void DrawPathCurveToSmoothAbsolute(
DrawingWand *wand,
const double x2,
3265 const double y2,
const double x,
const double y)
3268 assert(wand->signature == MagickWandSignature);
3269 if (wand->debug != MagickFalse)
3270 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3271 DrawPathCurveToSmooth(wand,AbsolutePathMode,x2,y2,x,y);
3314WandExport
void DrawPathCurveToSmoothRelative(
DrawingWand *wand,
const double x2,
3315 const double y2,
const double x,
const double y)
3318 assert(wand->signature == MagickWandSignature);
3319 if (wand->debug != MagickFalse)
3320 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3321 DrawPathCurveToSmooth(wand,RelativePathMode,x2,y2,x,y);
3373static void DrawPathEllipticArc(
DrawingWand *wand,
const PathMode mode,
3374 const double rx,
const double ry,
const double x_axis_rotation,
3375 const MagickBooleanType large_arc_flag,
const MagickBooleanType sweep_flag,
3376 const double x,
const double y)
3379 assert(wand->signature == MagickWandSignature);
3380 if (wand->debug != MagickFalse)
3381 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3382 if ((wand->path_operation != PathEllipticArcOperation) ||
3383 (wand->path_mode != mode))
3385 wand->path_operation=PathEllipticArcOperation;
3386 wand->path_mode=mode;
3387 (void) MVGAutoWrapPrintf(wand,
"%c%.20g %.20g %.20g %u %u %.20g %.20g",
3388 mode == AbsolutePathMode ?
'A' :
'a',rx,ry,x_axis_rotation,
3389 large_arc_flag,sweep_flag,x,y);
3392 (
void) MVGAutoWrapPrintf(wand,
" %.20g %.20g %.20g %u %u %.20g %.20g",rx,ry,
3393 x_axis_rotation,large_arc_flag,sweep_flag,x,y);
3396WandExport
void DrawPathEllipticArcAbsolute(
DrawingWand *wand,
const double rx,
3397 const double ry,
const double x_axis_rotation,
3398 const MagickBooleanType large_arc_flag,
const MagickBooleanType sweep_flag,
3399 const double x,
const double y)
3402 assert(wand->signature == MagickWandSignature);
3403 if (wand->debug != MagickFalse)
3404 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3405 DrawPathEllipticArc(wand,AbsolutePathMode,rx,ry,x_axis_rotation,
3406 large_arc_flag,sweep_flag,x,y);
3456WandExport
void DrawPathEllipticArcRelative(
DrawingWand *wand,
const double rx,
3457 const double ry,
const double x_axis_rotation,
3458 const MagickBooleanType large_arc_flag,
const MagickBooleanType sweep_flag,
3459 const double x,
const double y)
3461 DrawPathEllipticArc(wand,RelativePathMode,rx,ry,x_axis_rotation,
3462 large_arc_flag,sweep_flag,x,y);
3490 assert(wand->signature == MagickWandSignature);
3491 if (wand->debug != MagickFalse)
3492 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3493 (void) MVGPrintf(wand,
"'\n");
3494 wand->path_operation=PathDefaultOperation;
3495 wand->path_mode=DefaultPathMode;
3527static void DrawPathLineTo(
DrawingWand *wand,
const PathMode mode,
3528 const double x,
const double y)
3531 assert(wand->signature == MagickWandSignature);
3532 if (wand->debug != MagickFalse)
3533 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3534 if ((wand->path_operation != PathLineToOperation) ||
3535 (wand->path_mode != mode))
3537 wand->path_operation=PathLineToOperation;
3538 wand->path_mode=mode;
3539 (void) MVGAutoWrapPrintf(wand,
"%c%.20g %.20g",mode == AbsolutePathMode ?
3543 (
void) MVGAutoWrapPrintf(wand,
" %.20g %.20g",x,y);
3546WandExport
void DrawPathLineToAbsolute(
DrawingWand *wand,
const double x,
3550 assert(wand->signature == MagickWandSignature);
3551 if (wand->debug != MagickFalse)
3552 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3553 DrawPathLineTo(wand,AbsolutePathMode,x,y);
3585WandExport
void DrawPathLineToRelative(
DrawingWand *wand,
const double x,
3589 assert(wand->signature == MagickWandSignature);
3590 if (wand->debug != MagickFalse)
3591 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3592 DrawPathLineTo(wand,RelativePathMode,x,y);
3622static void DrawPathLineToHorizontal(
DrawingWand *wand,
const PathMode mode,
3626 assert(wand->signature == MagickWandSignature);
3627 if (wand->debug != MagickFalse)
3628 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3629 if ((wand->path_operation != PathLineToHorizontalOperation) ||
3630 (wand->path_mode != mode))
3632 wand->path_operation=PathLineToHorizontalOperation;
3633 wand->path_mode=mode;
3634 (void) MVGAutoWrapPrintf(wand,
"%c%.20g",mode == AbsolutePathMode ?
3638 (
void) MVGAutoWrapPrintf(wand,
" %.20g",x);
3641WandExport
void DrawPathLineToHorizontalAbsolute(
DrawingWand *wand,
3645 assert(wand->signature == MagickWandSignature);
3646 if (wand->debug != MagickFalse)
3647 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3648 DrawPathLineToHorizontal(wand,AbsolutePathMode,x);
3678WandExport
void DrawPathLineToHorizontalRelative(
DrawingWand *wand,
3681 DrawPathLineToHorizontal(wand,RelativePathMode,x);
3712static void DrawPathLineToVertical(
DrawingWand *wand,
const PathMode mode,
3716 assert(wand->signature == MagickWandSignature);
3717 if (wand->debug != MagickFalse)
3718 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3719 if ((wand->path_operation != PathLineToVerticalOperation) ||
3720 (wand->path_mode != mode))
3722 wand->path_operation=PathLineToVerticalOperation;
3723 wand->path_mode=mode;
3724 (void) MVGAutoWrapPrintf(wand,
"%c%.20g",mode == AbsolutePathMode ?
3728 (
void) MVGAutoWrapPrintf(wand,
" %.20g",y);
3731WandExport
void DrawPathLineToVerticalAbsolute(
DrawingWand *wand,
const double y)
3734 assert(wand->signature == MagickWandSignature);
3735 if (wand->debug != MagickFalse)
3736 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3737 DrawPathLineToVertical(wand,AbsolutePathMode,y);
3767WandExport
void DrawPathLineToVerticalRelative(
DrawingWand *wand,
const double y)
3770 assert(wand->signature == MagickWandSignature);
3771 if (wand->debug != MagickFalse)
3772 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3773 DrawPathLineToVertical(wand,RelativePathMode,y);
3805static void DrawPathMoveTo(
DrawingWand *wand,
const PathMode mode,
const double x,
3809 assert(wand->signature == MagickWandSignature);
3810 if (wand->debug != MagickFalse)
3811 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3812 if ((wand->path_operation != PathMoveToOperation) ||
3813 (wand->path_mode != mode))
3815 wand->path_operation=PathMoveToOperation;
3816 wand->path_mode=mode;
3817 (void) MVGAutoWrapPrintf(wand,
"%c%.20g %.20g",mode == AbsolutePathMode ?
3821 (
void) MVGAutoWrapPrintf(wand,
" %.20g %.20g",x,y);
3824WandExport
void DrawPathMoveToAbsolute(
DrawingWand *wand,
const double x,
3828 assert(wand->signature == MagickWandSignature);
3829 if (wand->debug != MagickFalse)
3830 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3831 DrawPathMoveTo(wand,AbsolutePathMode,x,y);
3863WandExport
void DrawPathMoveToRelative(
DrawingWand *wand,
const double x,
3867 assert(wand->signature == MagickWandSignature);
3868 if (wand->debug != MagickFalse)
3869 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3870 DrawPathMoveTo(wand,RelativePathMode,x,y);
3902 assert(wand->signature == MagickWandSignature);
3903 if (wand->debug != MagickFalse)
3904 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3905 (void) MVGPrintf(wand,
"path '");
3906 wand->path_operation=PathDefaultOperation;
3907 wand->path_mode=DefaultPathMode;
3936WandExport
void DrawPoint(
DrawingWand *wand,
const double x,
const double y)
3939 assert(wand->signature == MagickWandSignature);
3940 if (wand->debug != MagickFalse)
3941 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3942 (void) MVGPrintf(wand,
"point %.20g %.20g\n",x,y);
3974 const size_t number_coordinates,
const PointInfo *coordinates)
3977 assert(wand->signature == MagickWandSignature);
3978 if (wand->debug != MagickFalse)
3979 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
3980 MVGAppendPointsCommand(wand,
"polygon",number_coordinates,coordinates);
4012 const size_t number_coordinates,
const PointInfo *coordinates)
4015 assert(wand->signature == MagickWandSignature);
4016 if (wand->debug != MagickFalse)
4017 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4018 MVGAppendPointsCommand(wand,
"polyline",number_coordinates,coordinates);
4046 assert(wand->signature == MagickWandSignature);
4047 if (wand->debug != MagickFalse)
4048 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4049 if (wand->indent_depth > 0)
4050 wand->indent_depth--;
4051 (void) MVGPrintf(wand,
"pop clip-path\n");
4079 assert(wand->signature == MagickWandSignature);
4080 if (wand->debug != MagickFalse)
4081 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4082 if (wand->indent_depth > 0)
4083 wand->indent_depth--;
4084 (void) MVGPrintf(wand,
"pop defs\n");
4109WandExport MagickBooleanType DrawPopPattern(
DrawingWand *wand)
4112 geometry[MagickPathExtent],
4113 key[MagickPathExtent];
4116 assert(wand->signature == MagickWandSignature);
4117 if (wand->debug != MagickFalse)
4118 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4119 if (wand->image == (Image *) NULL)
4120 ThrowDrawException(WandError,
"ContainsNoImages",wand->name);
4121 if (wand->pattern_id == (
const char *) NULL)
4123 ThrowDrawException(DrawWarning,
"NotCurrentlyPushingPatternDefinition",
4125 return(MagickFalse);
4127 (void) FormatLocaleString(key,MagickPathExtent,
"%s",wand->pattern_id);
4128 (void) SetImageArtifact(wand->image,key,wand->mvg+wand->pattern_offset);
4129 (void) FormatLocaleString(geometry,MagickPathExtent,
"%.20gx%.20g%+.20g%+.20g",
4130 (
double) wand->pattern_bounds.width,(double) wand->pattern_bounds.height,
4131 (
double) wand->pattern_bounds.x,(double) wand->pattern_bounds.y);
4132 (void) SetImageArtifact(wand->image,key,geometry);
4133 wand->pattern_id=DestroyString(wand->pattern_id);
4134 wand->pattern_offset=0;
4135 wand->pattern_bounds.x=0;
4136 wand->pattern_bounds.y=0;
4137 wand->pattern_bounds.width=0;
4138 wand->pattern_bounds.height=0;
4139 wand->filter_off=MagickTrue;
4140 if (wand->indent_depth > 0)
4141 wand->indent_depth--;
4142 (void) MVGPrintf(wand,
"pop pattern\n");
4172WandExport
void DrawPushClipPath(
DrawingWand *wand,
const char *clip_mask_id)
4175 assert(wand->signature == MagickWandSignature);
4176 if (wand->debug != MagickFalse)
4177 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4178 assert(clip_mask_id != (
const char *) NULL);
4179 (void) MVGPrintf(wand,
"push clip-path \"%s\"\n",clip_mask_id);
4180 wand->indent_depth++;
4210 assert(wand->signature == MagickWandSignature);
4211 if (wand->debug != MagickFalse)
4212 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4213 (void) MVGPrintf(wand,
"push defs\n");
4214 wand->indent_depth++;
4256WandExport MagickBooleanType DrawPushPattern(
DrawingWand *wand,
4257 const char *pattern_id,
const double x,
const double y,
const double width,
4258 const double height)
4261 assert(wand->signature == MagickWandSignature);
4262 if (wand->debug != MagickFalse)
4263 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4264 assert(pattern_id != (
const char *) NULL);
4265 if (wand->pattern_id != NULL)
4267 ThrowDrawException(DrawError,
"AlreadyPushingPatternDefinition",
4269 return(MagickFalse);
4271 wand->filter_off=MagickTrue;
4272 (void) MVGPrintf(wand,
"push pattern %s %.20g %.20g %.20g %.20g\n",pattern_id,
4274 wand->indent_depth++;
4275 wand->pattern_id=AcquireString(pattern_id);
4276 wand->pattern_bounds.x=CastDoubleToLong(ceil(x-0.5));
4277 wand->pattern_bounds.y=CastDoubleToLong(ceil(y-0.5));
4278 wand->pattern_bounds.width=(size_t) CastDoubleToLong(floor(width+0.5));
4279 wand->pattern_bounds.height=(size_t) CastDoubleToLong(floor(height+0.5));
4280 wand->pattern_offset=wand->mvg_length;
4314WandExport
void DrawRectangle(
DrawingWand *wand,
const double x1,
const double y1,
4315 const double x2,
const double y2)
4318 assert(wand->signature == MagickWandSignature);
4319 if (wand->debug != MagickFalse)
4320 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4321 if ((fabs(x2-x1) < MagickEpsilon) && (fabs(y2-y1) < MagickEpsilon))
4322 (void) MVGPrintf(wand,
"point %.20g %.20g\n",x1,y1);
4324 (
void) MVGPrintf(wand,
"rectangle %.20g %.20g %.20g %.20g\n",x1,y1,x2,y2);
4349WandExport MagickBooleanType DrawRender(
DrawingWand *wand)
4355 assert(wand->signature == MagickWandSignature);
4356 if (wand->debug != MagickFalse)
4357 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4358 CurrentContext->primitive=wand->mvg;
4359 if (wand->debug != MagickFalse)
4360 (void) LogMagickEvent(DrawEvent,GetMagickModule(),
"MVG:\n'%s'\n",wand->mvg);
4361 if (wand->image == (Image *) NULL)
4362 ThrowDrawException(WandError,
"ContainsNoImages",wand->name);
4363 status=DrawImage(wand->image,CurrentContext,wand->exception);
4364 CurrentContext->primitive=(
char *) NULL;
4391WandExport
void DrawResetVectorGraphics(
DrawingWand *wand)
4394 assert(wand->signature == MagickWandSignature);
4395 if (wand->debug != MagickFalse)
4396 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4397 if (wand->mvg != (
char *) NULL)
4398 wand->mvg=DestroyString(wand->mvg);
4428WandExport
void DrawRotate(
DrawingWand *wand,
const double degrees)
4431 assert(wand->signature == MagickWandSignature);
4432 if (wand->debug != MagickFalse)
4433 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4434 (void) MVGPrintf(wand,
"rotate %.20g\n",degrees);
4474WandExport
void DrawRoundRectangle(
DrawingWand *wand,
double x1,
double y1,
4475 double x2,
double y2,
double rx,
double ry)
4478 assert(wand->signature == MagickWandSignature);
4479 if (wand->debug != MagickFalse)
4480 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4481 (void) MVGPrintf(wand,
"roundrectangle %.20g %.20g %.20g %.20g %.20g %.20g\n",
4512WandExport
void DrawScale(
DrawingWand *wand,
const double x,
const double y)
4515 assert(wand->signature == MagickWandSignature);
4516 if (wand->debug != MagickFalse)
4517 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4518 (void) MVGPrintf(wand,
"scale %.20g %.20g\n",x,y);
4546WandExport
void DrawSetBorderColor(
DrawingWand *wand,
4555 assert(wand->signature == MagickWandSignature);
4556 if (wand->debug != MagickFalse)
4557 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4558 assert(border_wand != (
const PixelWand *) NULL);
4559 PixelGetQuantumPacket(border_wand,&border_color);
4560 new_border=border_color;
4561 current_border=(&CurrentContext->border_color);
4562 if ((wand->filter_off != MagickFalse) ||
4563 (IsPixelInfoEquivalent(current_border,&new_border) == MagickFalse))
4565 CurrentContext->border_color=new_border;
4566 (void) MVGPrintf(wand,
"border-color '");
4567 MVGAppendColor(wand,&border_color);
4568 (void) MVGPrintf(wand,
"'\n");
4599WandExport MagickBooleanType DrawSetClipPath(
DrawingWand *wand,
4600 const char *clip_mask)
4603 if (wand->debug != MagickFalse)
4604 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",clip_mask);
4605 assert(wand->signature == MagickWandSignature);
4606 assert(clip_mask != (
const char *) NULL);
4607 if ((CurrentContext->clip_mask == (
const char *) NULL) ||
4608 (wand->filter_off != MagickFalse) ||
4609 (LocaleCompare(CurrentContext->clip_mask,clip_mask) != 0))
4611 (void) CloneString(&CurrentContext->clip_mask,clip_mask);
4612#if DRAW_BINARY_IMPLEMENTATION
4613 if (wand->image == (Image *) NULL)
4614 ThrowDrawException(WandError,
"ContainsNoImages",wand->name);
4615 (void) DrawClipPath(wand->image,CurrentContext,CurrentContext->clip_mask,
4618 (void) MVGPrintf(wand,
"clip-path url(#%s)\n",clip_mask);
4647WandExport
void DrawSetClipRule(
DrawingWand *wand,
const FillRule fill_rule)
4650 assert(wand->signature == MagickWandSignature);
4651 if (wand->debug != MagickFalse)
4652 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4653 if ((wand->filter_off != MagickFalse) ||
4654 (CurrentContext->fill_rule != fill_rule))
4656 CurrentContext->fill_rule=fill_rule;
4657 (void) MVGPrintf(wand,
"clip-rule '%s'\n",CommandOptionToMnemonic(
4658 MagickFillRuleOptions,(ssize_t) fill_rule));
4688WandExport
void DrawSetClipUnits(
DrawingWand *wand,
4689 const ClipPathUnits clip_units)
4692 assert(wand->signature == MagickWandSignature);
4693 if (wand->debug != MagickFalse)
4694 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4695 if ((wand->filter_off != MagickFalse) ||
4696 (CurrentContext->clip_units != clip_units))
4698 CurrentContext->clip_units=clip_units;
4699 if (clip_units == ObjectBoundingBox)
4704 GetAffineMatrix(&affine);
4705 affine.sx=CurrentContext->bounds.x2;
4706 affine.sy=CurrentContext->bounds.y2;
4707 affine.tx=CurrentContext->bounds.x1;
4708 affine.ty=CurrentContext->bounds.y1;
4709 AdjustAffine(wand,&affine);
4711 (void) MVGPrintf(wand,
"clip-units '%s'\n",CommandOptionToMnemonic(
4712 MagickClipPathOptions,(ssize_t) clip_units));
4741WandExport MagickBooleanType DrawSetDensity(
DrawingWand *wand,
4742 const char *density)
4745 if (wand->debug != MagickFalse)
4746 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",density);
4747 assert(wand->signature == MagickWandSignature);
4748 assert(density != (
const char *) NULL);
4749 if ((CurrentContext->density == (
const char *) NULL) ||
4750 (wand->filter_off != MagickFalse) ||
4751 (LocaleCompare(CurrentContext->density,density) != 0))
4753 (void) CloneString(&CurrentContext->density,density);
4754 (void) MVGPrintf(wand,
"density '%s'\n",density);
4791 assert(wand->signature == MagickWandSignature);
4792 if (wand->debug != MagickFalse)
4793 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4794 assert(fill_wand != (
const PixelWand *) NULL);
4795 PixelGetQuantumPacket(fill_wand,&fill_color);
4796 new_fill=fill_color;
4797 current_fill=(&CurrentContext->fill);
4798 if ((wand->filter_off != MagickFalse) ||
4799 (IsPixelInfoEquivalent(current_fill,&new_fill) == MagickFalse))
4801 CurrentContext->fill=new_fill;
4802 (void) MVGPrintf(wand,
"fill '");
4803 MVGAppendColor(wand,&fill_color);
4804 (void) MVGPrintf(wand,
"'\n");
4833WandExport
void DrawSetFillOpacity(
DrawingWand *wand,
const double fill_opacity)
4839 assert(wand->signature == MagickWandSignature);
4840 if (wand->debug != MagickFalse)
4841 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4842 alpha=(double) ClampToQuantum((
double) QuantumRange*fill_opacity);
4843 if ((wand->filter_off != MagickFalse) ||
4844 (CurrentContext->fill.alpha != alpha))
4846 CurrentContext->fill.alpha=alpha;
4847 (void) MVGPrintf(wand,
"fill-opacity %.20g\n",fill_opacity);
4878WandExport MagickBooleanType DrawSetFontResolution(
DrawingWand *wand,
4879 const double x_resolution,
const double y_resolution)
4882 density[MagickPathExtent];
4885 assert(wand->signature == MagickWandSignature);
4886 if (wand->debug != MagickFalse)
4887 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4888 (void) FormatLocaleString(density,MagickPathExtent,
"%.20gx%.20g",x_resolution,
4890 (void) CloneString(&CurrentContext->density,density);
4919WandExport
void DrawSetOpacity(
DrawingWand *wand,
const double opacity)
4925 assert(wand->signature == MagickWandSignature);
4926 if (wand->debug != MagickFalse)
4927 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
4928 quantum_alpha=ClampToQuantum((
double) QuantumRange*opacity);
4929 if ((wand->filter_off != MagickFalse) ||
4930 (CurrentContext->alpha != quantum_alpha))
4932 CurrentContext->alpha=quantum_alpha;
4933 (void) MVGPrintf(wand,
"opacity %.20g\n",opacity);
4965WandExport MagickBooleanType DrawSetFillPatternURL(
DrawingWand *wand,
4966 const char *fill_url)
4969 pattern[MagickPathExtent],
4970 pattern_spec[MagickPathExtent];
4973 assert(wand->signature == MagickWandSignature);
4974 if (wand->debug != MagickFalse)
4975 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",fill_url);
4976 if (wand->image == (Image *) NULL)
4977 ThrowDrawException(WandError,
"ContainsNoImages",wand->name);
4978 assert(fill_url != (
const char *) NULL);
4979 if (*fill_url !=
'#')
4981 ThrowDrawException(DrawError,
"NotARelativeURL",fill_url);
4982 return(MagickFalse);
4984 (void) FormatLocaleString(pattern,MagickPathExtent,
"%s",fill_url+1);
4985 if (GetImageArtifact(wand->image,pattern) == (
const char *) NULL)
4987 ThrowDrawException(DrawError,
"URLNotFound",fill_url)
4988 return(MagickFalse);
4990 (void) FormatLocaleString(pattern_spec,MagickPathExtent,
"url(%s)",fill_url);
4991#if DRAW_BINARY_IMPLEMENTATION
4992 DrawPatternPath(wand->image,CurrentContext,pattern_spec,
4993 &CurrentContext->fill_pattern,wand->exception);
4995 if (CurrentContext->fill.alpha != (
double) TransparentAlpha)
4996 CurrentContext->fill.alpha=(double) CurrentContext->alpha;
4997 (void) MVGPrintf(wand,
"fill %s\n",pattern_spec);
5025WandExport
void DrawSetFillRule(
DrawingWand *wand,
const FillRule fill_rule)
5028 assert(wand->signature == MagickWandSignature);
5029 if (wand->debug != MagickFalse)
5030 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5031 if ((wand->filter_off != MagickFalse) ||
5032 (CurrentContext->fill_rule != fill_rule))
5034 CurrentContext->fill_rule=fill_rule;
5035 (void) MVGPrintf(wand,
"fill-rule '%s'\n",CommandOptionToMnemonic(
5036 MagickFillRuleOptions,(ssize_t) fill_rule));
5065WandExport MagickBooleanType DrawSetFont(
DrawingWand *wand,
5066 const char *font_name)
5069 assert(wand->signature == MagickWandSignature);
5070 if (wand->debug != MagickFalse)
5071 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5072 assert(font_name != (
const char *) NULL);
5073 if ((wand->filter_off != MagickFalse) ||
5074 (CurrentContext->font == (
char *) NULL) ||
5075 (LocaleCompare(CurrentContext->font,font_name) != 0))
5077 (void) CloneString(&CurrentContext->font,font_name);
5078 (void) MVGPrintf(wand,
"font '%s'\n",font_name);
5108WandExport MagickBooleanType DrawSetFontFamily(
DrawingWand *wand,
5109 const char *font_family)
5112 assert(wand->signature == MagickWandSignature);
5113 if (wand->debug != MagickFalse)
5114 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5115 assert(font_family != (
const char *) NULL);
5116 if ((wand->filter_off != MagickFalse) ||
5117 (CurrentContext->family == (
const char *) NULL) ||
5118 (LocaleCompare(CurrentContext->family,font_family) != 0))
5120 (void) CloneString(&CurrentContext->family,font_family);
5121 (void) MVGPrintf(wand,
"font-family '%s'\n",font_family);
5150WandExport
void DrawSetFontSize(
DrawingWand *wand,
const double pointsize)
5153 assert(wand->signature == MagickWandSignature);
5154 if (wand->debug != MagickFalse)
5155 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5156 if ((wand->filter_off != MagickFalse) ||
5157 (fabs(CurrentContext->pointsize-pointsize) >= MagickEpsilon))
5159 CurrentContext->pointsize=pointsize;
5160 (void) MVGPrintf(wand,
"font-size %.20g\n",pointsize);
5193WandExport
void DrawSetFontStretch(
DrawingWand *wand,
5194 const StretchType font_stretch)
5197 assert(wand->signature == MagickWandSignature);
5198 if (wand->debug != MagickFalse)
5199 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5200 if ((wand->filter_off != MagickFalse) ||
5201 (CurrentContext->stretch != font_stretch))
5203 CurrentContext->stretch=font_stretch;
5204 (void) MVGPrintf(wand,
"font-stretch '%s'\n",CommandOptionToMnemonic(
5205 MagickStretchOptions,(ssize_t) font_stretch));
5234WandExport
void DrawSetFontStyle(
DrawingWand *wand,
const StyleType style)
5237 assert(wand->signature == MagickWandSignature);
5238 if (wand->debug != MagickFalse)
5239 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5240 if ((wand->filter_off != MagickFalse) ||
5241 (CurrentContext->style != style))
5243 CurrentContext->style=style;
5244 (void) MVGPrintf(wand,
"font-style '%s'\n",CommandOptionToMnemonic(
5245 MagickStyleOptions,(ssize_t) style));
5274WandExport
void DrawSetFontWeight(
DrawingWand *wand,
5275 const size_t font_weight)
5278 assert(wand->signature == MagickWandSignature);
5279 if (wand->debug != MagickFalse)
5280 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5281 if ((wand->filter_off != MagickFalse) ||
5282 (CurrentContext->weight != font_weight))
5284 CurrentContext->weight=font_weight;
5285 (void) MVGPrintf(wand,
"font-weight %.20g\n",(
double) font_weight);
5317WandExport
void DrawSetGravity(
DrawingWand *wand,
const GravityType gravity)
5320 assert(wand->signature == MagickWandSignature);
5321 if (wand->debug != MagickFalse)
5322 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5323 if ((wand->filter_off != MagickFalse) ||
5324 (CurrentContext->gravity != gravity) || (gravity != ForgetGravity))
5326 CurrentContext->gravity=gravity;
5327 (void) MVGPrintf(wand,
"gravity '%s'\n",CommandOptionToMnemonic(
5328 MagickGravityOptions,(ssize_t) gravity));
5357WandExport
void DrawSetStrokeColor(
DrawingWand *wand,
5366 assert(wand->signature == MagickWandSignature);
5367 if (wand->debug != MagickFalse)
5368 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5369 assert(stroke_wand != (
const PixelWand *) NULL);
5370 PixelGetQuantumPacket(stroke_wand,&stroke_color);
5371 new_stroke=stroke_color;
5372 current_stroke=(&CurrentContext->stroke);
5373 if ((wand->filter_off != MagickFalse) ||
5374 (IsPixelInfoEquivalent(current_stroke,&new_stroke) == MagickFalse))
5376 CurrentContext->stroke=new_stroke;
5377 (void) MVGPrintf(wand,
"stroke '");
5378 MVGAppendColor(wand,&stroke_color);
5379 (void) MVGPrintf(wand,
"'\n");
5408WandExport MagickBooleanType DrawSetStrokePatternURL(
DrawingWand *wand,
5409 const char *stroke_url)
5412 pattern[MagickPathExtent],
5413 pattern_spec[MagickPathExtent];
5416 assert(wand->signature == MagickWandSignature);
5417 if (wand->debug != MagickFalse)
5418 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5419 if (wand->image == (Image *) NULL)
5420 ThrowDrawException(WandError,
"ContainsNoImages",wand->name);
5421 assert(stroke_url != NULL);
5422 if (stroke_url[0] !=
'#')
5423 ThrowDrawException(DrawError,
"NotARelativeURL",stroke_url);
5424 (void) FormatLocaleString(pattern,MagickPathExtent,
"%s",stroke_url+1);
5425 if (GetImageArtifact(wand->image,pattern) == (
const char *) NULL)
5427 ThrowDrawException(DrawError,
"URLNotFound",stroke_url)
5428 return(MagickFalse);
5430 (void) FormatLocaleString(pattern_spec,MagickPathExtent,
"url(%s)",stroke_url);
5431#if DRAW_BINARY_IMPLEMENTATION
5432 DrawPatternPath(wand->image,CurrentContext,pattern_spec,
5433 &CurrentContext->stroke_pattern,wand->exception);
5435 if (CurrentContext->stroke.alpha != (
double) TransparentAlpha)
5436 CurrentContext->stroke.alpha=(double) CurrentContext->alpha;
5437 (void) MVGPrintf(wand,
"stroke %s\n",pattern_spec);
5469WandExport
void DrawSetStrokeAntialias(
DrawingWand *wand,
5470 const MagickBooleanType stroke_antialias)
5473 assert(wand->signature == MagickWandSignature);
5474 if (wand->debug != MagickFalse)
5475 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5476 if ((wand->filter_off != MagickFalse) ||
5477 (CurrentContext->stroke_antialias != stroke_antialias))
5479 CurrentContext->stroke_antialias=stroke_antialias;
5480 (void) MVGPrintf(wand,
"stroke-antialias %i\n",stroke_antialias != 0 ?
5518WandExport MagickBooleanType DrawSetStrokeDashArray(
DrawingWand *wand,
5519 const size_t number_elements,
const double *dasharray)
5538 assert(wand->signature == MagickWandSignature);
5539 if (wand->debug != MagickFalse)
5540 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5541 n_new=number_elements;
5542 if (dasharray == (
const double *) NULL)
5546 q=CurrentContext->dash_pattern;
5547 if (q != (
const double *) NULL)
5548 while (fabs(*q++) < MagickEpsilon)
5550 if ((n_old == 0) && (n_new == 0))
5556 if ((CurrentContext->dash_pattern != (
double *) NULL) &&
5557 (dasharray != (
double *) NULL))
5560 q=CurrentContext->dash_pattern;
5561 for (i=0; i < (ssize_t) n_new; i++)
5563 if (fabs((*p)-(*q)) >= MagickEpsilon)
5572 if ((wand->filter_off != MagickFalse) || (update != MagickFalse))
5574 if (CurrentContext->dash_pattern != (
double *) NULL)
5575 CurrentContext->dash_pattern=(
double *)
5576 RelinquishMagickMemory(CurrentContext->dash_pattern);
5579 CurrentContext->dash_pattern=(
double *) AcquireQuantumMemory((
size_t)
5580 n_new+1UL,
sizeof(*CurrentContext->dash_pattern));
5581 if (CurrentContext->dash_pattern == (
double *) NULL)
5583 ThrowDrawException(ResourceLimitError,
"MemoryAllocationFailed",
5585 return(MagickFalse);
5587 for (i=0; i < (ssize_t) n_new; i++)
5589 CurrentContext->dash_pattern[i]=0.0;
5590 if (dasharray != (
double *) NULL)
5591 CurrentContext->dash_pattern[i]=dasharray[i];
5593 CurrentContext->dash_pattern[n_new]=0.0;
5595 (void) MVGPrintf(wand,
"stroke-dasharray ");
5597 (void) MVGPrintf(wand,
"none\n");
5599 if (dasharray != (
double *) NULL)
5601 for (i=0; i < (ssize_t) n_new; i++)
5604 (void) MVGPrintf(wand,
",");
5605 (void) MVGPrintf(wand,
"%.20g",dasharray[i]);
5607 (void) MVGPrintf(wand,
"\n");
5639WandExport
void DrawSetStrokeDashOffset(
DrawingWand *wand,
5640 const double dash_offset)
5643 assert(wand->signature == MagickWandSignature);
5644 if (wand->debug != MagickFalse)
5645 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5646 if ((wand->filter_off != MagickFalse) ||
5647 (fabs(CurrentContext->dash_offset-dash_offset) >= MagickEpsilon))
5649 CurrentContext->dash_offset=dash_offset;
5650 (void) MVGPrintf(wand,
"stroke-dashoffset %.20g\n",dash_offset);
5681WandExport
void DrawSetStrokeLineCap(
DrawingWand *wand,
const LineCap linecap)
5684 assert(wand->signature == MagickWandSignature);
5685 if (wand->debug != MagickFalse)
5686 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5687 if ((wand->filter_off != MagickFalse) || (CurrentContext->linecap != linecap))
5689 CurrentContext->linecap=linecap;
5690 (void) MVGPrintf(wand,
"stroke-linecap '%s'\n",CommandOptionToMnemonic(
5691 MagickLineCapOptions,(ssize_t) linecap));
5722WandExport
void DrawSetStrokeLineJoin(
DrawingWand *wand,
const LineJoin linejoin)
5725 assert(wand->signature == MagickWandSignature);
5726 if (wand->debug != MagickFalse)
5727 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5728 if ((wand->filter_off != MagickFalse) ||
5729 (CurrentContext->linejoin != linejoin))
5731 CurrentContext->linejoin=linejoin;
5732 (void) MVGPrintf(wand,
"stroke-linejoin '%s'\n",CommandOptionToMnemonic(
5733 MagickLineJoinOptions,(ssize_t) linejoin));
5766WandExport
void DrawSetStrokeMiterLimit(
DrawingWand *wand,
5767 const size_t miterlimit)
5770 assert(wand->signature == MagickWandSignature);
5771 if (wand->debug != MagickFalse)
5772 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5773 if (CurrentContext->miterlimit != miterlimit)
5775 CurrentContext->miterlimit=miterlimit;
5776 (void) MVGPrintf(wand,
"stroke-miterlimit %.20g\n",(
double) miterlimit);
5805WandExport
void DrawSetStrokeOpacity(
DrawingWand *wand,
5806 const double opacity)
5812 assert(wand->signature == MagickWandSignature);
5813 if (wand->debug != MagickFalse)
5814 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5815 alpha=(double) ClampToQuantum((
double) QuantumRange*opacity);
5816 if ((wand->filter_off != MagickFalse) ||
5817 (CurrentContext->stroke.alpha != alpha))
5819 CurrentContext->stroke.alpha=alpha;
5820 (void) MVGPrintf(wand,
"stroke-opacity %.20g\n",opacity);
5850WandExport
void DrawSetStrokeWidth(
DrawingWand *wand,
const double stroke_width)
5853 assert(wand->signature == MagickWandSignature);
5854 if (wand->debug != MagickFalse)
5855 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5856 if ((wand->filter_off != MagickFalse) ||
5857 (fabs(CurrentContext->stroke_width-stroke_width) >= MagickEpsilon))
5859 CurrentContext->stroke_width=stroke_width;
5860 (void) MVGPrintf(wand,
"stroke-width %.20g\n",stroke_width);
5890WandExport
void DrawSetTextAlignment(
DrawingWand *wand,
5891 const AlignType alignment)
5894 assert(wand->signature == MagickWandSignature);
5895 if (wand->debug != MagickFalse)
5896 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5897 if ((wand->filter_off != MagickFalse) ||
5898 (CurrentContext->align != alignment))
5900 CurrentContext->align=alignment;
5901 (void) MVGPrintf(wand,
"text-align '%s'\n",CommandOptionToMnemonic(
5902 MagickAlignOptions,(ssize_t) alignment));
5933WandExport
void DrawSetTextAntialias(
DrawingWand *wand,
5934 const MagickBooleanType text_antialias)
5937 assert(wand->signature == MagickWandSignature);
5938 if (wand->debug != MagickFalse)
5939 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5940 if ((wand->filter_off != MagickFalse) ||
5941 (CurrentContext->text_antialias != text_antialias))
5943 CurrentContext->text_antialias=text_antialias;
5944 (void) MVGPrintf(wand,
"text-antialias %i\n",text_antialias != 0 ? 1 : 0);
5975WandExport
void DrawSetTextDecoration(
DrawingWand *wand,
5976 const DecorationType decoration)
5979 assert(wand->signature == MagickWandSignature);
5980 if (wand->debug != MagickFalse)
5981 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
5982 if ((wand->filter_off != MagickFalse) ||
5983 (CurrentContext->decorate != decoration))
5985 CurrentContext->decorate=decoration;
5986 (void) MVGPrintf(wand,
"decorate '%s'\n",CommandOptionToMnemonic(
5987 MagickDecorateOptions,(ssize_t) decoration));
6018WandExport
void DrawSetTextDirection(
DrawingWand *wand,
6019 const DirectionType direction)
6022 assert(wand->signature == MagickWandSignature);
6024 if (wand->debug != MagickFalse)
6025 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6026 if ((wand->filter_off != MagickFalse) ||
6027 (CurrentContext->direction != direction))
6029 CurrentContext->direction=direction;
6030 (void) MVGPrintf(wand,
"direction '%s'\n",CommandOptionToMnemonic(
6031 MagickDirectionOptions,(ssize_t) direction));
6064WandExport
void DrawSetTextEncoding(
DrawingWand *wand,
const char *encoding)
6067 assert(wand->signature == MagickWandSignature);
6068 if (wand->debug != MagickFalse)
6069 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6070 assert(encoding != (
char *) NULL);
6071 if ((wand->filter_off != MagickFalse) ||
6072 (CurrentContext->encoding == (
char *) NULL) ||
6073 (LocaleCompare(CurrentContext->encoding,encoding) != 0))
6075 (void) CloneString(&CurrentContext->encoding,encoding);
6076 (void) MVGPrintf(wand,
"encoding '%s'\n",encoding);
6104WandExport
void DrawSetTextKerning(
DrawingWand *wand,
const double kerning)
6107 assert(wand->signature == MagickWandSignature);
6109 if (wand->debug != MagickFalse)
6110 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6111 if ((wand->filter_off != MagickFalse) &&
6112 (fabs((CurrentContext->kerning-kerning)) >= MagickEpsilon))
6114 CurrentContext->kerning=kerning;
6115 (void) MVGPrintf(wand,
"kerning %lf\n",kerning);
6144WandExport
void DrawSetTextInterlineSpacing(
DrawingWand *wand,
6145 const double interline_spacing)
6148 assert(wand->signature == MagickWandSignature);
6150 if (wand->debug != MagickFalse)
6151 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6152 if ((wand->filter_off != MagickFalse) ||
6153 (fabs((CurrentContext->interline_spacing-
6154 interline_spacing)) >= MagickEpsilon))
6156 CurrentContext->interline_spacing=interline_spacing;
6157 (void) MVGPrintf(wand,
"interline-spacing %lf\n",interline_spacing);
6186WandExport
void DrawSetTextInterwordSpacing(
DrawingWand *wand,
6187 const double interword_spacing)
6190 assert(wand->signature == MagickWandSignature);
6192 if (wand->debug != MagickFalse)
6193 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6194 if ((wand->filter_off != MagickFalse) ||
6195 (fabs((CurrentContext->interword_spacing-
6196 interword_spacing)) >= MagickEpsilon))
6198 CurrentContext->interword_spacing=interword_spacing;
6199 (void) MVGPrintf(wand,
"interword-spacing %lf\n",interword_spacing);
6229WandExport
void DrawSetTextUnderColor(
DrawingWand *wand,
6236 assert(wand->signature == MagickWandSignature);
6237 if (wand->debug != MagickFalse)
6238 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6239 assert(under_wand != (
const PixelWand *) NULL);
6240 PixelGetQuantumPacket(under_wand,&under_color);
6241 if ((wand->filter_off != MagickFalse) ||
6242 (IsPixelInfoEquivalent(&CurrentContext->undercolor,&under_color) == MagickFalse))
6244 CurrentContext->undercolor=under_color;
6245 (void) MVGPrintf(wand,
"text-undercolor '");
6246 MVGAppendColor(wand,&under_color);
6247 (void) MVGPrintf(wand,
"'\n");
6279static inline MagickBooleanType IsPoint(
const char *point)
6287 value=strtol(point,&p,10);
6289 return(p != point ? MagickTrue : MagickFalse);
6292WandExport MagickBooleanType DrawSetVectorGraphics(
DrawingWand *wand,
6303 assert(wand->signature == MagickWandSignature);
6304 if (wand->debug != MagickFalse)
6305 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6306 CurrentContext=DestroyDrawInfo(CurrentContext);
6307 CurrentContext=CloneDrawInfo((ImageInfo *) NULL,(DrawInfo *) NULL);
6308 if (xml == (
const char *) NULL)
6309 return(MagickFalse);
6310 xml_info=NewXMLTree(xml,wand->exception);
6311 if (xml_info == (XMLTreeInfo *) NULL)
6312 return(MagickFalse);
6313 child=GetXMLTreeChild(xml_info,
"clip-path");
6314 if (child != (XMLTreeInfo *) NULL)
6315 (void) CloneString(&CurrentContext->clip_mask,GetXMLTreeContent(child));
6316 child=GetXMLTreeChild(xml_info,
"clip-units");
6317 if (child != (XMLTreeInfo *) NULL)
6319 value=GetXMLTreeContent(child);
6320 if (value != (
const char *) NULL)
6321 CurrentContext->clip_units=(ClipPathUnits) ParseCommandOption(
6322 MagickClipPathOptions,MagickFalse,value);
6324 child=GetXMLTreeChild(xml_info,
"decorate");
6325 if (child != (XMLTreeInfo *) NULL)
6327 value=GetXMLTreeContent(child);
6328 if (value != (
const char *) NULL)
6329 CurrentContext->decorate=(DecorationType) ParseCommandOption(
6330 MagickDecorateOptions,MagickFalse,value);
6332 child=GetXMLTreeChild(xml_info,
"encoding");
6333 if (child != (XMLTreeInfo *) NULL)
6334 (void) CloneString(&CurrentContext->encoding,GetXMLTreeContent(child));
6335 child=GetXMLTreeChild(xml_info,
"fill");
6336 if (child != (XMLTreeInfo *) NULL)
6338 value=GetXMLTreeContent(child);
6339 if (value != (
const char *) NULL)
6340 (void) QueryColorCompliance(value,AllCompliance,&CurrentContext->fill,
6343 child=GetXMLTreeChild(xml_info,
"fill-opacity");
6344 if (child != (XMLTreeInfo *) NULL)
6346 value=GetXMLTreeContent(child);
6347 if (value != (
const char *) NULL)
6348 CurrentContext->fill.alpha=(double) ClampToQuantum((
double)
6349 QuantumRange*(1.0-StringToDouble(value,(
char **) NULL)));
6351 child=GetXMLTreeChild(xml_info,
"fill-rule");
6352 if (child != (XMLTreeInfo *) NULL)
6354 value=GetXMLTreeContent(child);
6355 if (value != (
const char *) NULL)
6356 CurrentContext->fill_rule=(FillRule) ParseCommandOption(
6357 MagickFillRuleOptions,MagickFalse,value);
6359 child=GetXMLTreeChild(xml_info,
"font");
6360 if (child != (XMLTreeInfo *) NULL)
6361 (void) CloneString(&CurrentContext->font,GetXMLTreeContent(child));
6362 child=GetXMLTreeChild(xml_info,
"font-family");
6363 if (child != (XMLTreeInfo *) NULL)
6364 (void) CloneString(&CurrentContext->family,GetXMLTreeContent(child));
6365 child=GetXMLTreeChild(xml_info,
"font-size");
6366 if (child != (XMLTreeInfo *) NULL)
6368 value=GetXMLTreeContent(child);
6369 if (value != (
const char *) NULL)
6370 CurrentContext->pointsize=StringToDouble(value,(
char **) NULL);
6372 child=GetXMLTreeChild(xml_info,
"font-stretch");
6373 if (child != (XMLTreeInfo *) NULL)
6375 value=GetXMLTreeContent(child);
6376 if (value != (
const char *) NULL)
6377 CurrentContext->stretch=(StretchType) ParseCommandOption(
6378 MagickStretchOptions,MagickFalse,value);
6380 child=GetXMLTreeChild(xml_info,
"font-style");
6381 if (child != (XMLTreeInfo *) NULL)
6383 value=GetXMLTreeContent(child);
6384 if (value != (
const char *) NULL)
6385 CurrentContext->style=(StyleType) ParseCommandOption(MagickStyleOptions,
6388 child=GetXMLTreeChild(xml_info,
"font-weight");
6389 if (child != (XMLTreeInfo *) NULL)
6391 value=GetXMLTreeContent(child);
6392 if (value != (
const char *) NULL)
6397 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,value);
6399 weight=(ssize_t) StringToUnsignedLong(value);
6400 CurrentContext->weight=(size_t) weight;
6403 child=GetXMLTreeChild(xml_info,
"gravity");
6404 if (child != (XMLTreeInfo *) NULL)
6406 value=GetXMLTreeContent(child);
6407 if (value != (
const char *) NULL)
6408 CurrentContext->gravity=(GravityType) ParseCommandOption(
6409 MagickGravityOptions,MagickFalse,value);
6411 child=GetXMLTreeChild(xml_info,
"stroke");
6412 if (child != (XMLTreeInfo *) NULL)
6414 value=GetXMLTreeContent(child);
6415 if (value != (
const char *) NULL)
6416 (void) QueryColorCompliance(value,AllCompliance,&CurrentContext->stroke,
6419 child=GetXMLTreeChild(xml_info,
"stroke-antialias");
6420 if (child != (XMLTreeInfo *) NULL)
6422 value=GetXMLTreeContent(child);
6423 if (value != (
const char *) NULL)
6424 CurrentContext->stroke_antialias=StringToLong(value) != 0 ? MagickTrue :
6427 child=GetXMLTreeChild(xml_info,
"stroke-dasharray");
6428 if (child != (XMLTreeInfo *) NULL)
6431 token[MagickPathExtent];
6442 value=GetXMLTreeContent(child);
6443 if (value != (
const char *) NULL)
6445 if (CurrentContext->dash_pattern != (
double *) NULL)
6446 CurrentContext->dash_pattern=(
double *) RelinquishMagickMemory(
6447 CurrentContext->dash_pattern);
6449 if (IsPoint(q) != MagickFalse)
6455 (void) GetNextToken(p,&p,MagickPathExtent,token);
6457 (void) GetNextToken(p,&p,MagickPathExtent,token);
6458 for (x=0; IsPoint(token) != MagickFalse; x++)
6460 (void) GetNextToken(p,&p,MagickPathExtent,token);
6462 (void) GetNextToken(p,&p,MagickPathExtent,token);
6464 CurrentContext->dash_pattern=(
double *) AcquireQuantumMemory(
6465 (
size_t) (2*x)+1UL,
sizeof(*CurrentContext->dash_pattern));
6466 if (CurrentContext->dash_pattern == (
double *) NULL)
6467 ThrowWandFatalException(ResourceLimitFatalError,
6468 "MemoryAllocationFailed",wand->name);
6469 for (j=0; j < x; j++)
6471 (void) GetNextToken(q,&q,MagickPathExtent,token);
6473 (void) GetNextToken(q,&q,MagickPathExtent,token);
6474 CurrentContext->dash_pattern[j]=StringToDouble(token,
6477 if ((x & 0x01) != 0)
6478 for ( ; j < (2*x); j++)
6479 CurrentContext->dash_pattern[j]=
6480 CurrentContext->dash_pattern[j-x];
6481 CurrentContext->dash_pattern[j]=0.0;
6485 child=GetXMLTreeChild(xml_info,
"stroke-dashoffset");
6486 if (child != (XMLTreeInfo *) NULL)
6488 value=GetXMLTreeContent(child);
6489 if (value != (
const char *) NULL)
6490 CurrentContext->dash_offset=StringToDouble(value,(
char **) NULL);
6492 child=GetXMLTreeChild(xml_info,
"stroke-linecap");
6493 if (child != (XMLTreeInfo *) NULL)
6495 value=GetXMLTreeContent(child);
6496 if (value != (
const char *) NULL)
6497 CurrentContext->linecap=(LineCap) ParseCommandOption(
6498 MagickLineCapOptions,MagickFalse,value);
6500 child=GetXMLTreeChild(xml_info,
"stroke-linejoin");
6501 if (child != (XMLTreeInfo *) NULL)
6503 value=GetXMLTreeContent(child);
6504 if (value != (
const char *) NULL)
6505 CurrentContext->linejoin=(LineJoin) ParseCommandOption(
6506 MagickLineJoinOptions,MagickFalse,value);
6508 child=GetXMLTreeChild(xml_info,
"stroke-miterlimit");
6509 if (child != (XMLTreeInfo *) NULL)
6511 value=GetXMLTreeContent(child);
6512 if (value != (
const char *) NULL)
6513 CurrentContext->miterlimit=StringToUnsignedLong(value);
6515 child=GetXMLTreeChild(xml_info,
"stroke-opacity");
6516 if (child != (XMLTreeInfo *) NULL)
6518 value=GetXMLTreeContent(child);
6519 if (value != (
const char *) NULL)
6520 CurrentContext->stroke.alpha=(double) ClampToQuantum((
double)
6521 QuantumRange*(1.0-StringToDouble(value,(
char **) NULL)));
6523 child=GetXMLTreeChild(xml_info,
"stroke-width");
6524 if (child != (XMLTreeInfo *) NULL)
6526 value=GetXMLTreeContent(child);
6527 if (value != (
const char *) NULL)
6532 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,value);
6534 weight=(ssize_t) StringToUnsignedLong(value);
6535 CurrentContext->stroke_width=(double) weight;
6538 child=GetXMLTreeChild(xml_info,
"text-align");
6539 if (child != (XMLTreeInfo *) NULL)
6541 value=GetXMLTreeContent(child);
6542 if (value != (
const char *) NULL)
6543 CurrentContext->align=(AlignType) ParseCommandOption(MagickAlignOptions,
6546 child=GetXMLTreeChild(xml_info,
"text-antialias");
6547 if (child != (XMLTreeInfo *) NULL)
6549 value=GetXMLTreeContent(child);
6550 if (value != (
const char *) NULL)
6551 CurrentContext->text_antialias=StringToLong(value) != 0 ? MagickTrue :
6554 child=GetXMLTreeChild(xml_info,
"text-undercolor");
6555 if (child != (XMLTreeInfo *) NULL)
6557 value=GetXMLTreeContent(child);
6558 if (value != (
const char *) NULL)
6559 (void) QueryColorCompliance(value,AllCompliance,
6560 &CurrentContext->undercolor,wand->exception);
6562 child=GetXMLTreeChild(xml_info,
"vector-graphics");
6563 if (child != (XMLTreeInfo *) NULL)
6565 (void) CloneString(&wand->mvg,GetXMLTreeContent(child));
6566 wand->mvg_length=strlen(wand->mvg);
6567 wand->mvg_alloc=wand->mvg_length+1;
6569 xml_info=DestroyXMLTree(xml_info);
6598WandExport
void DrawSkewX(
DrawingWand *wand,
const double degrees)
6601 assert(wand->signature == MagickWandSignature);
6602 if (wand->debug != MagickFalse)
6603 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6604 (void) MVGPrintf(wand,
"skewX %.20g\n",degrees);
6632WandExport
void DrawSkewY(
DrawingWand *wand,
const double degrees)
6635 assert(wand->signature == MagickWandSignature);
6636 if (wand->debug != MagickFalse)
6637 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6638 (void) MVGPrintf(wand,
"skewY %.20g\n",degrees);
6670WandExport
void DrawTranslate(
DrawingWand *wand,
const double x,
const double y)
6673 assert(wand->signature == MagickWandSignature);
6674 if (wand->debug != MagickFalse)
6675 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6676 (void) MVGPrintf(wand,
"translate %.20g %.20g\n",x,y);
6714WandExport
void DrawSetViewbox(
DrawingWand *wand,
const double x1,
6715 const double y1,
const double x2,
const double y2)
6718 assert(wand->signature == MagickWandSignature);
6719 if (wand->debug != MagickFalse)
6720 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6721 (void) MVGPrintf(wand,
"viewbox %.20g %.20g %.20g %.20g\n",x1,y1,x2,y2);
6746WandExport MagickBooleanType IsDrawingWand(
const DrawingWand *wand)
6749 return(MagickFalse);
6750 if (wand->signature != MagickWandSignature)
6751 return(MagickFalse);
6752 if (LocaleNCompare(wand->name,DrawingWandId,strlen(DrawingWandId)) != 0)
6753 return(MagickFalse);
6781 CheckMagickCoreCompatibility();
6782 wand=(
DrawingWand *) AcquireMagickMemory(
sizeof(*wand));
6784 ThrowWandFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
6785 GetExceptionMessage(errno));
6786 (void) memset(wand,0,
sizeof(*wand));
6787 wand->id=AcquireWandId();
6788 (void) FormatLocaleString(wand->name,MagickPathExtent,
"%s-%.20g",
6789 DrawingWandId,(
double) wand->id);
6790 if (wand->debug != MagickFalse)
6791 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6792 wand->mvg=(
char *) NULL;
6796 wand->pattern_id=(
char *) NULL;
6797 wand->pattern_offset=0;
6798 wand->pattern_bounds.x=0;
6799 wand->pattern_bounds.y=0;
6800 wand->pattern_bounds.width=0;
6801 wand->pattern_bounds.height=0;
6803 wand->graphic_context=(DrawInfo **) AcquireMagickMemory(
sizeof(
6804 *wand->graphic_context));
6805 if (wand->graphic_context == (DrawInfo **) NULL)
6806 ThrowWandFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
6807 GetExceptionMessage(errno));
6808 wand->filter_off=MagickTrue;
6809 wand->indent_depth=0;
6810 wand->path_operation=PathDefaultOperation;
6811 wand->path_mode=DefaultPathMode;
6812 wand->exception=AcquireExceptionInfo();
6813 wand->image=AcquireImage((
const ImageInfo *) NULL,wand->exception);
6814 wand->destroy=MagickTrue;
6815 wand->debug=IsEventLogging();
6816 wand->signature=MagickWandSignature;
6817 CurrentContext=CloneDrawInfo((ImageInfo *) NULL,(DrawInfo *) NULL);
6843WandExport DrawInfo *PeekDrawingWand(
const DrawingWand *wand)
6849 assert(wand->signature == MagickWandSignature);
6850 if (wand->debug != MagickFalse)
6851 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6852 draw_info=CloneDrawInfo((ImageInfo *) NULL,CurrentContext);
6853 (void) CloneString(&draw_info->primitive,wand->mvg);
6882WandExport MagickBooleanType PopDrawingWand(
DrawingWand *wand)
6885 assert(wand->signature == MagickWandSignature);
6886 if (wand->debug != MagickFalse)
6887 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6888 if (wand->index == 0)
6890 ThrowDrawException(DrawError,
"UnbalancedGraphicContextPushPop",wand->name)
6891 return(MagickFalse);
6896#if DRAW_BINARY_IMPLEMENTATION
6897 if (wand->image == (Image *) NULL)
6898 ThrowDrawException(WandError,
"ContainsNoImages",wand->name);
6899 if (CurrentContext->clip_mask != (
char *) NULL)
6900 if (LocaleCompare(CurrentContext->clip_mask,
6901 wand->graphic_context[wand->index-1]->clip_mask) != 0)
6902 (void) SetImageMask(wand->image,WritePixelMask,(Image *) NULL,
6905 CurrentContext=DestroyDrawInfo(CurrentContext);
6907 if (wand->indent_depth > 0)
6908 wand->indent_depth--;
6909 (void) MVGPrintf(wand,
"pop graphic-context\n");
6938WandExport MagickBooleanType PushDrawingWand(
DrawingWand *wand)
6941 assert(wand->signature == MagickWandSignature);
6942 if (wand->debug != MagickFalse)
6943 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
6945 wand->graphic_context=(DrawInfo **) ResizeQuantumMemory(wand->graphic_context,
6946 (
size_t) wand->index+1UL,
sizeof(*wand->graphic_context));
6947 if (wand->graphic_context == (DrawInfo **) NULL)
6950 ThrowDrawException(ResourceLimitError,
"MemoryAllocationFailed",
6952 return(MagickFalse);
6954 CurrentContext=CloneDrawInfo((ImageInfo *) NULL,
6955 wand->graphic_context[wand->index-1]);
6956 (void) MVGPrintf(wand,
"push graphic-context\n");
6957 wand->indent_depth++;