2
% Copyright (C) 2003 GraphicsMagick Group
3
% Copyright (C) 2002 ImageMagick Studio
4
% Copyright 1991-1999 E. I. du Pont de Nemours and Company
6
% This program is covered by multiple licenses, which are described in
7
% Copyright.txt. You should have received a copy of Copyright.txt with this
8
% package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
10
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16
% D D RRRR AAAAA W W %
21
% GraphicsMagick Image Vector Drawing Methods %
30
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38
#include "magick/studio.h"
39
#include "magick/attribute.h"
40
#include "magick/blob.h"
41
#include "magick/color.h"
42
#include "magick/draw.h"
43
#include "magick/gem.h"
44
#include "magick/log.h"
45
#include "magick/magick.h"
46
#include "magick/monitor.h"
47
#include "magick/utility.h"
52
#define DRAW_BINARY_IMPLEMENTATION 0
54
#define ThrowDrawException(code,reason,description) \
56
if (context->image->exception.severity > (long)code) \
57
ThrowException(&context->image->exception,code,reason,description); \
60
#define ThrowDrawException3(code,reason,description) \
62
if (context->image->exception.severity > (long)code) \
63
ThrowException3(&context->image->exception,code,reason,description); \
67
#define CurrentContext (context->graphic_context[context->index])
68
#define PixelPacketMatch(p,q) (((p)->red == (q)->red) && \
69
((p)->green == (q)->green) && ((p)->blue == (q)->blue) && \
70
((p)->opacity == (q)->opacity))
78
PathCloseOperation, /* Z|z (none) */
79
PathCurveToOperation, /* C|c (x1 y1 x2 y2 x y)+ */
80
PathCurveToQuadraticBezierOperation, /* Q|q (x1 y1 x y)+ */
81
PathCurveToQuadraticBezierSmoothOperation, /* T|t (x y)+ */
82
PathCurveToSmoothOperation, /* S|s (x2 y2 x y)+ */
83
PathEllipticArcOperation, /* A|a (rx ry x-axis-rotation large-arc-flag sweep-flag x y)+ */
84
PathLineToHorizontalOperation, /* H|h x+ */
85
PathLineToOperation, /* L|l (x y)+ */
86
PathLineToVerticalOperation, /* V|v y+ */
87
PathMoveToOperation /* M|m (x y)+ */
99
/* Support structures */
103
/* MVG output string and housekeeping */
108
mvg_alloc, /* total allocated memory */
109
mvg_length; /* total MVG length */
112
mvg_width; /* current line length */
114
/* Pattern support */
124
/* Graphic context */
126
index; /* array index */
132
filter_off; /* true if not filtering attributes */
134
/* Pretty-printing depth */
136
indent_depth; /* number of left-hand pad characters */
138
/* Path operation support */
145
/* Structure unique signature */
150
/* Vector table for invoking subordinate renderers */
153
void (*DrawAnnotation)
154
(DrawContext context, const double x, const double y,
155
const unsigned char *text);
157
(DrawContext context, const double sx, const double sy,
158
const double ex, const double ey, const double sd, const double ed);
160
(DrawContext context, const unsigned long num_coords, const PointInfo *coordinates);
162
(DrawContext context, const double ox, const double oy,
163
const double px, const double py);
165
(DrawContext context, const double x, const double y,
166
const PaintMethod paintMethod);
168
(DrawContext context,const char* comment);
169
void (*DrawDestroyContext)
170
(DrawContext context);
172
(DrawContext context, const double ox, const double oy,
173
const double rx, const double ry, const double start, const double end);
174
void (*DrawComposite)
175
(DrawContext context, const CompositeOperator composite_operator,
176
const double x, const double y, const double width, const double height,
177
const Image * image );
179
(DrawContext context, const double sx, const double sy,
180
const double ex, const double ey);
182
(DrawContext context, const double x, const double y,
183
const PaintMethod paint_method);
184
void (*DrawPathClose)
185
(DrawContext context);
186
void (*DrawPathCurveToAbsolute)
187
(DrawContext context, const double x1, const double y1,
188
const double x2, const double y2, const double x, const double y);
189
void (*DrawPathCurveToRelative)
190
(DrawContext context, const double x1, const double y1,
191
const double x2, const double y2, const double x, const double y);
192
void (*DrawPathCurveToQuadraticBezierAbsolute)
193
(DrawContext context, const double x1, const double y1,
194
const double x, const double y);
195
void (*DrawPathCurveToQuadraticBezierRelative)
196
(DrawContext context, const double x1, const double y1,
197
const double x, const double y);
198
void (*DrawPathCurveToQuadraticBezierSmoothAbsolute)
199
(DrawContext context, const double x, const double y);
200
void (*DrawPathCurveToQuadraticBezierSmoothRelative)
201
(DrawContext context, const double x, const double y);
202
void (*DrawPathCurveToSmoothAbsolute)
203
(DrawContext context, const double x2, const double y2,
204
const double x, const double y);
205
void (*DrawPathCurveToSmoothRelative)
206
(DrawContext context, const double x2, const double y2,
207
const double x, const double y);
208
void (*DrawPathEllipticArcAbsolute)
209
(DrawContext context, const double rx, const double ry,
210
const double x_axis_rotation, unsigned int large_arc_flag,
211
unsigned int sweep_flag, const double x, const double y);
212
void (*DrawPathEllipticArcRelative)
213
(DrawContext context, const double rx, const double ry,
214
const double x_axis_rotation, unsigned int large_arc_flag,
215
unsigned int sweep_flag, const double x, const double y);
216
void (*DrawPathFinish)
217
(DrawContext context);
218
void (*DrawPathLineToAbsolute)
219
(DrawContext context, const double x, const double y);
220
void (*DrawPathLineToRelative)
221
(DrawContext context, const double x, const double y);
222
void (*DrawPathLineToHorizontalAbsolute)
223
(DrawContext context, const double x);
224
void (*DrawPathLineToHorizontalRelative)
225
(DrawContext context, const double x);
226
void (*DrawPathLineToVerticalAbsolute)
227
(DrawContext context, const double y);
228
void (*DrawPathLineToVerticalRelative)
229
(DrawContext context, const double y);
230
void (*DrawPathMoveToAbsolute)
231
(DrawContext context, const double x, const double y);
232
void (*DrawPathMoveToRelative)
233
(DrawContext context, const double x, const double y);
234
void (*DrawPathStart)
235
(DrawContext context);
237
(DrawContext context, const double x, const double y);
239
(DrawContext context, const unsigned long num_coords, const PointInfo * coordinates);
241
(DrawContext context, const unsigned long num_coords, const PointInfo * coordinates);
242
void (*DrawPopClipPath)
243
(DrawContext context);
245
(DrawContext context);
246
void (*DrawPopGraphicContext)
247
(DrawContext context);
248
void (*DrawPopPattern)
249
(DrawContext context);
250
void (*DrawPushClipPath)
251
(DrawContext context, const char *clip_path_id);
253
(DrawContext context);
254
void (*DrawPushGraphicContext)
255
(DrawContext context);
256
void (*DrawPushPattern)
257
(DrawContext context, const char *pattern_id,
258
const double x, const double y, const double width, const double height);
259
void (*DrawRectangle)
260
(DrawContext context, const double x1, const double y1,
261
const double x2, const double y2);
262
void (*DrawRoundRectangle)
263
(DrawContext context, double x1, double y1,
264
double x2, double y2, double rx, double ry);
266
(DrawContext context, const AffineMatrix *affine);
267
void (*DrawSetClipPath)
268
(DrawContext context, const char *clip_path);
269
void (*DrawSetClipRule)
270
(DrawContext context, const FillRule fill_rule);
271
void (*DrawSetClipUnits)
272
(DrawContext context, const ClipPathUnits clip_units);
273
void (*DrawSetFillColor)
274
(DrawContext context, const PixelPacket * fill_color);
275
void (*DrawSetFillOpacity)
276
(DrawContext context, const double fill_opacity);
277
void (*DrawSetFillRule)
278
(DrawContext context, const FillRule fill_rule);
279
void (*DrawSetFillPatternURL)
280
(DrawContext context, const char* fill_url);
282
(DrawContext context, const char *font_name);
283
void (*DrawSetFontFamily)
284
(DrawContext context, const char *font_family);
285
void (*DrawSetFontSize)
286
(DrawContext context, const double font_pointsize);
287
void (*DrawSetFontStretch)
288
(DrawContext context, const StretchType font_stretch);
289
void (*DrawSetFontStyle)
290
(DrawContext context, const StyleType font_style);
291
void (*DrawSetFontWeight)
292
(DrawContext context, const unsigned long font_weight);
293
void (*DrawSetGravity)
294
(DrawContext context, const GravityType gravity);
296
(DrawContext context, const double degrees);
298
(DrawContext context, const double x, const double y);
300
(DrawContext context, const double degrees);
302
(DrawContext context, const double degrees);
303
/* void (*DrawSetStopColor) */
304
/* (DrawContext context, const PixelPacket * color, const double offset); */
305
void (*DrawSetStrokeAntialias)
306
(DrawContext context, const unsigned int true_false);
307
void (*DrawSetStrokeColor)
308
(DrawContext context, const PixelPacket * stroke_color);
309
void (*DrawSetStrokeDashArray)
310
(DrawContext context,const double *dasharray);
311
void (*DrawSetStrokeDashOffset)
312
(DrawContext context,const double dashoffset);
313
void (*DrawSetStrokeLineCap)
314
(DrawContext context, const LineCap linecap);
315
void (*DrawSetStrokeLineJoin)
316
(DrawContext context, const LineJoin linejoin);
317
void (*DrawSetStrokeMiterLimit)
318
(DrawContext context,const unsigned long miterlimit);
319
void (*DrawSetStrokeOpacity)
320
(DrawContext context, const double opacity);
321
void (*DrawSetStrokePatternURL)
322
(DrawContext context, const char* stroke_url);
323
void (*DrawSetStrokeWidth)
324
(DrawContext context, const double width);
325
void (*DrawSetTextAntialias)
326
(DrawContext context, const unsigned int true_false);
327
void (*DrawSetTextDecoration)
328
(DrawContext context, const DecorationType decoration);
329
void (*DrawSetTextUnderColor)
330
(DrawContext context, const PixelPacket * color);
331
void (*DrawTranslate)
332
(DrawContext context, const double x, const double y);
333
void (*DrawSetViewbox)
334
(DrawContext context, unsigned long x1, unsigned long y1,
335
unsigned long x2, unsigned long y2);
339
Forward declarations.
342
MvgPrintf(DrawContext context, const char *format, ...)
343
#if defined(__GNUC__)
344
__attribute__ ((format (printf, 2, 3)))
347
MvgAutoWrapPrintf(DrawContext context, const char *format, ...)
348
#if defined(__GNUC__)
349
__attribute__ ((format (printf, 2, 3)))
353
MvgAppendColor(DrawContext context, const PixelPacket *color);
356
/* "Printf" for MVG commands */
357
static int MvgPrintf(DrawContext context, const char *format, ...)
360
alloc_size = MaxTextExtent * 20; /* 40K */
362
assert(context != (DrawContext)NULL);
363
assert(context->signature == MagickSignature);
365
/* Allocate initial memory */
366
if (context->mvg == (char*) NULL)
368
context->mvg = MagickAllocateMemory(char *,alloc_size);
369
if( context->mvg == (char*) NULL )
371
ThrowException3(&context->image->exception,ResourceLimitError,
372
MemoryAllocationFailed,UnableToDrawOnImage);
376
context->mvg_alloc = alloc_size;
377
context->mvg_length = 0;
378
if (context->mvg == 0)
380
ThrowException3(&context->image->exception,ResourceLimitError,
381
MemoryAllocationFailed,UnableToDrawOnImage);
386
/* Re-allocate additional memory if necessary (ensure 20K unused) */
387
if (context->mvg_alloc < (context->mvg_length + MaxTextExtent * 10))
389
size_t realloc_size = context->mvg_alloc + alloc_size;
391
MagickReallocMemory(context->mvg, realloc_size);
392
if (context->mvg == NULL)
394
ThrowException3(&context->image->exception,ResourceLimitError,
395
MemoryAllocationFailed,UnableToDrawOnImage);
398
context->mvg_alloc = realloc_size;
401
/* Write to end of existing MVG string */
404
formatted_length; /* must be a signed type! */
409
/* Pretty-print indentation */
410
while(context->mvg_width < context->indent_depth)
412
context->mvg[context->mvg_length] = ' ';
413
++context->mvg_length;
414
++context->mvg_width;
416
context->mvg[context->mvg_length] = 0;
418
va_start(argp, format);
419
#if defined(HAVE_VSNPRINTF)
421
vsnprintf(context->mvg + context->mvg_length,
422
context->mvg_alloc - context->mvg_length - 1, format, argp);
424
# if defined(HAVE_VSPRINTF)
425
formatted_length = vsprintf(context->mvg + context->mvg_length, format, argp);
427
# error Neither vsnprintf or vsprintf is available.
432
if (formatted_length < 0)
434
ThrowException(&context->image->exception,DrawError,UnableToPrint,
439
context->mvg_length += formatted_length;
440
context->mvg_width += formatted_length;
442
context->mvg[context->mvg_length] = 0;
444
/* Re-evaluate mvg_width */
445
if( (context->mvg_length > 1) &&
446
(context->mvg[context->mvg_length-1] == '\n') )
447
context->mvg_width = 0;
449
assert(context->mvg_length + 1 < context->mvg_alloc);
451
return formatted_length;
455
/* "Printf" for MVG commands, with autowrap at 78 characters */
456
static int MvgAutoWrapPrintf(DrawContext context, const char *format, ...)
465
buffer[MaxTextExtent];
467
va_start(argp, format);
468
#if defined(HAVE_VSNPRINTF)
469
formatted_length = vsnprintf(buffer, sizeof(buffer) - 1, format, argp);
471
# if defined(HAVE_VSPRINTF)
472
formatted_length = vsprintf(buffer, format, argp);
474
# error Neither vsnprintf or vsprintf is available.
478
*(buffer+sizeof(buffer)-1)=0;
480
if (formatted_length < 0)
482
ThrowException(&context->image->exception,DrawError,UnableToPrint,
487
if( ((context->mvg_width + formatted_length) > 78) &&
488
buffer[formatted_length-1] != '\n' )
489
MvgPrintf(context, "\n");
491
MvgPrintf(context, "%s", buffer);
494
return formatted_length;
497
static void MvgAppendColor(DrawContext context, const PixelPacket *color)
499
if(color->red == 0 && color->green == 0 && color->blue == 0 &&
500
color->opacity == TransparentOpacity)
502
MvgPrintf(context,"none");
507
tuple[MaxTextExtent];
509
GetColorTuple(color,context->image->depth,context->image->matte,True,
511
MvgPrintf(context,"%.1024s",tuple);
515
static void MvgAppendPointsCommand(DrawContext context, const char* command,
516
const unsigned long num_coords,
517
const PointInfo * coordinates)
525
MvgPrintf(context, command);
526
for (i = num_coords, coordinate = coordinates; i; i--)
528
MvgAutoWrapPrintf(context," %.4g,%.4g", coordinate->x, coordinate->y);
532
MvgPrintf(context, "\n");
535
static void AdjustAffine(DrawContext context, const AffineMatrix *affine)
537
assert(context != (DrawContext)NULL);
538
assert(context->signature == MagickSignature);
540
if ((affine->sx != 1.0) || (affine->rx != 0.0) || (affine->ry != 0.0) ||
541
(affine->sy != 1.0) || (affine->tx != 0.0) || (affine->ty != 0.0))
546
current = CurrentContext->affine;
547
CurrentContext->affine.sx=current.sx*affine->sx+current.ry*affine->rx;
548
CurrentContext->affine.rx=current.rx*affine->sx+current.sy*affine->rx;
549
CurrentContext->affine.ry=current.sx*affine->ry+current.ry*affine->sy;
550
CurrentContext->affine.sy=current.rx*affine->ry+current.sy*affine->sy;
551
CurrentContext->affine.tx=current.sx*affine->tx+current.ry*affine->ty+current.tx;
552
CurrentContext->affine.ty=current.rx*affine->tx+current.sy*affine->ty+current.ty;
557
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
561
% D r a w A n n o t a t i o n %
565
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
567
% DrawAnnotation() draws text on the image.
569
% The format of the DrawAnnotation method is:
571
% void DrawAnnotation(DrawContext context,
572
% const double x, const double y,
573
% const unsigned char *text)
575
% A description of each parameter follows:
577
% o context: drawing context
579
% o x: x ordinate to left of text
581
% o y: y ordinate to text baseline
583
% o text: text to draw
586
MagickExport void DrawAnnotation(DrawContext context,
587
const double x, const double y,
588
const unsigned char *text)
593
assert(context != (DrawContext)NULL);
594
assert(context->signature == MagickSignature);
595
assert(text != (const unsigned char *) NULL);
597
escaped_text=EscapeString((const char*)text,'\'');
598
MvgPrintf(context, "text %.4g,%.4g '%.1024s'\n", x, y, escaped_text);
599
MagickFreeMemory(escaped_text);
603
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
607
% D r a w A f f i n e %
611
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
613
% DrawAffine() adjusts the current affine transformation matrix with
614
% the specified affine transformation matrix. Note that the current affine
615
% transform is adjusted rather than replaced.
617
% The format of the DrawAffine method is:
619
% void DrawAffine(DrawContext context, const AffineMatrix *affine)
621
% A description of each parameter follows:
623
% o context: Drawing context
625
% o affine: Affine matrix parameters
628
MagickExport void DrawAffine(DrawContext context, const AffineMatrix *affine)
630
assert(context != (DrawContext)NULL);
631
assert(context->signature == MagickSignature);
632
assert(affine != (const AffineMatrix *)NULL);
634
AdjustAffine( context, affine );
636
MvgPrintf(context, "affine %.6g,%.6g,%.6g,%.6g,%.6g,%.6g\n",
637
affine->sx, affine->rx, affine->ry, affine->sy,
638
affine->tx, affine->ty);
642
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
646
% D r a w A l l o c a t e C o n t e x t %
650
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
652
% DrawAllocateContext() allocates an initial drawing context which is an
653
% opaque handle required by the remaining drawing methods.
655
% The format of the DrawAllocateContext method is:
657
% DrawContext DrawAllocateContext(const DrawInfo *draw_info,
660
% A description of each parameter follows:
662
% o draw_info: Initial drawing defaults. Set to NULL to use
663
% GraphicsMagick defaults.
665
% o image: The image to draw on.
668
MagickExport DrawContext DrawAllocateContext(const DrawInfo *draw_info,
674
/* Allocate initial drawing context */
675
context = MagickAllocateMemory(DrawContext,sizeof(struct _DrawContext));
676
if(context == (DrawContext) NULL)
677
MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
678
UnableToAllocateDrawContext);
680
/* Support structures */
681
context->image = image;
683
/* MVG output string and housekeeping */
685
context->mvg_alloc = 0;
686
context->mvg_length = 0;
687
context->mvg_width = 0;
689
/* Pattern support */
690
context->pattern_id = NULL;
691
context->pattern_offset = 0;
693
context->pattern_bounds.x = 0;
694
context->pattern_bounds.y = 0;
695
context->pattern_bounds.width = 0;
696
context->pattern_bounds.height = 0;
698
/* Graphic context */
700
context->graphic_context=MagickAllocateMemory(DrawInfo **,sizeof(DrawInfo *));
701
if(context->graphic_context == (DrawInfo **) NULL)
703
ThrowException3(&context->image->exception,ResourceLimitError,
704
MemoryAllocationFailed,UnableToDrawOnImage);
705
return (DrawContext) NULL;
707
CurrentContext=CloneDrawInfo((ImageInfo*)NULL,draw_info);
708
if(CurrentContext == (DrawInfo*) NULL)
710
ThrowException3(&context->image->exception,ResourceLimitError,
711
MemoryAllocationFailed,UnableToDrawOnImage);
712
return (DrawContext) NULL;
715
context->filter_off = False;
717
/* Pretty-printing depth */
718
context->indent_depth = 0;
720
/* Path operation support */
721
context->path_operation = PathDefaultOperation;
722
context->path_mode = DefaultPathMode;
724
/* Structure unique signature */
725
context->signature = MagickSignature;
731
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
739
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
741
% DrawArc() draws an arc falling within a specified bounding rectangle on the
744
% The format of the DrawArc method is:
746
% void DrawArc(DrawContext context,
747
% const double sx, const double sy,
748
% const double ex, const double ey,
749
% const double sd, const double ed)
751
% A description of each parameter follows:
753
% o context: drawing context
755
% o sx: starting x ordinate of bounding rectangle
757
% o sy: starting y ordinate of bounding rectangle
759
% o ex: ending x ordinate of bounding rectangle
761
% o ey: ending y ordinate of bounding rectangle
763
% o sd: starting degrees of rotation
765
% o ed: ending degrees of rotation
768
MagickExport void DrawArc(DrawContext context,
769
const double sx, const double sy,
770
const double ex, const double ey,
771
const double sd, const double ed)
773
assert(context != (DrawContext)NULL);
774
assert(context->signature == MagickSignature);
776
MvgPrintf(context, "arc %.4g,%.4g %.4g,%.4g %.4g,%.4g\n",
777
sx, sy, ex, ey, sd, ed);
781
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
785
% D r a w B e z i e r %
789
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
791
% DrawBezier() draws a bezier curve through a set of points on the image.
793
% The format of the DrawBezier method is:
795
% void DrawBezier(DrawContext context, const unsigned long num_coords,
796
% const PointInfo *coordinates)
798
% A description of each parameter follows:
800
% o context: drawing context
802
% o num_coords: number of coordinates
804
% o coordinates: coordinates
807
MagickExport void DrawBezier(DrawContext context, const unsigned long num_coords,
808
const PointInfo *coordinates)
810
assert(context != (DrawContext)NULL);
811
assert(context->signature == MagickSignature);
812
assert(coordinates != (const PointInfo *) NULL);
814
MvgAppendPointsCommand(context,"bezier",num_coords,coordinates);
818
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
822
% D r a w C i r c l e %
826
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
828
% DrawCircle() draws a circle on the image.
830
% The format of the DrawCircle method is:
832
% void DrawCircle(DrawContext context, const double ox,
833
% const double oy, const double px, const double py)
835
% A description of each parameter follows:
837
% o context: drawing context
839
% o ox: origin x ordinate
841
% o oy: origin y ordinate
843
% o px: perimeter x ordinate
845
% o py: perimeter y ordinate
848
MagickExport void DrawCircle(DrawContext context, const double ox,
849
const double oy, const double px, const double py)
851
assert(context != (DrawContext)NULL);
852
assert(context->signature == MagickSignature);
854
MvgPrintf(context, "circle %.4g,%.4g %.4g,%.4g\n", ox, oy, px, py);
858
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
862
% D r a w G e t C l i p P a t h %
866
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
868
% DrawGetClipPath() obtains the current clipping path ID. The value returned
869
% must be deallocated by the user when it is no longer needed.
871
% The format of the DrawGetClipPath method is:
873
% char *DrawGetClipPath(DrawContext context)
875
% A description of each parameter follows:
877
% o context: drawing context
880
MagickExport char *DrawGetClipPath(DrawContext context)
882
assert(context != (DrawContext)NULL);
883
assert(context->signature == MagickSignature);
885
if (CurrentContext->clip_path != (char *) NULL)
886
return (char *)AllocateString(CurrentContext->clip_path);
888
return (char *) NULL;
892
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
896
% D r a w S e t C l i p P a t h %
900
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
902
% DrawSetClipPath() associates a named clipping path with the image. Only
903
% the areas drawn on by the clipping path will be modified as long as it
906
% The format of the DrawSetClipPath method is:
908
% void DrawSetClipPath(DrawContext context, const char *clip_path)
910
% A description of each parameter follows:
912
% o context: drawing context
914
% o clip_path: name of clipping path to associate with image
917
MagickExport void DrawSetClipPath(DrawContext context, const char *clip_path)
919
assert(context != (DrawContext)NULL);
920
assert(context->signature == MagickSignature);
921
assert(clip_path != (const char *) NULL);
923
if( CurrentContext->clip_path == NULL || context->filter_off ||
924
LocaleCompare(CurrentContext->clip_path,clip_path) != 0)
926
CloneString(&CurrentContext->clip_path,clip_path);
927
if(CurrentContext->clip_path == (char*)NULL)
928
ThrowDrawException3(ResourceLimitError,MemoryAllocationFailed,
929
UnableToDrawOnImage);
931
#if DRAW_BINARY_IMPLEMENTATION
932
(void) DrawClipPath(context->image,CurrentContext,CurrentContext->clip_path);
935
MvgPrintf(context, "clip-path url(#%s)\n", clip_path);
940
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
944
% D r a w G e t C l i p R u l e %
948
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
950
% DrawGetClipRule() returns the current polygon fill rule to be used by the
953
% The format of the DrawGetClipRule method is:
955
% FillRule DrawGetClipRule(DrawContext context)
957
% A description of each parameter follows:
959
% o context: drawing context
962
MagickExport FillRule DrawGetClipRule(DrawContext context)
964
assert(context != (DrawContext)NULL);
965
assert(context->signature == MagickSignature);
967
return CurrentContext->fill_rule;
971
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
975
% D r a w S e t C l i p R u l e %
979
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
981
% DrawSetClipRule() set the polygon fill rule to be used by the clipping path.
983
% The format of the DrawSetClipRule method is:
985
% void DrawSetClipRule(DrawContext context,
986
% const FillRule fill_rule)
988
% A description of each parameter follows:
990
% o context: drawing context
992
% o fill_rule: fill rule (EvenOddRule or NonZeroRule)
995
MagickExport void DrawSetClipRule(DrawContext context,
996
const FillRule fill_rule)
1001
assert(context != (DrawContext)NULL);
1002
assert(context->signature == MagickSignature);
1004
if(context->filter_off || (CurrentContext->fill_rule != fill_rule))
1006
CurrentContext->fill_rule = fill_rule;
1021
MvgPrintf(context, "clip-rule %s\n", p);
1026
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1030
% D r a w G e t C l i p U n i t s %
1034
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1036
% DrawGetClipUnits() returns the interpretation of clip path units.
1038
% The format of the DrawGetClipUnits method is:
1040
% ClipPathUnits DrawGetClipUnits(DrawContext context)
1042
% A description of each parameter follows:
1044
% o context: drawing context
1047
MagickExport ClipPathUnits DrawGetClipUnits(DrawContext context)
1049
assert(context != (DrawContext)NULL);
1050
assert(context->signature == MagickSignature);
1052
return CurrentContext->clip_units;
1056
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1060
% D r a w S e t C l i p U n i t s %
1064
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1066
% DrawSetClipUnits() sets the interpretation of clip path units.
1068
% The format of the DrawSetClipUnits method is:
1070
% void DrawSetClipUnits(DrawContext context,
1071
% const ClipPathUnits clip_units)
1073
% A description of each parameter follows:
1075
% o context: drawing context
1077
% o clip_units: units to use (UserSpace, UserSpaceOnUse, or ObjectBoundingBox)
1080
MagickExport void DrawSetClipUnits(DrawContext context,
1081
const ClipPathUnits clip_units)
1086
assert(context != (DrawContext)NULL);
1087
assert(context->signature == MagickSignature);
1089
if(context->filter_off || (CurrentContext->clip_units != clip_units))
1091
CurrentContext->clip_units = clip_units;
1093
if ( clip_units == ObjectBoundingBox )
1098
IdentityAffine(&affine);
1100
affine.sx=CurrentContext->bounds.x2;
1101
affine.sy=CurrentContext->bounds.y2;
1102
affine.tx=CurrentContext->bounds.x1;
1103
affine.ty=CurrentContext->bounds.y1;
1105
AdjustAffine( context, &affine );
1113
case UserSpaceOnUse:
1114
p = "userSpaceOnUse";
1116
case ObjectBoundingBox:
1117
p = "objectBoundingBox";
1122
MvgPrintf(context, "clip-units %s\n", p);
1127
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1131
% D r a w C o l o r %
1135
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1137
% DrawColor() draws color on image using the current fill color, starting at
1138
% specified position, and using specified paint method. The available paint
1141
% PointMethod: Recolors the target pixel
1142
% ReplaceMethod: Recolor any pixel that matches the target pixel.
1143
% FloodfillMethod: Recolors target pixels and matching neighbors.
1144
% FillToBorderMethod: Recolor target pixels and neighbors not matching border color.
1145
% ResetMethod: Recolor all pixels.
1147
% The format of the DrawColor method is:
1149
% void DrawColor(DrawContext context,
1150
% const double x, const double y,
1151
% const PaintMethod paintMethod)
1153
% A description of each parameter follows:
1155
% o context: drawing context
1161
% o paintMethod: paint method
1164
MagickExport void DrawColor(DrawContext context,
1165
const double x, const double y,
1166
const PaintMethod paintMethod)
1171
assert(context != (DrawContext)NULL);
1172
assert(context->signature == MagickSignature);
1174
switch (paintMethod)
1182
case FloodfillMethod:
1185
case FillToBorderMethod:
1194
MvgPrintf(context, "color %.4g,%.4g %s\n", x, y, p);
1198
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1202
% D r a w C o m m e n t %
1206
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1208
% DrawComment() adds a comment to a vector output stream.
1210
% The format of the DrawComment method is:
1212
% void DrawComment(DrawContext context,const char* comment)
1214
% A description of each parameter follows:
1216
% o context: drawing context
1218
% o comment: comment text
1221
MagickExport void DrawComment(DrawContext context,const char* comment)
1223
/* FIXME: should handle multi-line comments by inserting # before
1225
MvgPrintf(context, "#%s\n", comment);
1229
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1233
% D r a w D e s t r o y C o n t e x t %
1237
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1239
% DrawDestroyContext() frees all resources associated with the drawing
1240
% context. Once the drawing context has been freed, it should not be used
1241
% any further unless it re-allocated.
1243
% The format of the DrawDestroyContext method is:
1245
% void DrawDestroyContext(DrawContext context)
1247
% A description of each parameter follows:
1249
% o context: drawing context to destroy
1252
MagickExport void DrawDestroyContext(DrawContext context)
1254
assert(context != (DrawContext)NULL);
1255
assert(context->signature == MagickSignature);
1257
/* Path operation support */
1258
context->path_operation = PathDefaultOperation;
1259
context->path_mode = DefaultPathMode;
1261
/* Pretty-printing depth */
1262
context->indent_depth = 0;
1264
/* Graphic context */
1265
for ( ; context->index > 0; context->index--)
1267
DestroyDrawInfo(CurrentContext);
1268
CurrentContext = (DrawInfo*) NULL;
1270
DestroyDrawInfo(CurrentContext);
1271
CurrentContext = (DrawInfo*) NULL;
1272
MagickFreeMemory(context->graphic_context);
1274
/* Pattern support */
1275
MagickFreeMemory(context->pattern_id);
1276
context->pattern_offset = 0;
1278
context->pattern_bounds.x = 0;
1279
context->pattern_bounds.y = 0;
1280
context->pattern_bounds.width = 0;
1281
context->pattern_bounds.height = 0;
1283
/* MVG output string and housekeeping */
1284
MagickFreeMemory(context->mvg);
1285
context->mvg_alloc = 0;
1286
context->mvg_length = 0;
1288
/* Support structures */
1289
context->image = (Image*)NULL;
1291
/* Context itself */
1292
context->signature = 0;
1293
MagickFreeMemory(context);
1297
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1301
% D r a w E l l i p s e %
1305
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1307
% DrawEllipse() draws an ellipse on the image.
1309
% The format of the DrawEllipse method is:
1311
% void DrawEllipse(DrawContext context,
1312
% const double ox, const double oy,
1313
% const double rx, const double ry,
1314
% const double start, const double end)
1316
% A description of each parameter follows:
1318
% o context: drawing context
1320
% o ox: origin x ordinate
1322
% o oy: origin y ordinate
1328
% o start: starting rotation in degrees
1330
% o end: ending rotation in degrees
1333
MagickExport void DrawEllipse(DrawContext context,
1334
const double ox, const double oy,
1335
const double rx, const double ry,
1336
const double start, const double end)
1338
assert(context != (DrawContext)NULL);
1339
assert(context->signature == MagickSignature);
1341
MvgPrintf(context, "ellipse %.4g,%.4g %.4g,%.4g %.4g,%.4g\n",
1342
ox, oy, rx, ry, start, end);
1346
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1350
% D r a w G e t F i l l C o l o r %
1354
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1356
% DrawGetFillColor() returns the fill color used for drawing filled objects.
1358
% The format of the DrawGetFillColor method is:
1360
% PixelPacket DrawGetFillColor(DrawContext context)
1362
% A description of each parameter follows:
1364
% o context: drawing context
1366
MagickExport PixelPacket DrawGetFillColor(DrawContext context)
1368
assert(context != (DrawContext)NULL);
1369
assert(context->signature == MagickSignature);
1371
return CurrentContext->fill;
1375
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1379
% D r a w S e t F i l l C o l o r %
1383
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1385
% DrawSetFillColor() sets the fill color to be used for drawing filled objects.
1387
% The format of the DrawSetFillColor method is:
1389
% void DrawSetFillColor(DrawContext context,
1390
% const PixelPacket * fill_color)
1392
% A description of each parameter follows:
1394
% o context: drawing context
1396
% o fill_color: fill color
1399
MagickExport void DrawSetFillColor(DrawContext context,
1400
const PixelPacket *fill_color)
1406
assert(context != (DrawContext)NULL);
1407
assert(context->signature == MagickSignature);
1408
assert(fill_color != (const PixelPacket *) NULL);
1410
new_fill = *fill_color;
1412
/* Inherit base opacity */
1413
if(new_fill.opacity == OpaqueOpacity)
1414
new_fill.opacity = CurrentContext->opacity;
1416
current_fill = &CurrentContext->fill;
1417
if( context->filter_off || !(PixelPacketMatch(current_fill,&new_fill)) )
1419
CurrentContext->fill = new_fill;
1421
MvgPrintf(context, "fill '");
1422
MvgAppendColor(context, fill_color);
1423
MvgPrintf(context, "'\n");
1428
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1432
% D r a w S e t F i l l C o l o r S t r i n g %
1436
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1438
% DrawSetFillColorString() sets the fill color to be used for drawing filled
1441
% The format of the DrawSetFillColorString method is:
1443
% void DrawSetFillColorString(DrawContext context, const char* fill_color)
1445
% A description of each parameter follows:
1447
% o context: drawing context
1449
% o fill_color: fill color
1452
MagickExport void DrawSetFillColorString(DrawContext context,
1453
const char* fill_color)
1458
if(QueryColorDatabase(fill_color,&pixel_packet,&context->image->exception))
1459
DrawSetFillColor(context,&pixel_packet);
1463
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1467
% D r a w S e t F i l l P a t t e r n U R L %
1471
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1473
% DrawSetFillPatternURL() sets the URL to use as a fill pattern for filling
1474
% objects. Only local URLs ("#identifier") are supported at this time. These
1475
% local URLs are normally created by defining a named fill pattern with
1476
% DrawPushPattern/DrawPopPattern.
1478
% The format of the DrawSetFillPatternURL method is:
1480
% void DrawSetFillPatternURL(DrawContext context, const char* fill_url)
1482
% A description of each parameter follows:
1484
% o context: drawing context
1486
% o fill_url: URL to use to obtain fill pattern.
1489
MagickExport void DrawSetFillPatternURL(DrawContext context, const char* fill_url)
1492
pattern[MaxTextExtent];
1494
assert(context != (DrawContext)NULL);
1495
assert(context->signature == MagickSignature);
1496
assert(fill_url != NULL);
1498
if(fill_url[0] != '#')
1499
ThrowDrawException(DrawWarning,NotARelativeURL, fill_url);
1501
FormatString(pattern,"[%.1024s]",fill_url+1);
1503
if (GetImageAttribute(context->image,pattern) == (ImageAttribute *) NULL)
1505
ThrowDrawException(DrawWarning,URLNotFound, fill_url)
1510
pattern_spec[MaxTextExtent];
1512
FormatString(pattern_spec,"url(%.1024s)",fill_url);
1513
#if DRAW_BINARY_IMPLEMENTATION
1514
DrawPatternPath(context->image,CurrentContext,pattern_spec,&CurrentContext->fill_pattern);
1516
/* Inherit base opacity */
1517
if (CurrentContext->fill.opacity != TransparentOpacity)
1518
CurrentContext->fill.opacity=CurrentContext->opacity;
1520
MvgPrintf(context, "fill %s\n",pattern_spec);
1525
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1529
% D r a w G e t F i l l O p a c i t y %
1533
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1535
% DrawGetFillOpacity() returns the opacity used when drawing using the fill
1536
% color or fill texture. Fully opaque is 1.0.
1538
% The format of the DrawGetFillOpacity method is:
1540
% double DrawGetFillOpacity(DrawContext context)
1542
% A description of each parameter follows:
1544
% o context: drawing context
1547
MagickExport double DrawGetFillOpacity(DrawContext context)
1549
assert(context != (DrawContext)NULL);
1550
assert(context->signature == MagickSignature);
1552
return (((double)(MaxRGB-CurrentContext->fill.opacity))/MaxRGB);
1556
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1560
% D r a w S e t F i l l O p a c i t y %
1564
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1566
% DrawSetFillOpacity() sets the opacity to use when drawing using the fill
1567
% color or fill texture. Fully opaque is 1.0.
1569
% The format of the DrawSetFillOpacity method is:
1571
% void DrawSetFillOpacity(DrawContext context, const double fill_opacity)
1573
% A description of each parameter follows:
1575
% o context: drawing context
1577
% o fill_opacity: fill opacity
1580
MagickExport void DrawSetFillOpacity(DrawContext context,
1581
const double fill_opacity)
1589
assert(context != (DrawContext)NULL);
1590
assert(context->signature == MagickSignature);
1592
validated_opacity=(fill_opacity < 0.0 ? 0.0 : (fill_opacity > 1.0 ? 1.0 : fill_opacity));
1593
quantum_opacity = (Quantum) (((double) MaxRGB*(1.0-validated_opacity))+0.5);
1595
if (context->filter_off || (CurrentContext->fill.opacity != quantum_opacity))
1597
CurrentContext->fill.opacity = quantum_opacity;
1598
MvgPrintf(context, "fill-opacity %.4g\n", validated_opacity);
1603
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1607
% D r a w G e t F i l l R u l e %
1611
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1613
% DrawGetFillRule() returns the fill rule used while drawing polygons.
1615
% The format of the DrawGetFillRule method is:
1617
% FillRule DrawGetFillRule(DrawContext context)
1619
% A description of each parameter follows:
1621
% o context: drawing context
1623
MagickExport FillRule DrawGetFillRule(DrawContext context)
1625
assert(context != (DrawContext)NULL);
1626
assert(context->signature == MagickSignature);
1628
return CurrentContext->fill_rule;
1632
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1636
% D r a w S e t F i l l R u l e %
1640
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1642
% DrawSetFillRule() sets the fill rule to use while drawing polygons.
1644
% The format of the DrawSetFillRule method is:
1646
% void DrawSetFillRule(DrawContext context, const FillRule fill_rule)
1648
% A description of each parameter follows:
1650
% o context: drawing context
1652
% o fill_rule: fill rule (EvenOddRule or NonZeroRule)
1655
MagickExport void DrawSetFillRule(DrawContext context,
1656
const FillRule fill_rule)
1661
assert(context != (DrawContext)NULL);
1662
assert(context->signature == MagickSignature);
1664
if(context->filter_off || (CurrentContext->fill_rule != fill_rule))
1666
CurrentContext->fill_rule = fill_rule;
1681
MvgPrintf(context, "fill-rule %s\n", p);
1686
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1690
% D r a w G e t F o n t %
1694
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1696
% DrawGetFont() returns a null-terminaged string specifying the font used
1697
% when annotating with text. The value returned must be freed by the user
1698
% when no longer needed.
1700
% The format of the DrawGetFont method is:
1702
% char *DrawGetFont(DrawContext context)
1704
% A description of each parameter follows:
1706
% o context: drawing context
1708
MagickExport char *DrawGetFont(DrawContext context)
1710
assert(context != (DrawContext)NULL);
1711
assert(context->signature == MagickSignature);
1713
if (CurrentContext->font != (char *) NULL)
1714
return AllocateString(CurrentContext->font);
1716
return (char *) NULL;
1720
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1724
% D r a w S e t F o n t %
1728
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1730
% DrawSetFont() sets the fully-sepecified font to use when annotating with
1733
% The format of the DrawSetFont method is:
1735
% void DrawSetFont(DrawContext context, const char *font_name)
1737
% A description of each parameter follows:
1739
% o context: drawing context
1741
% o font_name: font name
1744
MagickExport void DrawSetFont(DrawContext context, const char *font_name)
1746
assert(context != (DrawContext)NULL);
1747
assert(context->signature == MagickSignature);
1748
assert(font_name != (const char *) NULL);
1750
if(context->filter_off || (CurrentContext->font == NULL) ||
1751
LocaleCompare(CurrentContext->font,font_name) != 0)
1753
(void) CloneString(&CurrentContext->font,font_name);
1754
if(CurrentContext->font == (char*)NULL)
1755
ThrowDrawException3(ResourceLimitError,MemoryAllocationFailed,
1756
UnableToDrawOnImage);
1757
MvgPrintf(context, "font '%s'\n", font_name);
1762
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1766
% D r a w G e t F o n t F a m i l y %
1770
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1772
% DrawGetFontFamily() returns the font family to use when annotating with text.
1773
% The value returned must be freed by the user when it is no longer needed.
1775
% The format of the DrawGetFontFamily method is:
1777
% char *DrawGetFontFamily(DrawContext context)
1779
% A description of each parameter follows:
1781
% o context: drawing context
1783
MagickExport char *DrawGetFontFamily(DrawContext context)
1785
assert(context != (DrawContext)NULL);
1786
assert(context->signature == MagickSignature);
1788
if (CurrentContext->family != NULL)
1789
return AllocateString(CurrentContext->family);
1791
return (char *) NULL;
1795
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1799
% D r a w S e t F o n t F a m i l y %
1803
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1805
% DrawSetFontFamily() sets the font family to use when annotating with text.
1807
% The format of the DrawSetFontFamily method is:
1809
% void DrawSetFontFamily(DrawContext context, const char *font_family)
1811
% A description of each parameter follows:
1813
% o context: drawing context
1815
% o font_family: font family
1818
MagickExport void DrawSetFontFamily(DrawContext context,
1819
const char *font_family)
1821
assert(context != (DrawContext)NULL);
1822
assert(context->signature == MagickSignature);
1823
assert(font_family != (const char *) NULL);
1825
if(context->filter_off || (CurrentContext->family == NULL) ||
1826
LocaleCompare(CurrentContext->family,font_family) != 0)
1828
(void) CloneString(&CurrentContext->family,font_family);
1829
if(CurrentContext->family == (char*)NULL)
1830
ThrowDrawException3(ResourceLimitError,MemoryAllocationFailed,
1831
UnableToDrawOnImage);
1832
MvgPrintf(context, "font-family '%s'\n", font_family);
1837
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1841
% D r a w G e t F o n t S i z e %
1845
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1847
% DrawGetFontSize() returns the font pointsize used when annotating with text.
1849
% The format of the DrawGetFontSize method is:
1851
% double DrawGetFontSize(DrawContext context)
1853
% A description of each parameter follows:
1855
% o context: drawing context
1857
MagickExport double DrawGetFontSize(DrawContext context)
1859
assert(context != (DrawContext)NULL);
1860
assert(context->signature == MagickSignature);
1862
return CurrentContext->pointsize;
1866
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1870
% D r a w S e t F o n t S i z e %
1874
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1876
% DrawSetFontSize() sets the font pointsize to use when annotating with text.
1878
% The format of the DrawSetFontSize method is:
1880
% void DrawSetFontSize(DrawContext context, const double pointsize)
1882
% A description of each parameter follows:
1884
% o context: drawing context
1886
% o pointsize: text pointsize
1889
MagickExport void DrawSetFontSize(DrawContext context,
1890
const double pointsize)
1892
assert(context != (DrawContext)NULL);
1893
assert(context->signature == MagickSignature);
1895
if(context->filter_off ||
1896
(AbsoluteValue(CurrentContext->pointsize-pointsize) > MagickEpsilon))
1898
CurrentContext->pointsize=pointsize;
1900
MvgPrintf(context, "font-size %.4g\n", pointsize);
1905
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1909
% D r a w G e t F o n t S t r e t c h %
1913
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1915
% DrawGetFontStretch() returns the font stretch used when annotating with text.
1917
% The format of the DrawGetFontStretch method is:
1919
% StretchType DrawGetFontStretch(DrawContext context)
1921
% A description of each parameter follows:
1923
% o context: drawing context
1925
MagickExport StretchType DrawGetFontStretch(DrawContext context)
1927
assert(context != (DrawContext)NULL);
1928
assert(context->signature == MagickSignature);
1930
return CurrentContext->stretch;
1934
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1938
% D r a w S e t F o n t S t r e t c h %
1942
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1944
% DrawSetFontStretch() sets the font stretch to use when annotating with text.
1945
% The AnyStretch enumeration acts as a wild-card "don't care" option.
1947
% The format of the DrawSetFontStretch method is:
1949
% void DrawSetFontStretch(DrawContext context,
1950
% const StretchType font_stretch)
1952
% A description of each parameter follows:
1954
% o context: drawing context
1956
% o font_stretch: font stretch (NormalStretch, UltraCondensedStretch,
1957
% CondensedStretch, SemiCondensedStretch,
1958
% SemiExpandedStretch, ExpandedStretch,
1959
% ExtraExpandedStretch, UltraExpandedStretch, AnyStretch)
1962
MagickExport void DrawSetFontStretch(DrawContext context,
1963
const StretchType font_stretch)
1968
assert(context != (DrawContext)NULL);
1969
assert(context->signature == MagickSignature);
1971
if(context->filter_off || (CurrentContext->stretch != font_stretch))
1973
CurrentContext->stretch=font_stretch;
1975
switch (font_stretch)
1980
case UltraCondensedStretch:
1981
p = "ultra-condensed";
1983
case ExtraCondensedStretch:
1984
p = "extra-condensed";
1986
case CondensedStretch:
1989
case SemiCondensedStretch:
1990
p = "semi-condensed";
1992
case SemiExpandedStretch:
1993
p = "semi-expanded";
1995
case ExpandedStretch:
1998
case ExtraExpandedStretch:
1999
p = "extra-expanded";
2001
case UltraExpandedStretch:
2002
p = "ultra-expanded";
2010
MvgPrintf(context, "font-stretch '%s'\n", p);
2015
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2019
% D r a w G e t F o n t S t y l e %
2023
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2025
% DrawGetFontStyle() returns the font style used when annotating with text.
2027
% The format of the DrawGetFontStyle method is:
2029
% StyleType DrawGetFontStyle(DrawContext context)
2031
% A description of each parameter follows:
2033
% o context: drawing context
2035
MagickExport StyleType DrawGetFontStyle(DrawContext context)
2037
assert(context != (DrawContext)NULL);
2038
assert(context->signature == MagickSignature);
2040
return CurrentContext->style;
2044
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2048
% D r a w S e t F o n t S t y l e %
2052
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2054
% DrawSetFontStyle() sets the font style to use when annotating with text.
2055
% The AnyStyle enumeration acts as a wild-card "don't care" option.
2057
% The format of the DrawSetFontStyle method is:
2059
% void DrawSetFontStyle(DrawContext context, const StyleType style)
2061
% A description of each parameter follows:
2063
% o context: drawing context
2065
% o style: font style (NormalStyle, ItalicStyle, ObliqueStyle, AnyStyle)
2068
MagickExport void DrawSetFontStyle(DrawContext context,
2069
const StyleType style)
2074
assert(context != (DrawContext)NULL);
2075
assert(context->signature == MagickSignature);
2077
if(context->filter_off || (CurrentContext->style != style))
2079
CurrentContext->style=style;
2098
MvgPrintf(context, "font-style '%s'\n", p);
2103
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2107
% D r a w G e t F o n t W e i g h t %
2111
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2113
% DrawGetFontWeight() returns the font weight used when annotating with text.
2115
% The format of the DrawGetFontWeight method is:
2117
% unsigned long DrawGetFontWeight(DrawContext context)
2119
% A description of each parameter follows:
2121
% o context: drawing context
2123
MagickExport unsigned long DrawGetFontWeight(DrawContext context)
2125
assert(context != (DrawContext)NULL);
2126
assert(context->signature == MagickSignature);
2128
return CurrentContext->weight;
2132
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2136
% D r a w S e t F o n t W e i g h t %
2140
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2142
% DrawSetFontWeight() sets the font weight to use when annotating with text.
2144
% The format of the DrawSetFontWeight method is:
2146
% void DrawSetFontWeight(DrawContext context,
2147
% const unsigned long font_weight)
2149
% A description of each parameter follows:
2151
% o context: drawing context
2153
% o font_weight: font weight (valid range 100-900)
2156
MagickExport void DrawSetFontWeight(DrawContext context,
2157
const unsigned long font_weight)
2159
assert(context != (DrawContext)NULL);
2160
assert(context->signature == MagickSignature);
2162
if(context->filter_off || (CurrentContext->weight != font_weight))
2164
CurrentContext->weight=font_weight;
2165
MvgPrintf(context, "font-weight %lu\n", font_weight);
2170
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2174
% D r a w G e t G r a v i t y %
2178
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2180
% DrawGetGravity() returns the text placement gravity used when annotating
2183
% The format of the DrawGetGravity method is:
2185
% GravityType DrawGetGravity(DrawContext context)
2187
% A description of each parameter follows:
2189
% o context: drawing context
2191
MagickExport GravityType DrawGetGravity(DrawContext context)
2193
assert(context != (DrawContext)NULL);
2194
assert(context->signature == MagickSignature);
2196
return CurrentContext->gravity;
2200
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2204
% D r a w S e t G r a v i t y %
2208
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2210
% DrawSetGravity() sets the text placement gravity to use when annotating
2213
% The format of the DrawSetGravity method is:
2215
% void DrawSetGravity(DrawContext context, const GravityType gravity)
2217
% A description of each parameter follows:
2219
% o context: drawing context
2221
% o gravity: positioning gravity (NorthWestGravity, NorthGravity,
2222
% NorthEastGravity, WestGravity, CenterGravity,
2223
% EastGravity, SouthWestGravity, SouthGravity,
2227
MagickExport void DrawSetGravity(DrawContext context,
2228
const GravityType gravity)
2233
assert(context != (DrawContext)NULL);
2234
assert(context->signature == MagickSignature);
2236
if(context->filter_off || (CurrentContext->gravity != gravity))
2238
CurrentContext->gravity=gravity;
2242
case NorthWestGravity:
2248
case NorthEastGravity:
2260
case SouthWestGravity:
2266
case SouthEastGravity:
2277
MvgPrintf(context, "gravity %s\n", p);
2282
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2286
% D r a w C o m p o s i t e %
2290
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2292
% DrawComposite() composites an image onto the current image, using the
2293
% specified composition operator, specified position, and at the specified
2296
% The format of the DrawComposite method is:
2298
% void DrawComposite(DrawContext context,
2299
% const CompositeOperator composite_operator,
2300
% const double x, const double y,
2301
% const double width, const double height,
2302
% const Image * image )
2304
% A description of each parameter follows:
2306
% o context: drawing context
2308
% o composite_operator: composition operator
2310
% o x: x ordinate of top left corner
2312
% o y: y ordinate of top left corner
2314
% o width: Width to resize image to prior to compositing. Specify zero to
2315
% use existing width.
2317
% o height: Height to resize image to prior to compositing. Specify zero
2318
% to use existing height.
2320
% o image: Image to composite
2323
MagickExport void DrawComposite(DrawContext context,
2324
const CompositeOperator composite_operator,
2325
const double x, const double y,
2326
const double width, const double height,
2327
const Image * image )
2344
*blob = (unsigned char*)NULL;
2353
assert(context != (DrawContext)NULL);
2354
assert(image != (Image *) NULL);
2356
assert(height != 0);
2357
assert(*image->magick != '\0');
2359
/* LogMagickEvent(CoderEvent,GetMagickModule(),"DrawComposite columns=%ld rows=%ld magick=%s ", */
2360
/* image->columns, image->rows, image->magick ); */
2362
clone_image = CloneImage(image,0,0,True,&context->image->exception);
2366
image_info = CloneImageInfo((ImageInfo*)NULL);
2368
ThrowDrawException3(ResourceLimitError,MemoryAllocationFailed,
2369
UnableToDrawOnImage);
2370
handler=SetMonitorHandler((MonitorHandler) NULL);
2371
blob = (unsigned char*)ImageToBlob( image_info, clone_image, &blob_length,
2372
&context->image->exception );
2373
(void) SetMonitorHandler(handler);
2374
DestroyImageInfo(image_info);
2375
DestroyImageList(clone_image);
2379
base64 = Base64Encode(blob,blob_length,&encoded_length);
2380
MagickFreeMemory(blob);
2384
buffer[MaxTextExtent];
2386
FormatString(buffer,"%ld bytes", (4L*blob_length/3L+4L));
2387
ThrowDrawException(ResourceLimitWarning,MemoryAllocationFailed,buffer)
2391
switch (composite_operator)
2393
case AddCompositeOp:
2396
case AtopCompositeOp:
2399
case BumpmapCompositeOp:
2402
case ClearCompositeOp:
2405
case ColorizeCompositeOp:
2406
mode = "colorize_not_supported";
2408
case CopyBlueCompositeOp:
2411
case CopyCompositeOp:
2414
case CopyGreenCompositeOp:
2417
case CopyOpacityCompositeOp:
2418
mode = "copyopacity";
2420
case CopyRedCompositeOp:
2423
case DarkenCompositeOp:
2424
mode = "darken_not_supported";
2426
case DifferenceCompositeOp:
2427
mode = "difference";
2429
case DisplaceCompositeOp:
2430
mode = "displace_not_supported";
2432
case DissolveCompositeOp:
2433
mode = "dissolve_not_supported";
2435
case HueCompositeOp:
2436
mode = "hue_not_supported";
2441
case LightenCompositeOp:
2442
mode = "lighten_not_supported";
2444
case LuminizeCompositeOp:
2445
mode = "luminize_not_supported";
2447
case MinusCompositeOp:
2450
case ModulateCompositeOp:
2451
mode = "modulate_not_supported";
2453
case MultiplyCompositeOp:
2457
mode = "no_not_supported";
2459
case OutCompositeOp:
2462
case OverCompositeOp:
2465
case OverlayCompositeOp:
2466
mode = "overlay_not_supported";
2468
case PlusCompositeOp:
2471
case SaturateCompositeOp:
2472
mode = "saturate_not_supported";
2474
case ScreenCompositeOp:
2475
mode = "screen_not_supported";
2477
case SubtractCompositeOp:
2480
case ThresholdCompositeOp:
2483
case XorCompositeOp:
2490
media_type = MagickToMime( image->magick );
2492
if( media_type != NULL )
2500
MvgPrintf(context, "image %s %.4g,%.4g %.4g,%.4g 'data:%s;base64,\n",
2501
mode, x, y, width, height, media_type);
2503
remaining = (int)encoded_length;
2505
while( remaining > 0 )
2507
MvgPrintf(context,"%.76s", str);
2511
MvgPrintf(context,"\n");
2514
MvgPrintf(context,"'\n");
2517
MagickFreeMemory(base64);
2518
MagickFreeMemory(media_type);
2522
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2530
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2532
% DrawLine() draws a line on the image using the current stroke color,
2533
% stroke opacity, and stroke width.
2535
% The format of the DrawLine method is:
2537
% void DrawLine(DrawContext context,
2538
% const double sx, const double sy,
2539
% const double ex, const double ey)
2541
% A description of each parameter follows:
2543
% o context: drawing context
2545
% o sx: starting x ordinate
2547
% o sy: starting y ordinate
2549
% o ex: ending x ordinate
2551
% o ey: ending y ordinate
2554
MagickExport void DrawLine(DrawContext context,
2555
const double sx, const double sy,
2556
const double ex, const double ey)
2558
assert(context != (DrawContext)NULL);
2559
assert(context->signature == MagickSignature);
2561
MvgPrintf(context, "line %.4g,%.4g %.4g,%.4g\n", sx, sy, ex, ey);
2565
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2569
% D r a w M a t t e %
2573
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2575
% DrawMatte() paints on the image's opacity channel in order to set effected
2576
% pixels to transparent.
2577
% to influence the opacity of pixels. The available paint
2580
% PointMethod: Select the target pixel
2581
% ReplaceMethod: Select any pixel that matches the target pixel.
2582
% FloodfillMethod: Select the target pixel and matching neighbors.
2583
% FillToBorderMethod: Select the target pixel and neighbors not matching
2585
% ResetMethod: Select all pixels.
2587
% The format of the DrawMatte method is:
2589
% void DrawMatte(DrawContext context,
2590
% const double x, const double y,
2591
% const PaintMethod paint_method)
2593
% A description of each parameter follows:
2595
% o context: drawing context
2604
MagickExport void DrawMatte(DrawContext context,
2605
const double x, const double y,
2606
const PaintMethod paint_method)
2611
assert(context != (DrawContext)NULL);
2612
assert(context->signature == MagickSignature);
2614
switch (paint_method)
2622
case FloodfillMethod:
2625
case FillToBorderMethod:
2634
MvgPrintf(context, "matte %.4g,%.4g %s\n", x, y, p);
2638
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2642
% D r a w P a t h C l o s e %
2646
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2648
% DrawPathClose() adds a path element to the current path which closes the
2649
% current subpath by drawing a straight line from the current point to the
2650
% current subpath's most recent starting point (usually, the most recent
2653
% The format of the DrawPathClose method is:
2655
% void DrawPathClose(DrawContext context)
2657
% A description of each parameter follows:
2659
% o context: drawing context
2662
MagickExport void DrawPathClose(DrawContext context)
2664
assert(context != (DrawContext)NULL);
2665
assert(context->signature == MagickSignature);
2667
MvgAutoWrapPrintf(context, "%s", context->path_mode == AbsolutePathMode ? "Z" : "z");
2671
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2675
% D r a w P a t h C u r v e T o A b s o l u t e %
2679
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2681
% DrawPathCurveToAbsolute() draws a cubic Bļæ½zier curve from the current
2682
% point to (x,y) using (x1,y1) as the control point at the beginning of
2683
% the curve and (x2,y2) as the control point at the end of the curve using
2684
% absolute coordinates. At the end of the command, the new current point
2685
% becomes the final (x,y) coordinate pair used in the polybezier.
2687
% The format of the DrawPathCurveToAbsolute method is:
2689
% void DrawPathCurveToAbsolute(DrawContext context,
2690
% const double x1, const double y1,
2691
% const double x2, const double y2,
2692
% const double x, const double y)
2694
% A description of each parameter follows:
2696
% o context: drawing context
2698
% o x1: x ordinate of control point for curve beginning
2700
% o y1: y ordinate of control point for curve beginning
2702
% o x2: x ordinate of control point for curve ending
2704
% o y2: y ordinate of control point for curve ending
2706
% o x: x ordinate of the end of the curve
2708
% o y: y ordinate of the end of the curve
2711
static void DrawPathCurveTo(DrawContext context,
2712
const PathMode mode,
2713
const double x1, const double y1,
2714
const double x2, const double y2,
2715
const double x, const double y)
2717
assert(context != (DrawContext)NULL);
2718
assert(context->signature == MagickSignature);
2720
if ((context->path_operation != PathCurveToOperation)
2721
|| (context->path_mode != mode))
2723
context->path_operation = PathCurveToOperation;
2724
context->path_mode = mode;
2725
MvgAutoWrapPrintf(context, "%c%.4g,%.4g %.4g,%.4g %.4g,%.4g",
2726
mode == AbsolutePathMode ? 'C' : 'c',
2727
x1, y1, x2, y2, x, y);
2730
MvgAutoWrapPrintf(context, " %.4g,%.4g %.4g,%.4g %.4g,%.4g",
2731
x1, y1, x2, y2, x, y);
2733
MagickExport void DrawPathCurveToAbsolute(DrawContext context,
2734
const double x1, const double y1,
2735
const double x2, const double y2,
2736
const double x, const double y)
2738
assert(context != (DrawContext)NULL);
2739
assert(context->signature == MagickSignature);
2741
DrawPathCurveTo(context, AbsolutePathMode, x1, y1, x2, y2, x, y);
2745
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2749
% D r a w P a t h C u r v e T o R e l a t i v e %
2753
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2755
% DrawPathCurveToRelative() draws a cubic Bļæ½zier curve from the current
2756
% point to (x,y) using (x1,y1) as the control point at the beginning of
2757
% the curve and (x2,y2) as the control point at the end of the curve using
2758
% relative coordinates. At the end of the command, the new current point
2759
% becomes the final (x,y) coordinate pair used in the polybezier.
2761
% The format of the DrawPathCurveToRelative method is:
2763
% void DrawPathCurveToRelative(DrawContext context,
2764
% const double x1, const double y1,
2765
% const double x2, const double y2,
2766
% const double x, const double y)
2768
% A description of each parameter follows:
2770
% o context: drawing context
2772
% o x1: x ordinate of control point for curve beginning
2774
% o y1: y ordinate of control point for curve beginning
2776
% o x2: x ordinate of control point for curve ending
2778
% o y2: y ordinate of control point for curve ending
2780
% o x: x ordinate of the end of the curve
2782
% o y: y ordinate of the end of the curve
2785
MagickExport void DrawPathCurveToRelative(DrawContext context,
2786
const double x1, const double y1,
2787
const double x2, const double y2,
2788
const double x, const double y)
2790
assert(context != (DrawContext)NULL);
2791
assert(context->signature == MagickSignature);
2793
DrawPathCurveTo(context, RelativePathMode, x1, y1, x2, y2, x, y);
2797
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2801
% D r a w P a t h C u r v e T o Q u a d r a t i c B e z i e r A b s o l u t e %
2805
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2807
% DrawPathCurveToQuadraticBezierAbsolute() draws a quadratic Bļæ½zier curve
2808
% from the current point to (x,y) using (x1,y1) as the control point using
2809
% absolute coordinates. At the end of the command, the new current point
2810
% becomes the final (x,y) coordinate pair used in the polybezier.
2812
% The format of the DrawPathCurveToQuadraticBezierAbsolute method is:
2814
% void DrawPathCurveToQuadraticBezierAbsolute(DrawContext context,
2820
% A description of each parameter follows:
2822
% o context: drawing context
2824
% o x1: x ordinate of the control point
2826
% o y1: y ordinate of the control point
2828
% o x: x ordinate of final point
2830
% o y: y ordinate of final point
2833
static void DrawPathCurveToQuadraticBezier(DrawContext context,
2834
const PathMode mode,
2835
const double x1, double y1,
2836
const double x, const double y)
2838
assert(context != (DrawContext)NULL);
2839
assert(context->signature == MagickSignature);
2841
if ((context->path_operation != PathCurveToQuadraticBezierOperation)
2842
|| (context->path_mode != mode))
2844
context->path_operation = PathCurveToQuadraticBezierOperation;
2845
context->path_mode = mode;
2846
MvgAutoWrapPrintf(context, "%c%.4g,%.4g %.4g,%.4g",
2847
mode == AbsolutePathMode ? 'Q' : 'q', x1, y1, x, y);
2850
MvgAutoWrapPrintf(context, " %.4g,%.4g %.4g,%.4g", x1, y1, x, y);
2852
MagickExport void DrawPathCurveToQuadraticBezierAbsolute(DrawContext context,
2858
assert(context != (DrawContext)NULL);
2859
assert(context->signature == MagickSignature);
2861
DrawPathCurveToQuadraticBezier(context, AbsolutePathMode, x1, y1, x, y);
2865
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2869
% D r a w P a t h C u r v e T o Q u a d r a t i c B e z i e r R e l a t i v e %
2873
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2875
% DrawPathCurveToQuadraticBezierRelative() draws a quadratic Bļæ½zier curve
2876
% from the current point to (x,y) using (x1,y1) as the control point using
2877
% relative coordinates. At the end of the command, the new current point
2878
% becomes the final (x,y) coordinate pair used in the polybezier.
2880
% The format of the DrawPathCurveToQuadraticBezierRelative method is:
2882
% void DrawPathCurveToQuadraticBezierRelative(DrawContext context,
2888
% A description of each parameter follows:
2890
% o context: drawing context
2892
% o x1: x ordinate of the control point
2894
% o y1: y ordinate of the control point
2896
% o x: x ordinate of final point
2898
% o y: y ordinate of final point
2901
MagickExport void DrawPathCurveToQuadraticBezierRelative(DrawContext context,
2907
assert(context != (DrawContext)NULL);
2908
assert(context->signature == MagickSignature);
2910
DrawPathCurveToQuadraticBezier(context, RelativePathMode, x1, y1, x, y);
2914
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2918
% D r a w P a t h C u r v e T o Q u a d r a t i c B e z i e r S m o o t h A b s o l u t e %
2922
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2924
% DrawPathCurveToQuadraticBezierSmoothAbsolute() draws a quadratic
2925
% Bļæ½zier curve (using absolute coordinates) from the current point to
2926
% (x,y). The control point is assumed to be the reflection of the
2927
% control point on the previous command relative to the current
2928
% point. (If there is no previous command or if the previous command was
2929
% not a DrawPathCurveToQuadraticBezierAbsolute,
2930
% DrawPathCurveToQuadraticBezierRelative,
2931
% DrawPathCurveToQuadraticBezierSmoothAbsolut or
2932
% DrawPathCurveToQuadraticBezierSmoothRelative, assume the control point
2933
% is coincident with the current point.). At the end of the command, the
2934
% new current point becomes the final (x,y) coordinate pair used in the
2937
% The format of the DrawPathCurveToQuadraticBezierSmoothAbsolute method is:
2939
% void DrawPathCurveToQuadraticBezierSmoothAbsolute(DrawContext
2944
% A description of each parameter follows:
2946
% o context: drawing context
2948
% o x: x ordinate of final point
2950
% o y: y ordinate of final point
2953
static void DrawPathCurveToQuadraticBezierSmooth(DrawContext context,
2954
const PathMode mode,
2955
const double x, const double y)
2957
assert(context != (DrawContext)NULL);
2958
assert(context->signature == MagickSignature);
2960
if ((context->path_operation != PathCurveToQuadraticBezierSmoothOperation)
2961
|| (context->path_mode != mode))
2963
context->path_operation = PathCurveToQuadraticBezierSmoothOperation;
2964
context->path_mode = mode;
2965
MvgAutoWrapPrintf(context, "%c%.4g,%.4g",
2966
mode == AbsolutePathMode ? 'T' : 't', x, y);
2969
MvgAutoWrapPrintf(context, " %.4g,%.4g", x, y);
2971
MagickExport void DrawPathCurveToQuadraticBezierSmoothAbsolute(DrawContext
2976
assert(context != (DrawContext)NULL);
2977
assert(context->signature == MagickSignature);
2979
DrawPathCurveToQuadraticBezierSmooth(context, AbsolutePathMode, x, y);
2983
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2987
% D r a w P a t h C u r v e T o Q u a d r a t i c B e z i e r S m o o t h R e l a t i v e %
2991
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2993
% DrawPathCurveToQuadraticBezierSmoothAbsolute() draws a quadratic
2994
% Bļæ½zier curve (using relative coordinates) from the current point to
2995
% (x,y). The control point is assumed to be the reflection of the
2996
% control point on the previous command relative to the current
2997
% point. (If there is no previous command or if the previous command was
2998
% not a DrawPathCurveToQuadraticBezierAbsolute,
2999
% DrawPathCurveToQuadraticBezierRelative,
3000
% DrawPathCurveToQuadraticBezierSmoothAbsolut or
3001
% DrawPathCurveToQuadraticBezierSmoothRelative, assume the control point
3002
% is coincident with the current point.). At the end of the command, the
3003
% new current point becomes the final (x,y) coordinate pair used in the
3006
% The format of the DrawPathCurveToQuadraticBezierSmoothRelative method is:
3008
% void DrawPathCurveToQuadraticBezierSmoothRelative(DrawContext
3013
% A description of each parameter follows:
3015
% o context: drawing context
3017
% o x: x ordinate of final point
3019
% o y: y ordinate of final point
3023
MagickExport void DrawPathCurveToQuadraticBezierSmoothRelative(DrawContext
3028
DrawPathCurveToQuadraticBezierSmooth(context, RelativePathMode, x, y);
3032
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3036
% D r a w P a t h C u r v e T o S m o o t h A b s o l u t e %
3040
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3042
% DrawPathCurveToSmoothAbsolute() draws a cubic Bļæ½zier curve from the
3043
% current point to (x,y) using absolute coordinates. The first control
3044
% point is assumed to be the reflection of the second control point on
3045
% the previous command relative to the current point. (If there is no
3046
% previous command or if the previous command was not an
3047
% DrawPathCurveToAbsolute, DrawPathCurveToRelative,
3048
% DrawPathCurveToSmoothAbsolute or DrawPathCurveToSmoothRelative, assume
3049
% the first control point is coincident with the current point.) (x2,y2)
3050
% is the second control point (i.e., the control point at the end of the
3051
% curve). At the end of the command, the new current point becomes the
3052
% final (x,y) coordinate pair used in the polybezier.
3054
% The format of the DrawPathCurveToSmoothAbsolute method is:
3056
% void DrawPathCurveToSmoothAbsolute(DrawContext context,
3057
% const double x2, const double y2,
3058
% const double x, const double y)
3060
% A description of each parameter follows:
3062
% o context: drawing context
3064
% o x2: x ordinate of second control point
3066
% o y2: y ordinate of second control point
3068
% o x: x ordinate of termination point
3070
% o y: y ordinate of termination point
3074
static void DrawPathCurveToSmooth(DrawContext context, const PathMode mode,
3075
const double x2, const double y2,
3076
const double x, const double y)
3078
assert(context != (DrawContext)NULL);
3079
assert(context->signature == MagickSignature);
3081
if ((context->path_operation != PathCurveToSmoothOperation)
3082
|| (context->path_mode != mode))
3084
context->path_operation = PathCurveToSmoothOperation;
3085
context->path_mode = mode;
3086
MvgAutoWrapPrintf(context, "%c%.4g,%.4g %.4g,%.4g",
3087
mode == AbsolutePathMode ? 'S' : 's', x2, y2, x, y);
3090
MvgAutoWrapPrintf(context, " %.4g,%.4g %.4g,%.4g", x2, y2, x, y);
3092
MagickExport void DrawPathCurveToSmoothAbsolute(DrawContext context,
3093
const double x2, const double y2,
3094
const double x, const double y)
3096
assert(context != (DrawContext)NULL);
3097
assert(context->signature == MagickSignature);
3099
DrawPathCurveToSmooth(context, AbsolutePathMode, x2, y2, x, y);
3103
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3107
% D r a w P a t h C u r v e T o S m o o t h R e l a t i v e %
3111
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3113
% DrawPathCurveToSmoothRelative() draws a cubic Bļæ½zier curve from the
3114
% current point to (x,y) using relative coordinates. The first control
3115
% point is assumed to be the reflection of the second control point on
3116
% the previous command relative to the current point. (If there is no
3117
% previous command or if the previous command was not an
3118
% DrawPathCurveToAbsolute, DrawPathCurveToRelative,
3119
% DrawPathCurveToSmoothAbsolute or DrawPathCurveToSmoothRelative, assume
3120
% the first control point is coincident with the current point.) (x2,y2)
3121
% is the second control point (i.e., the control point at the end of the
3122
% curve). At the end of the command, the new current point becomes the
3123
% final (x,y) coordinate pair used in the polybezier.
3125
% The format of the DrawPathCurveToSmoothRelative method is:
3127
% void DrawPathCurveToSmoothRelative(DrawContext context,
3128
% const double x2, const double y2,
3129
% const double x, const double y)
3131
% A description of each parameter follows:
3133
% o context: drawing context
3135
% o x2: x ordinate of second control point
3137
% o y2: y ordinate of second control point
3139
% o x: x ordinate of termination point
3141
% o y: y ordinate of termination point
3145
MagickExport void DrawPathCurveToSmoothRelative(DrawContext context,
3146
const double x2, const double y2,
3147
const double x, const double y)
3149
assert(context != (DrawContext)NULL);
3150
assert(context->signature == MagickSignature);
3152
DrawPathCurveToSmooth(context, RelativePathMode, x2, y2, x, y);
3156
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3160
% D r a w P a t h E l l i p t i c A r c A b s o l u t e %
3164
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3166
% DrawPathEllipticArcAbsolute() draws an elliptical arc from the current
3167
% point to (x, y) using absolute coordinates. The size and orientation
3168
% of the ellipse are defined by two radii (rx, ry) and an
3169
% xAxisRotation, which indicates how the ellipse as a whole is rotated
3170
% relative to the current coordinate system. The center (cx, cy) of the
3171
% ellipse is calculated automatically to satisfy the constraints imposed
3172
% by the other parameters. largeArcFlag and sweepFlag contribute to the
3173
% automatic calculations and help determine how the arc is drawn. If
3174
% largeArcFlag is true then draw the larger of the available arcs. If
3175
% sweepFlag is true, then draw the arc matching a clock-wise rotation.
3177
% The format of the DrawPathEllipticArcAbsolute method is:
3179
% void DrawPathEllipticArcAbsolute(DrawContext context,
3180
% const double rx, const double ry,
3181
% const double x_axis_rotation,
3182
% unsigned int large_arc_flag,
3183
% unsigned int sweep_flag,
3184
% const double x, const double y)
3186
% A description of each parameter follows:
3188
% o context: drawing context
3194
% o x_axis_rotation: indicates how the ellipse as a whole is rotated
3195
% relative to the current coordinate system
3197
% o large_arc_flag: If non-zero (true) then draw the larger of the
3200
% o sweep_flag: If non-zero (true) then draw the arc matching a
3201
% clock-wise rotation
3205
static void DrawPathEllipticArc(DrawContext context, const PathMode mode,
3206
const double rx, const double ry,
3207
const double x_axis_rotation,
3208
unsigned int large_arc_flag,
3209
unsigned int sweep_flag,
3210
const double x, const double y)
3212
assert(context != (DrawContext)NULL);
3213
assert(context->signature == MagickSignature);
3215
if ((context->path_operation != PathEllipticArcOperation)
3216
|| (context->path_mode != mode))
3218
context->path_operation = PathEllipticArcOperation;
3219
context->path_mode = mode;
3220
MvgAutoWrapPrintf(context, "%c%.4g,%.4g %.4g %u %u %.4g,%.4g",
3221
mode == AbsolutePathMode ? 'A' : 'a', rx, ry, x_axis_rotation,
3222
large_arc_flag, sweep_flag, x, y);
3225
MvgAutoWrapPrintf(context, " %.4g,%.4g %.4g %u %u %.4g,%.4g", rx, ry,
3226
x_axis_rotation, large_arc_flag, sweep_flag, x, y);
3228
MagickExport void DrawPathEllipticArcAbsolute(DrawContext context,
3229
const double rx, const double ry,
3230
const double x_axis_rotation,
3231
unsigned int large_arc_flag,
3232
unsigned int sweep_flag,
3233
const double x, const double y)
3235
assert(context != (DrawContext)NULL);
3236
assert(context->signature == MagickSignature);
3238
DrawPathEllipticArc(context, AbsolutePathMode, rx, ry, x_axis_rotation,
3239
large_arc_flag, sweep_flag, x, y);
3243
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3247
% D r a w P a t h E l l i p t i c A r c R e l a t i v e %
3251
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3253
% DrawPathEllipticArcRelative() draws an elliptical arc from the current
3254
% point to (x, y) using relative coordinates. The size and orientation
3255
% of the ellipse are defined by two radii (rx, ry) and an
3256
% xAxisRotation, which indicates how the ellipse as a whole is rotated
3257
% relative to the current coordinate system. The center (cx, cy) of the
3258
% ellipse is calculated automatically to satisfy the constraints imposed
3259
% by the other parameters. largeArcFlag and sweepFlag contribute to the
3260
% automatic calculations and help determine how the arc is drawn. If
3261
% largeArcFlag is true then draw the larger of the available arcs. If
3262
% sweepFlag is true, then draw the arc matching a clock-wise rotation.
3264
% The format of the DrawPathEllipticArcRelative method is:
3266
% void DrawPathEllipticArcRelative(DrawContext context,
3267
% const double rx, const double ry,
3268
% const double x_axis_rotation,
3269
% unsigned int large_arc_flag,
3270
% unsigned int sweep_flag,
3271
% const double x, const double y)
3273
% A description of each parameter follows:
3275
% o context: drawing context
3281
% o x_axis_rotation: indicates how the ellipse as a whole is rotated
3282
% relative to the current coordinate system
3284
% o large_arc_flag: If non-zero (true) then draw the larger of the
3287
% o sweep_flag: If non-zero (true) then draw the arc matching a
3288
% clock-wise rotation
3291
MagickExport void DrawPathEllipticArcRelative(DrawContext context,
3292
const double rx, const double ry,
3293
const double x_axis_rotation,
3294
unsigned int large_arc_flag,
3295
unsigned int sweep_flag,
3296
const double x, const double y)
3298
DrawPathEllipticArc(context, RelativePathMode, rx, ry, x_axis_rotation,
3299
large_arc_flag, sweep_flag, x, y);
3303
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3307
% D r a w P a t h F i n i s h %
3311
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3313
% DrawPathFinish() terminates the current path.
3315
% The format of the DrawPathFinish method is:
3317
% void DrawPathFinish(DrawContext context)
3319
% A description of each parameter follows:
3321
% o context: drawing context
3324
MagickExport void DrawPathFinish(DrawContext context)
3326
assert(context != (DrawContext)NULL);
3327
assert(context->signature == MagickSignature);
3329
MvgPrintf(context, "'\n");
3330
context->path_operation = PathDefaultOperation;
3331
context->path_mode = DefaultPathMode;
3335
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3339
% D r a w P a t h L i n e T o A b s o l u t e %
3343
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3345
% DrawPathLineToAbsolute() draws a line path from the current point to the
3346
% given coordinate using absolute coordinates. The coordinate then becomes
3347
% the new current point.
3349
% The format of the DrawPathLineToAbsolute method is:
3351
% void DrawPathLineToAbsolute(DrawContext context,
3352
% const double x, const double y)
3354
% A description of each parameter follows:
3356
% o context: drawing context
3358
% o x: target x ordinate
3360
% o y: target y ordinate
3363
static void DrawPathLineTo(DrawContext context,
3364
const PathMode mode,
3365
const double x, const double y)
3367
assert(context != (DrawContext)NULL);
3368
assert(context->signature == MagickSignature);
3370
if ((context->path_operation != PathLineToOperation)
3371
|| (context->path_mode != mode))
3373
context->path_operation = PathLineToOperation;
3374
context->path_mode = mode;
3375
MvgAutoWrapPrintf(context, "%c%.4g,%.4g",
3376
mode == AbsolutePathMode ? 'L' : 'l', x, y);
3379
MvgAutoWrapPrintf(context, " %.4g,%.4g", x, y);
3381
MagickExport void DrawPathLineToAbsolute(DrawContext context,
3382
const double x, const double y)
3384
assert(context != (DrawContext)NULL);
3385
assert(context->signature == MagickSignature);
3387
DrawPathLineTo(context, AbsolutePathMode, x, y);
3391
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3395
% D r a w P a t h L i n e T o R e l a t i v e %
3399
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3401
% DrawPathLineToRelative() draws a line path from the current point to the
3402
% given coordinate using relative coordinates. The coordinate then becomes
3403
% the new current point.
3405
% The format of the DrawPathLineToRelative method is:
3407
% void DrawPathLineToRelative(DrawContext context,
3408
% const double x, const double y)
3410
% A description of each parameter follows:
3412
% o context: drawing context
3414
% o x: target x ordinate
3416
% o y: target y ordinate
3419
MagickExport void DrawPathLineToRelative(DrawContext context,
3420
const double x, const double y)
3422
assert(context != (DrawContext)NULL);
3423
assert(context->signature == MagickSignature);
3425
DrawPathLineTo(context, RelativePathMode, x, y);
3429
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3433
% D r a w P a t h L i n e T o H o r i z o n t a l A b s o l u t e %
3437
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3439
% DrawPathLineToHorizontalAbsolute() draws a horizontal line path from the
3440
% current point to the target point using absolute coordinates. The target
3441
% point then becomes the new current point.
3443
% The format of the DrawPathLineToHorizontalAbsolute method is:
3445
% void DrawPathLineToHorizontalAbsolute(DrawContext context,
3448
% A description of each parameter follows:
3450
% o context: drawing context
3452
% o x: target x ordinate
3456
static void DrawPathLineToHorizontal(DrawContext context,
3457
const PathMode mode, const double x)
3459
assert(context != (DrawContext)NULL);
3460
assert(context->signature == MagickSignature);
3462
if ((context->path_operation != PathLineToHorizontalOperation)
3463
|| (context->path_mode != mode))
3465
context->path_operation = PathLineToHorizontalOperation;
3466
context->path_mode = mode;
3467
MvgAutoWrapPrintf(context, "%c%.4g",
3468
mode == AbsolutePathMode ? 'H' : 'h', x);
3471
MvgAutoWrapPrintf(context, " %.4g", x);
3473
MagickExport void DrawPathLineToHorizontalAbsolute(DrawContext context,
3476
assert(context != (DrawContext)NULL);
3477
assert(context->signature == MagickSignature);
3479
DrawPathLineToHorizontal(context, AbsolutePathMode, x);
3483
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3487
% D r a w P a t h L i n e T o H o r i z o n t a l R e l a t i v e %
3491
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3493
% DrawPathLineToHorizontalRelative() draws a horizontal line path from the
3494
% current point to the target point using relative coordinates. The target
3495
% point then becomes the new current point.
3497
% The format of the DrawPathLineToHorizontalRelative method is:
3499
% void DrawPathLineToHorizontalRelative(DrawContext context, const double x)
3501
% A description of each parameter follows:
3503
% o context: drawing context
3505
% o x: target x ordinate
3508
MagickExport void DrawPathLineToHorizontalRelative(DrawContext context,
3511
DrawPathLineToHorizontal(context, RelativePathMode, x);
3515
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3519
% D r a w P a t h L i n e T o V e r t i c a l A b s o l u t e %
3523
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3525
% DrawPathLineToVerticalAbsolute() draws a vertical line path from the
3526
% current point to the target point using absolute coordinates. The target
3527
% point then becomes the new current point.
3529
% The format of the DrawPathLineToVerticalAbsolute method is:
3531
% void DrawPathLineToVerticalAbsolute(DrawContext context,
3534
% A description of each parameter follows:
3536
% o context: drawing context
3538
% o y: target y ordinate
3541
static void DrawPathLineToVertical(DrawContext context, const PathMode mode,
3544
assert(context != (DrawContext)NULL);
3545
assert(context->signature == MagickSignature);
3547
if ((context->path_operation != PathLineToVerticalOperation)
3548
|| (context->path_mode != mode))
3550
context->path_operation = PathLineToVerticalOperation;
3551
context->path_mode = mode;
3552
MvgAutoWrapPrintf(context, "%c%.4g",
3553
mode == AbsolutePathMode ? 'V' : 'v', y);
3556
MvgAutoWrapPrintf(context, " %.4g", y);
3558
MagickExport void DrawPathLineToVerticalAbsolute(DrawContext context,
3561
assert(context != (DrawContext)NULL);
3562
assert(context->signature == MagickSignature);
3564
DrawPathLineToVertical(context, AbsolutePathMode, y);
3568
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3572
% D r a w P a t h L i n e T o V e r t i c a l R e l a t i v e %
3576
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3578
% DrawPathLineToVerticalRelative() draws a vertical line path from the
3579
% current point to the target point using relative coordinates. The target
3580
% point then becomes the new current point.
3582
% The format of the DrawPathLineToVerticalRelative method is:
3584
% void DrawPathLineToVerticalRelative(DrawContext context,
3587
% A description of each parameter follows:
3589
% o context: drawing context
3591
% o y: target y ordinate
3594
MagickExport void DrawPathLineToVerticalRelative(DrawContext context,
3597
assert(context != (DrawContext)NULL);
3598
assert(context->signature == MagickSignature);
3600
DrawPathLineToVertical(context, RelativePathMode, y);
3603
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3607
% D r a w P a t h M o v e T o A b s o l u t e %
3611
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3613
% DrawPathMoveToAbsolute() starts a new sub-path at the given coordinate
3614
% using absolute coordinates. The current point then becomes the
3615
% specified coordinate.
3617
% The format of the DrawPathMoveToAbsolute method is:
3619
% void DrawPathMoveToAbsolute(DrawContext context, const double x,
3622
% A description of each parameter follows:
3624
% o context: drawing context
3626
% o x: target x ordinate
3628
% o y: target y ordinate
3631
static void DrawPathMoveTo(DrawContext context, const PathMode mode,
3632
const double x, const double y)
3634
assert(context != (DrawContext)NULL);
3635
assert(context->signature == MagickSignature);
3637
if ((context->path_operation != PathMoveToOperation)
3638
|| (context->path_mode != mode))
3640
context->path_operation = PathMoveToOperation;
3641
context->path_mode = mode;
3642
MvgAutoWrapPrintf(context, "%c%.4g,%.4g",
3643
mode == AbsolutePathMode ? 'M' : 'm', x, y);
3646
MvgAutoWrapPrintf(context, " %.4g,%.4g", x, y);
3649
MagickExport void DrawPathMoveToAbsolute(DrawContext context, const double x,
3652
assert(context != (DrawContext)NULL);
3653
assert(context->signature == MagickSignature);
3655
DrawPathMoveTo(context, AbsolutePathMode, x, y);
3659
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3663
% D r a w P a t h M o v e T o R e l a t i v e %
3667
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3669
% DrawPathMoveToRelative() starts a new sub-path at the given coordinate
3670
% using relative coordinates. The current point then becomes the
3671
% specified coordinate.
3673
% The format of the DrawPathMoveToRelative method is:
3675
% void DrawPathMoveToRelative(DrawContext context,
3676
% const double x, const double y)
3678
% A description of each parameter follows:
3680
% o context: drawing context
3682
% o x: target x ordinate
3684
% o y: target y ordinate
3687
MagickExport void DrawPathMoveToRelative(DrawContext context,
3688
const double x, const double y)
3690
assert(context != (DrawContext)NULL);
3691
assert(context->signature == MagickSignature);
3693
DrawPathMoveTo(context, RelativePathMode, x, y);
3697
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3701
% D r a w P a t h S t a r t %
3705
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3707
% DrawPathStart() declares the start of a path drawing list which is terminated
3708
% by a matching DrawPathFinish() command. All other DrawPath commands must
3709
% be enclosed between a DrawPathStart() and a DrawPathFinish() command. This
3710
% is because path drawing commands are subordinate commands and they do not
3711
% function by themselves.
3713
% The format of the DrawPathStart method is:
3715
% void DrawPathStart(DrawContext context)
3717
% A description of each parameter follows:
3719
% o context: drawing context
3722
MagickExport void DrawPathStart(DrawContext context)
3724
assert(context != (DrawContext)NULL);
3725
assert(context->signature == MagickSignature);
3727
MvgPrintf(context, "path '");
3728
context->path_operation = PathDefaultOperation;
3729
context->path_mode = DefaultPathMode;
3733
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3737
% D r a w P e e k G r a p h i c C o n t e x t %
3741
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3743
% DrawPeekGraphicContext() returns a copy of the the DrawInfo structure at
3744
% the head of the drawing context stack. The user is responsible for
3745
% deallocating the returned object using DestroyDrawInfo.
3747
% The format of the DrawPeekGraphicContext method is:
3749
% DrawInfo *DrawPeekGraphicContext(const DrawContext context)
3751
% A description of each parameter follows:
3753
% o context: drawing context
3756
MagickExport DrawInfo *DrawPeekGraphicContext(const DrawContext context)
3761
assert(context != (DrawContext)NULL);
3762
assert(context->signature == MagickSignature);
3763
draw_info=CloneDrawInfo((ImageInfo *) NULL,CurrentContext);
3764
CloneString(&draw_info->primitive,context->mvg);
3765
CurrentContext->primitive=context->mvg;
3770
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3774
% D r a w P o i n t %
3778
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3780
% DrawPoint() draws a point using the current stroke color and stroke
3781
% thickness at the specified coordinates.
3783
% The format of the DrawPoint method is:
3785
% void DrawPoint(DrawContext context, const double x, const double y)
3787
% A description of each parameter follows:
3789
% o context: drawing context
3791
% o x: target x coordinate
3793
% o y: target y coordinate
3796
MagickExport void DrawPoint(DrawContext context,
3797
const double x, const double y)
3799
assert(context != (DrawContext)NULL);
3800
assert(context->signature == MagickSignature);
3802
MvgPrintf(context, "point %.4g,%.4g\n", x, y);
3806
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3810
% D r a w P o l y g o n %
3814
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3816
% DrawPolygon() draws a polygon using the current stroke, stroke width, and
3817
% fill color or texture, using the specified array of coordinates.
3819
% The format of the DrawPolygon method is:
3821
% void DrawPolygon(DrawContext context,
3822
% const unsigned long num_coords,
3823
% const PointInfo * coordinates)
3825
% A description of each parameter follows:
3827
% o context: drawing context
3829
% o num_coords: number of coordinates
3831
% o coordinates: coordinate array
3834
MagickExport void DrawPolygon(DrawContext context,
3835
const unsigned long num_coords,
3836
const PointInfo * coordinates)
3838
assert(context != (DrawContext)NULL);
3839
assert(context->signature == MagickSignature);
3841
MvgAppendPointsCommand(context,"polygon",num_coords,coordinates);
3845
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3849
% D r a w P o l y l i n e %
3853
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3855
% DrawPolyline() draws a polyline using the current stroke, stroke width, and
3856
% fill color or texture, using the specified array of coordinates.
3858
% The format of the DrawPolyline method is:
3860
% void DrawPolyline(DrawContext context,
3861
% const unsigned long num_coords,
3862
% const PointInfo * coordinates)
3864
% A description of each parameter follows:
3866
% o context: drawing context
3868
% o num_coords: number of coordinates
3870
% o coordinates: coordinate array
3873
MagickExport void DrawPolyline(DrawContext context,
3874
const unsigned long num_coords,
3875
const PointInfo * coordinates)
3877
assert(context != (DrawContext)NULL);
3878
assert(context->signature == MagickSignature);
3880
MvgAppendPointsCommand(context,"polyline",num_coords,coordinates);
3884
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3888
% D r a w P o p C l i p P a t h %
3892
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3894
% DrawPopClipPath() terminates a clip path definition.
3896
% The format of the DrawPopClipPath method is:
3898
% void DrawPopClipPath(DrawContext context)
3900
% A description of each parameter follows:
3902
% o context: drawing context
3905
MagickExport void DrawPopClipPath(DrawContext context)
3907
assert(context != (DrawContext)NULL);
3908
assert(context->signature == MagickSignature);
3910
if(context->indent_depth > 0)
3911
context->indent_depth--;
3912
MvgPrintf(context, "pop clip-path\n");
3916
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3920
% D r a w P o p D e f s %
3924
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3926
% DrawPopDefs() terminates a definition list
3928
% The format of the DrawPopDefs method is:
3930
% void DrawPopDefs(DrawContext context)
3932
% A description of each parameter follows:
3934
% o context: drawing context
3937
MagickExport void DrawPopDefs(DrawContext context)
3939
assert(context != (DrawContext)NULL);
3940
assert(context->signature == MagickSignature);
3942
if(context->indent_depth > 0)
3943
context->indent_depth--;
3944
MvgPrintf(context, "pop defs\n");
3948
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3952
% D r a w P o p G r a p h i c C o n t e x t %
3956
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3958
% DrawPopGraphicContext() destroys the current context returning to the
3959
% previously pushed context. Multiple contexts may exist. It is an error
3960
% to attempt to pop more contexts than have been pushed, and it is proper
3961
% form to pop all contexts which have been pushed.
3963
% The format of the DrawPopGraphicContext method is:
3965
% void DrawPopGraphicContext(DrawContext context)
3967
% A description of each parameter follows:
3969
% o context: drawing context
3972
MagickExport void DrawPopGraphicContext(DrawContext context)
3974
assert(context != (DrawContext)NULL);
3975
assert(context->signature == MagickSignature);
3977
if(context->index > 0)
3979
/* Destroy clip path if not same in preceding context */
3980
#if DRAW_BINARY_IMPLEMENTATION
3981
if (CurrentContext->clip_path != (char *) NULL)
3982
if (LocaleCompare(CurrentContext->clip_path,
3983
context->graphic_context[context->index-1]->clip_path) != 0)
3984
(void) SetImageClipMask(context->image,(Image *) NULL);
3987
DestroyDrawInfo(CurrentContext);
3988
CurrentContext=(DrawInfo*)NULL;
3991
if(context->indent_depth > 0)
3992
context->indent_depth--;
3993
MvgPrintf(context, "pop graphic-context\n");
3997
ThrowDrawException(DrawError,UnbalancedGraphicContextPushPop,NULL)
4002
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4006
% D r a w P o p P a t t e r n %
4010
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4012
% DrawPopPattern() terminates a pattern definition.
4014
% The format of the DrawPopPattern method is:
4016
% void DrawPopPattern(DrawContext context)
4018
% A description of each parameter follows:
4020
% o context: drawing context
4023
MagickExport void DrawPopPattern(DrawContext context)
4026
geometry[MaxTextExtent],
4029
assert(context != (DrawContext)NULL);
4030
assert(context->signature == MagickSignature);
4032
if( context->pattern_id == NULL )
4033
ThrowDrawException(DrawWarning,NotCurrentlyPushingPatternDefinition,NULL);
4035
FormatString(key,"[%.1024s]",context->pattern_id);
4037
(void) SetImageAttribute(context->image,key,context->mvg+context->pattern_offset);
4038
FormatString(geometry,"%lux%lu%+ld%+ld",
4039
context->pattern_bounds.width,context->pattern_bounds.height,
4040
context->pattern_bounds.x,context->pattern_bounds.y);
4041
(void) SetImageAttribute(context->image,key,geometry);
4043
MagickFreeMemory(context->pattern_id);
4044
context->pattern_offset = 0;
4046
context->pattern_bounds.x = 0;
4047
context->pattern_bounds.y = 0;
4048
context->pattern_bounds.width = 0;
4049
context->pattern_bounds.height = 0;
4051
context->filter_off = False;
4053
if(context->indent_depth > 0)
4054
context->indent_depth--;
4055
MvgPrintf(context, "pop pattern\n");
4059
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4063
% D r a w P u s h C l i p P a t h %
4067
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4069
% DrawPushClipPath() starts a clip path definition which is comprized of
4070
% any number of drawing commands and terminated by a DrawPopClipPath()
4073
% The format of the DrawPushClipPath method is:
4075
% void DrawPushClipPath(DrawContext context, const char *clip_path_id)
4077
% A description of each parameter follows:
4079
% o context: drawing context
4081
% o clip_path_id: string identifier to associate with the clip path for
4085
MagickExport void DrawPushClipPath(DrawContext context,
4086
const char *clip_path_id)
4088
assert(context != (DrawContext)NULL);
4089
assert(context->signature == MagickSignature);
4090
assert(clip_path_id != (const char *) NULL);
4092
MvgPrintf(context, "push clip-path %s\n", clip_path_id);
4093
context->indent_depth++;
4097
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4101
% D r a w P u s h D e f s %
4105
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4107
% DrawPushDefs() indicates that commands up to a terminating DrawPopDefs()
4108
% command create named elements (e.g. clip-paths, textures, etc.) which
4109
% may safely be processed earlier for the sake of efficiency.
4111
% The format of the DrawPushDefs method is:
4113
% void DrawPushDefs(DrawContext context)
4115
% A description of each parameter follows:
4117
% o context: drawing context
4120
MagickExport void DrawPushDefs(DrawContext context)
4122
assert(context != (DrawContext)NULL);
4123
assert(context->signature == MagickSignature);
4125
MvgPrintf(context, "push defs\n");
4126
context->indent_depth++;
4130
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4134
% D r a w P u s h G r a p h i c C o n t e x t %
4138
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4140
% DrawPushGraphicContext() clones the current drawing context to create a
4141
% new drawing context. The original drawing context(s) may be returned to
4142
% by invoking DrawPopGraphicContext(). The contexts are stored on a context
4143
% stack. For every Pop there must have already been an equivalent Push.
4145
% The format of the DrawPushGraphicContext method is:
4147
% void DrawPushGraphicContext(DrawContext context)
4149
% A description of each parameter follows:
4151
% o context: drawing context
4154
MagickExport void DrawPushGraphicContext(DrawContext context)
4156
assert(context != (DrawContext)NULL);
4157
assert(context->signature == MagickSignature);
4160
MagickReallocMemory(context->graphic_context,
4161
(context->index+1)*sizeof(DrawInfo *));
4162
if (context->graphic_context == (DrawInfo **) NULL)
4164
ThrowDrawException3(ResourceLimitError,MemoryAllocationFailed,
4165
UnableToDrawOnImage)
4168
CloneDrawInfo((ImageInfo *) NULL,context->graphic_context[context->index-1]);
4169
MvgPrintf(context, "push graphic-context\n");
4170
context->indent_depth++;
4174
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4178
% D r a w P u s h P a t t e r n %
4182
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4184
% DrawPushPattern() indicates that subsequent commands up to a
4185
% DrawPopPattern() command comprise the definition of a named pattern.
4186
% The pattern space is assigned top left corner coordinates, a width
4187
% and height, and becomes its own drawing space. Anything which can
4188
% be drawn may be used in a pattern definition.
4189
% Named patterns may be used as stroke or brush definitions.
4191
% The format of the DrawPushPattern method is:
4193
% void DrawPushPattern(DrawContext context,
4194
% const char *pattern_id,
4195
% const double x, const double y,
4196
% const double width, const double height)
4198
% A description of each parameter follows:
4200
% o context: drawing context
4202
% o pattern_id: pattern identification for later reference
4204
% o x: x ordinate of top left corner
4206
% o y: y ordinate of top left corner
4208
% o width: width of pattern space
4210
% o height: height of pattern space
4213
MagickExport void DrawPushPattern(DrawContext context,
4214
const char *pattern_id,
4215
const double x, const double y,
4216
const double width, const double height)
4218
assert(context != (DrawContext)NULL);
4219
assert(context->signature == MagickSignature);
4220
assert(pattern_id != (const char *) NULL);
4222
if( context->pattern_id != NULL )
4223
ThrowDrawException(DrawError,AlreadyPushingPatternDefinition,
4224
context->pattern_id);
4226
context->filter_off = True;
4228
MvgPrintf(context, "push pattern %s %.4g,%.4g %.4g,%.4g\n",
4229
pattern_id, x, y, width, height);
4230
context->indent_depth++;
4232
/* Record current pattern ID, bounds, and start position in MVG */
4233
context->pattern_id = AllocateString(pattern_id);
4234
context->pattern_bounds.x = (long) ceil(x-0.5);
4235
context->pattern_bounds.y = (long) ceil(y-0.5);
4236
context->pattern_bounds.width = (unsigned long) floor(width+0.5);
4237
context->pattern_bounds.height = (unsigned long) floor(height+0.5);
4238
context->pattern_offset = context->mvg_length;
4242
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4246
% D r a w R e c t a n g l e %
4250
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4252
% DrawRectangle() draws a rectangle given two coordinates and using
4253
% the current stroke, stroke width, and fill settings.
4255
% The format of the DrawRectangle method is:
4257
% void DrawRectangle(DrawContext context,
4258
% const double x1, const double y1,
4259
% const double x2, const double y2)
4261
% A description of each parameter follows:
4263
% o x1: x ordinate of first coordinate
4265
% o y1: y ordinate of first coordinate
4267
% o x2: x ordinate of second coordinate
4269
% o y2: y ordinate of second coordinate
4272
MagickExport void DrawRectangle(DrawContext context,
4273
const double x1, const double y1,
4274
const double x2, const double y2)
4276
assert(context != (DrawContext)NULL);
4277
assert(context->signature == MagickSignature);
4278
MvgPrintf(context, "rectangle %.4g,%.4g %.4g,%.4g\n", x1, y1, x2, y2);
4282
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4286
% D r a w R e n d e r %
4290
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4292
% DrawRender() renders all preceding drawing commands onto the image.
4294
% The format of the DrawRender method is:
4296
% int DrawRender(const DrawContext context)
4298
% A description of each parameter follows:
4300
% o context: drawing context
4303
MagickExport int DrawRender(const DrawContext context)
4305
assert(context != (DrawContext)NULL);
4306
assert(context->signature == MagickSignature);
4308
CurrentContext->primitive = context->mvg;
4309
(void) LogMagickEvent(RenderEvent,GetMagickModule(),"MVG:\n'%s'\n",context->mvg);
4310
DrawImage(context->image, CurrentContext);
4311
CurrentContext->primitive = (char *) NULL;
4317
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4321
% D r a w R o t a t e %
4325
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4327
% DrawRotate() applies the specified rotation to the current coordinate
4330
% The format of the DrawRotate method is:
4332
% void DrawRotate(DrawContext context, const double degrees)
4334
% A description of each parameter follows:
4336
% o context: drawing context
4338
% o degrees: degrees of rotation
4341
MagickExport void DrawRotate(DrawContext context, const double degrees)
4346
assert(context != (DrawContext)NULL);
4347
assert(context->signature == MagickSignature);
4349
IdentityAffine(&affine);
4350
affine.sx=cos(DegreesToRadians(fmod(degrees,360.0)));
4351
affine.rx=sin(DegreesToRadians(fmod(degrees,360.0)));
4352
affine.ry=(-sin(DegreesToRadians(fmod(degrees,360.0))));
4353
affine.sy=cos(DegreesToRadians(fmod(degrees,360.0)));
4354
AdjustAffine( context, &affine );
4356
MvgPrintf(context, "rotate %.4g\n", degrees);
4360
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4364
% D r a w R o u n d R e c t a n g l e %
4368
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4370
% DrawRoundRectangle() draws a rounted rectangle given two coordinates,
4371
% x & y corner radiuses and using the current stroke, stroke width,
4372
% and fill settings.
4374
% The format of the DrawRoundRectangle method is:
4376
% void DrawRoundRectangle(DrawContext context,
4377
% double x1, double y1,
4378
% double x2, double y2,
4379
% double rx, double ry)
4381
% A description of each parameter follows:
4383
% o context: drawing context
4385
% o x1: x ordinate of first coordinate
4387
% o y1: y ordinate of first coordinate
4389
% o x2: x ordinate of second coordinate
4391
% o y2: y ordinate of second coordinate
4393
% o rx: radius of corner in horizontal direction
4395
% o ry: radius of corner in vertical direction
4398
MagickExport void DrawRoundRectangle(DrawContext context,
4399
double x1, double y1,
4400
double x2, double y2,
4401
double rx, double ry)
4403
assert(context != (DrawContext)NULL);
4404
assert(context->signature == MagickSignature);
4406
MvgPrintf(context, "roundrectangle %.4g,%.4g %.4g,%.4g %.4g,%.4g\n",
4407
x1, y1, x2, y2, rx, ry);
4411
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4415
% D r a w S c a l e %
4419
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4421
% DrawScale() adjusts the scaling factor to apply in the horizontal and
4422
% vertical directions to the current coordinate space.
4424
% The format of the DrawScale method is:
4426
% void DrawScale(DrawContext context, const double x, const double y)
4428
% A description of each parameter follows:
4430
% o context: drawing context
4432
% o x: horizontal scale factor
4434
% o y: vertical scale factor
4437
MagickExport void DrawScale(DrawContext context,
4438
const double x, const double y)
4443
assert(context != (DrawContext)NULL);
4444
assert(context->signature == MagickSignature);
4446
IdentityAffine(&affine);
4449
AdjustAffine( context, &affine );
4451
MvgPrintf(context, "scale %.4g,%.4g\n", x, y);
4455
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4459
% D r a w S k e w X %
4463
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4465
% DrawSkewX() skews the current coordinate system in the horizontal
4468
% The format of the DrawSkewX method is:
4470
% void DrawSkewX(DrawContext context, const double degrees)
4472
% A description of each parameter follows:
4474
% o context: drawing context
4476
% o degrees: number of degrees to skew the coordinates
4479
MagickExport void DrawSkewX(DrawContext context, const double degrees)
4484
assert(context != (DrawContext)NULL);
4485
assert(context->signature == MagickSignature);
4487
IdentityAffine(&affine);
4488
affine.ry=tan(DegreesToRadians(fmod(degrees,360.0)));
4489
AdjustAffine(context,&affine);
4491
MvgPrintf(context, "skewX %.4g\n", degrees);
4495
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4499
% D r a w S k e w Y %
4503
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4505
% DrawSkewY() skews the current coordinate system in the vertical
4508
% The format of the DrawSkewY method is:
4510
% void DrawSkewY(DrawContext context, const double degrees)
4512
% A description of each parameter follows:
4514
% o context: drawing context
4516
% o degrees: number of degrees to skew the coordinates
4519
MagickExport void DrawSkewY(DrawContext context, const double degrees)
4524
assert(context != (DrawContext)NULL);
4525
assert(context->signature == MagickSignature);
4527
IdentityAffine(&affine);
4528
affine.rx=tan(DegreesToRadians(fmod(degrees,360.0)));
4529
DrawAffine(context,&affine);
4531
MvgPrintf(context, "skewY %.4g\n", degrees);
4537
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4541
% D r a w S e t S t o p C o l o r %
4545
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4547
% DrawSetStopColor() sets the stop color and offset for gradients
4549
% The format of the DrawSetStopColor method is:
4551
% void DrawSetStopColor(DrawContext context,
4552
% const PixelPacket * stop_color,
4553
% const double offset)
4555
% A description of each parameter follows:
4557
% o context: drawing context
4564
/* This is gradient stuff so it shouldn't be supported yet */
4565
MagickExport void DrawSetStopColor(DrawContext context,
4566
const PixelPacket * stop_color,
4567
const double offset)
4569
assert(context != (DrawContext)NULL);
4570
assert(context->signature == MagickSignature);
4571
assert(stop_color != (const PixelPacket *) NULL);
4574
MvgPrintf(context, "stop-color ");
4575
MvgAppendColor(context, stop_color);
4576
MvgPrintf(context, "\n");
4581
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4585
% D r a w G e t S t r o k e C o l o r %
4589
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4591
% DrawGetStrokeColor() returns the color used for stroking object outlines.
4593
% The format of the DrawGetStrokeColor method is:
4595
% PixelPacket DrawGetStrokeColor(DrawContext context)
4597
% A description of each parameter follows:
4599
% o context: drawing context
4602
MagickExport PixelPacket DrawGetStrokeColor(DrawContext context)
4604
assert(context != (DrawContext)NULL);
4605
assert(context->signature == MagickSignature);
4607
return CurrentContext->stroke;
4611
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4615
% D r a w S e t S t r o k e C o l o r %
4619
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4621
% DrawSetStrokeColor() sets the color used for stroking object outlines.
4623
% The format of the DrawSetStrokeColor method is:
4625
% void DrawSetStrokeColor(DrawContext context,
4626
% const PixelPacket * stroke_color)
4628
% A description of each parameter follows:
4630
% o context: drawing context
4632
% o stroke_color: stroke color
4635
MagickExport void DrawSetStrokeColor(DrawContext context,
4636
const PixelPacket * stroke_color)
4642
assert(context != (DrawContext)NULL);
4643
assert(context->signature == MagickSignature);
4644
assert(stroke_color != (const PixelPacket *) NULL);
4646
new_stroke = *stroke_color;
4648
/* Inherit base opacity */
4649
if(new_stroke.opacity == OpaqueOpacity)
4650
new_stroke.opacity = CurrentContext->opacity;
4652
current_stroke = &CurrentContext->stroke;
4653
if( context->filter_off || !(PixelPacketMatch(current_stroke,&new_stroke)) )
4655
CurrentContext->stroke = new_stroke;
4657
MvgPrintf(context, "stroke '");
4658
MvgAppendColor(context, stroke_color);
4659
MvgPrintf(context, "'\n");
4664
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4668
% D r a w S e t S t r o k e C o l o r S t r i n g %
4672
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4674
% DrawSetStrokeColorString() sets the color used for stroking object outlines.
4676
% The format of the DrawSetStrokeColorString method is:
4678
% void DrawSetStrokeColorString(DrawContext context,
4679
% const char* stroke_color)
4681
% A description of each parameter follows:
4683
% o context: drawing context
4685
% o stroke_color: stroke color
4688
MagickExport void DrawSetStrokeColorString(DrawContext context,
4689
const char* stroke_color)
4694
if(QueryColorDatabase(stroke_color,&pixel_packet,&context->image->exception))
4695
DrawSetStrokeColor(context,&pixel_packet);
4699
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4703
% D r a w S e t S t r o k e P a t t e r n U R L %
4707
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4709
% DrawSetStrokePatternURL() sets the pattern used for stroking object outlines.
4711
% The format of the DrawSetStrokePatternURL method is:
4713
% void DrawSetStrokePatternURL(DrawContext context, const char* stroke_url)
4715
% A description of each parameter follows:
4717
% o context: drawing context
4719
% o stroke_url: URL specifying pattern ID (e.g. "#pattern_id")
4722
MagickExport void DrawSetStrokePatternURL(DrawContext context,
4723
const char* stroke_url)
4726
pattern[MaxTextExtent];
4728
assert(context != (DrawContext)NULL);
4729
assert(context->signature == MagickSignature);
4730
assert(stroke_url != NULL);
4732
if(stroke_url[0] != '#')
4733
ThrowDrawException(DrawWarning, NotARelativeURL, stroke_url);
4735
FormatString(pattern,"[%.1024s]",stroke_url+1);
4737
if (GetImageAttribute(context->image,pattern) == (ImageAttribute *) NULL)
4739
ThrowDrawException(DrawWarning, URLNotFound, stroke_url)
4744
pattern_spec[MaxTextExtent];
4746
FormatString(pattern_spec,"url(%.1024s)",stroke_url);
4747
#if DRAW_BINARY_IMPLEMENTATION
4748
DrawPatternPath(context->image,CurrentContext,pattern_spec,&CurrentContext->stroke_pattern);
4750
/* Inherit base opacity */
4751
if (CurrentContext->stroke.opacity == OpaqueOpacity)
4752
CurrentContext->stroke.opacity=CurrentContext->opacity;
4754
MvgPrintf(context, "stroke %s\n",pattern_spec);
4759
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4763
% D r a w G e t S t r o k e A n t i a l i a s %
4767
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4769
% DrawGetStrokeAntialias() returns the current stroke antialias setting.
4770
% Stroked outlines are antialiased by default. When antialiasing is disabled
4771
% stroked pixels are thresholded to determine if the stroke color or
4772
% underlying canvas color should be used.
4774
% The format of the DrawGetStrokeAntialias method is:
4776
% unsigned int DrawGetStrokeAntialias(DrawContext context)
4778
% A description of each parameter follows:
4780
% o context: drawing context
4782
MagickExport unsigned int DrawGetStrokeAntialias(DrawContext context)
4784
assert(context != (DrawContext)NULL);
4785
assert(context->signature == MagickSignature);
4787
return CurrentContext->stroke_antialias;
4791
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4795
% D r a w S e t S t r o k e A n t i a l i a s %
4799
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4801
% DrawSetStrokeAntialias() controls whether stroked outlines are antialiased.
4802
% Stroked outlines are antialiased by default. When antialiasing is disabled
4803
% stroked pixels are thresholded to determine if the stroke color or
4804
% underlying canvas color should be used.
4806
% The format of the DrawSetStrokeAntialias method is:
4808
% void DrawSetStrokeAntialias(DrawContext context,
4809
% const unsigned int stroke_antialias)
4811
% A description of each parameter follows:
4813
% o context: drawing context
4815
% o stroke_antialias: set to false (zero) to disable antialiasing
4818
MagickExport void DrawSetStrokeAntialias(DrawContext context,
4819
const unsigned int stroke_antialias)
4821
assert(context != (DrawContext)NULL);
4822
assert(context->signature == MagickSignature);
4824
if(context->filter_off || (CurrentContext->stroke_antialias != stroke_antialias))
4826
CurrentContext->stroke_antialias = stroke_antialias;
4828
MvgPrintf(context, "stroke-antialias %i\n", stroke_antialias ? 1 : 0);
4833
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4837
% D r a w G e t S t r o k e D a s h A r r a y %
4841
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4843
% DrawGetStrokeDashArray() returns an array representing the pattern of
4844
% dashes and gaps used to stroke paths (see DrawSetStrokeDashArray). The
4845
% array must be freed once it is no longer required by the user.
4847
% The format of the DrawGetStrokeDashArray method is:
4849
% double *DrawGetStrokeDashArray(DrawContext context,unsigned long *num_elems)
4851
% A description of each parameter follows:
4853
% o context: drawing context
4855
% o num_elems: address to place number of elements in dash array
4858
MagickExport double *DrawGetStrokeDashArray(DrawContext context,
4859
unsigned long *num_elems)
4861
register const double
4874
assert(context != (DrawContext)NULL);
4875
assert(context->signature == MagickSignature);
4876
assert(num_elems != (unsigned long *)NULL);
4878
p = CurrentContext->dash_pattern;
4879
if( p != (const double *) NULL )
4884
dasharray = (double *)NULL;
4887
dasharray = MagickAllocateMemory(double *, n*sizeof(double));
4888
p = CurrentContext->dash_pattern;
4898
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4902
% D r a w S e t S t r o k e D a s h A r r a y %
4906
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4908
% DrawSetStrokeDashArray() specifies the pattern of dashes and gaps used to
4909
% stroke paths. The strokeDashArray represents an array of numbers that
4910
% specify the lengths of alternating dashes and gaps in pixels. If an odd
4911
% number of values is provided, then the list of values is repeated to yield
4912
% an even number of values. To remove an existing dash array, pass a zero
4913
% num_elems argument and null dasharray.
4914
% A typical strokeDashArray_ array might contain the members 5 3 2.
4916
% The format of the DrawSetStrokeDashArray method is:
4918
% void DrawSetStrokeDashArray(DrawContext context,
4919
% const unsigned long num_elems,
4920
% const double *dasharray)
4922
% A description of each parameter follows:
4924
% o context: drawing context
4926
% o num_elems: number of elements in dash array
4928
% o dasharray: dash array values
4931
MagickExport void DrawSetStrokeDashArray(DrawContext context,
4932
const unsigned long num_elems,
4933
const double *dasharray)
4935
register const double
4947
assert(context != (DrawContext)NULL);
4948
assert(context->signature == MagickSignature);
4950
q = CurrentContext->dash_pattern;
4951
if( q != (const double *) NULL )
4955
if( (n_old == 0) && (n_new == 0) )
4959
else if( n_old != n_new )
4963
else if((CurrentContext->dash_pattern != (double*)NULL)
4964
&& (dasharray != (double*)NULL))
4967
q = CurrentContext->dash_pattern;
4971
if(AbsoluteValue(*p - *q) > MagickEpsilon)
4981
if( context->filter_off || updated )
4983
if(CurrentContext->dash_pattern != (double*)NULL)
4984
MagickFreeMemory(CurrentContext->dash_pattern);
4988
CurrentContext->dash_pattern = MagickAllocateMemory(double *,
4989
(n_new+1)*sizeof(double));
4990
if(CurrentContext->dash_pattern)
4992
q=CurrentContext->dash_pattern;
5000
ThrowDrawException3(ResourceLimitError,MemoryAllocationFailed,
5001
UnableToDrawOnImage)
5005
MvgPrintf(context, "stroke-dasharray ");
5007
MvgPrintf(context, "none");
5012
MvgPrintf(context, "%.4g", *p++);
5014
MvgPrintf(context, ",%.4g", *p++);
5016
MvgPrintf(context, "0 \n");
5021
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5025
% D r a w G e t S t r o k e D a s h O f f s e t %
5029
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5031
% DrawGetStrokeDashOffset() returns the offset into the dash pattern to
5034
% The format of the DrawGetStrokeDashOffset method is:
5036
% double DrawGetStrokeDashOffset(DrawContext context)
5038
% A description of each parameter follows:
5040
% o context: drawing context
5043
MagickExport double DrawGetStrokeDashOffset(DrawContext context)
5045
assert(context != (DrawContext)NULL);
5046
assert(context->signature == MagickSignature);
5048
return CurrentContext->dash_offset;
5052
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5056
% D r a w S e t S t r o k e D a s h O f f s e t %
5060
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5062
% DrawSetStrokeDashOffset() specifies the offset into the dash pattern to
5065
% The format of the DrawSetStrokeDashOffset method is:
5067
% void DrawSetStrokeDashOffset(DrawContext context,
5068
% const double dash_offset)
5070
% A description of each parameter follows:
5072
% o context: drawing context
5074
% o dash_offset: dash offset
5077
MagickExport void DrawSetStrokeDashOffset(DrawContext context,
5078
const double dash_offset)
5080
assert(context != (DrawContext)NULL);
5081
assert(context->signature == MagickSignature);
5083
if(context->filter_off ||
5084
(AbsoluteValue(CurrentContext->dash_offset-dash_offset) > MagickEpsilon))
5086
CurrentContext->dash_offset = dash_offset;
5088
MvgPrintf(context, "stroke-dashoffset %.4g\n", dash_offset);
5093
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5097
% D r a w G e t S t r o k e L i n e C a p %
5101
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5103
% DrawGetStrokeLineCap() returns the shape to be used at the end of
5104
% open subpaths when they are stroked. Values of LineCap are
5105
% UndefinedCap, ButtCap, RoundCap, and SquareCap.
5107
% The format of the DrawGetStrokeLineCap method is:
5109
% LineCap DrawGetStrokeLineCap(DrawContext context)
5111
% A description of each parameter follows:
5113
% o context: drawing context
5116
MagickExport LineCap DrawGetStrokeLineCap(DrawContext context)
5118
assert(context != (DrawContext)NULL);
5119
assert(context->signature == MagickSignature);
5121
return CurrentContext->linecap;
5125
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5129
% D r a w S e t S t r o k e L i n e C a p %
5133
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5135
% DrawSetStrokeLineCap() specifies the shape to be used at the end of
5136
% open subpaths when they are stroked. Values of LineCap are
5137
% UndefinedCap, ButtCap, RoundCap, and SquareCap.
5139
% The format of the DrawSetStrokeLineCap method is:
5141
% void DrawSetStrokeLineCap(DrawContext context,
5142
% const LineCap linecap)
5144
% A description of each parameter follows:
5146
% o context: drawing context
5148
% o linecap: linecap style
5151
MagickExport void DrawSetStrokeLineCap(DrawContext context,
5152
const LineCap linecap)
5154
assert(context != (DrawContext)NULL);
5155
assert(context->signature == MagickSignature);
5157
if(context->filter_off || (CurrentContext->linecap != linecap))
5162
CurrentContext->linecap = linecap;
5180
MvgPrintf(context, "stroke-linecap %s\n", p);
5185
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5189
% D r a w G e t S t r o k e L i n e J o i n %
5193
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5195
% DrawGetStrokeLineJoin() returns the shape to be used at the
5196
% corners of paths (or other vector shapes) when they are
5197
% stroked. Values of LineJoin are UndefinedJoin, MiterJoin, RoundJoin,
5200
% The format of the DrawGetStrokeLineJoin method is:
5202
% LineJoin DrawGetStrokeLineJoin(DrawContext context)
5204
% A description of each parameter follows:
5206
% o context: drawing context
5209
MagickExport LineJoin DrawGetStrokeLineJoin(DrawContext context)
5211
assert(context != (DrawContext)NULL);
5212
assert(context->signature == MagickSignature);
5214
return CurrentContext->linejoin;
5218
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5222
% D r a w S e t S t r o k e L i n e J o i n %
5226
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5228
% DrawSetStrokeLineJoin() specifies the shape to be used at the
5229
% corners of paths (or other vector shapes) when they are
5230
% stroked. Values of LineJoin are UndefinedJoin, MiterJoin, RoundJoin,
5233
% The format of the DrawSetStrokeLineJoin method is:
5235
% void DrawSetStrokeLineJoin(DrawContext context, const LineJoin linejoin)
5237
% A description of each parameter follows:
5239
% o context: drawing context
5241
% o linejoin: line join style
5244
MagickExport void DrawSetStrokeLineJoin(DrawContext context,
5245
const LineJoin linejoin)
5247
assert(context != (DrawContext)NULL);
5248
assert(context->signature == MagickSignature);
5250
if(context->filter_off || (CurrentContext->linejoin != linejoin))
5255
CurrentContext->linejoin = linejoin;
5273
MvgPrintf(context, "stroke-linejoin %s\n", p);
5278
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5282
% D r a w G e t S t r o k e M i t e r L i m i t %
5286
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5288
% DrawGetStrokeMiterLimit() returns the miter limit. When two line
5289
% segments meet at a sharp angle and miter joins have been specified for
5290
% 'lineJoin', it is possible for the miter to extend far beyond the
5291
% thickness of the line stroking the path. The miterLimit' imposes a
5292
% limit on the ratio of the miter length to the 'lineWidth'.
5294
% The format of the DrawGetStrokeMiterLimit method is:
5296
% unsigned long DrawGetStrokeMiterLimit(DrawContext context)
5298
% A description of each parameter follows:
5300
% o context: drawing context
5303
MagickExport unsigned long DrawGetStrokeMiterLimit(DrawContext context)
5305
assert(context != (DrawContext)NULL);
5306
assert(context->signature == MagickSignature);
5308
return CurrentContext->miterlimit;
5312
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5316
% D r a w S e t S t r o k e M i t e r L i m i t %
5320
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5322
% DrawSetStrokeMiterLimit() specifies the miter limit. When two line
5323
% segments meet at a sharp angle and miter joins have been specified for
5324
% 'lineJoin', it is possible for the miter to extend far beyond the
5325
% thickness of the line stroking the path. The miterLimit' imposes a
5326
% limit on the ratio of the miter length to the 'lineWidth'.
5328
% The format of the DrawSetStrokeMiterLimit method is:
5330
% void DrawSetStrokeMiterLimit(DrawContext context,
5331
% const unsigned long miterlimit)
5333
% A description of each parameter follows:
5335
% o context: drawing context
5337
% o miterlimit: miter limit
5340
MagickExport void DrawSetStrokeMiterLimit(DrawContext context,
5341
const unsigned long miterlimit)
5343
assert(context != (DrawContext)NULL);
5344
assert(context->signature == MagickSignature);
5346
if(CurrentContext->miterlimit != miterlimit)
5348
CurrentContext->miterlimit = miterlimit;
5350
MvgPrintf(context, "stroke-miterlimit %lu\n", miterlimit);
5355
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5359
% D r a w G e t S t r o k e O p a c i t y %
5363
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5365
% DrawGetStrokeOpacity() returns the opacity of stroked object outlines.
5367
% The format of the DrawGetStrokeOpacity method is:
5369
% double DrawGetStrokeOpacity(DrawContext context)
5371
% A description of each parameter follows:
5373
% o context: drawing context
5375
MagickExport double DrawGetStrokeOpacity(DrawContext context)
5377
assert(context != (DrawContext)NULL);
5378
assert(context->signature == MagickSignature);
5380
return (((double)(MaxRGB-CurrentContext->stroke.opacity))/MaxRGB);
5384
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5388
% D r a w S e t S t r o k e O p a c i t y %
5392
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5394
% DrawSetStrokeOpacity() specifies the opacity of stroked object outlines.
5396
% The format of the DrawSetStrokeOpacity method is:
5398
% void DrawSetStrokeOpacity(DrawContext context,
5399
% const double stroke_opacity)
5401
% A description of each parameter follows:
5403
% o context: drawing context
5405
% o stroke_opacity: stroke opacity. The value 1.0 is opaque.
5408
MagickExport void DrawSetStrokeOpacity(DrawContext context,
5409
const double stroke_opacity)
5417
assert(context != (DrawContext)NULL);
5418
assert(context->signature == MagickSignature);
5420
validated_opacity=(stroke_opacity < 0.0 ? 0.0 : (stroke_opacity > 1.0 ? 1.0 : stroke_opacity));
5421
quantum_opacity = (Quantum) (((double) MaxRGB*(1.0-validated_opacity))+0.5);
5423
if (context->filter_off || (CurrentContext->stroke.opacity != quantum_opacity))
5425
CurrentContext->stroke.opacity = quantum_opacity;
5426
MvgPrintf(context, "stroke-opacity %.4g\n", validated_opacity);
5431
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5435
% D r a w G e t S t r o k e W i d t h %
5439
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5441
% DrawGetStrokeWidth() returns the width of the stroke used to draw object
5444
% The format of the DrawGetStrokeWidth method is:
5446
% double DrawGetStrokeWidth(DrawContext context)
5448
% A description of each parameter follows:
5450
% o context: drawing context
5453
MagickExport double DrawGetStrokeWidth(DrawContext context)
5455
assert(context != (DrawContext)NULL);
5456
assert(context->signature == MagickSignature);
5458
return CurrentContext->stroke_width;
5462
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5466
% D r a w S e t S t r o k e W i d t h %
5470
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5472
% DrawSetStrokeWidth() sets the width of the stroke used to draw object
5475
% The format of the DrawSetStrokeWidth method is:
5477
% void DrawSetStrokeWidth(DrawContext context, const double stroke_width)
5479
% A description of each parameter follows:
5481
% o context: drawing context
5483
% o stroke_width: stroke width
5486
MagickExport void DrawSetStrokeWidth(DrawContext context,
5487
const double stroke_width)
5489
assert(context != (DrawContext)NULL);
5490
assert(context->signature == MagickSignature);
5492
if (context->filter_off ||
5493
(AbsoluteValue(CurrentContext->stroke_width-stroke_width) > MagickEpsilon))
5495
CurrentContext->stroke_width = stroke_width;
5497
MvgPrintf(context, "stroke-width %.4g\n", stroke_width);
5502
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5506
% D r a w G e t T e x t A n t i a l i a s %
5510
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5512
% DrawGetTextAntialias() returns the current text antialias setting, which
5513
% determines whether text is antialiased. Text is antialiased by default.
5515
% The format of the DrawGetTextAntialias method is:
5517
% unsigned int DrawGetTextAntialias(DrawContext context)
5519
% A description of each parameter follows:
5521
% o context: drawing context
5524
MagickExport unsigned int DrawGetTextAntialias(DrawContext context)
5526
assert(context != (DrawContext)NULL);
5527
assert(context->signature == MagickSignature);
5529
return CurrentContext->text_antialias;
5533
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5537
% D r a w S e t T e x t A n t i a l i a s %
5541
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5543
% DrawSetTextAntialias() controls whether text is antialiased. Text is
5544
% antialiased by default.
5546
% The format of the DrawSetTextAntialias method is:
5548
% void DrawSetTextAntialias(DrawContext context,
5549
% const unsigned int text_antialias)
5551
% A description of each parameter follows:
5553
% o context: drawing context
5555
% o text_antialias: antialias boolean. Set to false (0) to disable
5559
MagickExport void DrawSetTextAntialias(DrawContext context,
5560
const unsigned int text_antialias)
5562
assert(context != (DrawContext)NULL);
5563
assert(context->signature == MagickSignature);
5565
if (context->filter_off || (CurrentContext->text_antialias != text_antialias))
5567
CurrentContext->text_antialias = text_antialias;
5569
MvgPrintf(context, "text-antialias %i\n", text_antialias ? 1 : 0);
5574
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5578
% D r a w G e t T e x t D e c o r a t i o n %
5582
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5584
% DrawGetTextDecoration() returns the decoration applied when annotating with
5587
% The format of the DrawGetTextDecoration method is:
5589
% DecorationType DrawGetTextDecoration(DrawContext context)
5591
% A description of each parameter follows:
5593
% o context: drawing context
5596
MagickExport DecorationType DrawGetTextDecoration(DrawContext context)
5598
assert(context != (DrawContext)NULL);
5599
assert(context->signature == MagickSignature);
5601
return CurrentContext->decorate;
5605
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5609
% D r a w S e t T e x t D e c o r a t i o n %
5613
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5615
% DrawSetTextDecoration() specifies a decoration to be applied when
5616
% annotating with text.
5618
% The format of the DrawSetTextDecoration method is:
5620
% void DrawSetTextDecoration(DrawContext context,
5621
% const DecorationType decoration)
5623
% A description of each parameter follows:
5625
% o context: drawing context
5627
% o decoration: text decoration. One of NoDecoration, UnderlineDecoration,
5628
% OverlineDecoration, or LineThroughDecoration
5631
MagickExport void DrawSetTextDecoration(DrawContext context,
5632
const DecorationType decoration)
5637
assert(context != (DrawContext)NULL);
5638
assert(context->signature == MagickSignature);
5640
if (context->filter_off || (CurrentContext->decorate != decoration))
5642
CurrentContext->decorate = decoration;
5649
case UnderlineDecoration:
5652
case OverlineDecoration:
5655
case LineThroughDecoration:
5661
MvgPrintf(context, "decorate %s\n", p);
5666
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5670
% D r a w G e t T e x t E n c o d i n g %
5674
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5676
% DrawGetTextEncoding() returns a null-terminated string which specifies the
5677
% code set used for text annotations. The string must be freed by the user
5678
% once it is no longer required.
5680
% The format of the DrawGetTextEncoding method is:
5682
% char *DrawGetTextEncoding(DrawContext context)
5684
% A description of each parameter follows:
5686
% o context: drawing context
5689
MagickExport char *DrawGetTextEncoding(DrawContext context)
5691
assert(context != (DrawContext)NULL);
5692
assert(context->signature == MagickSignature);
5694
if (CurrentContext->encoding != (char *)NULL)
5695
return (char *) AllocateString(CurrentContext->encoding);
5697
return (char *) NULL;
5701
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5705
% D r a w S e t T e x t E n c o d i n g %
5709
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5711
% DrawSetTextEncoding() specifies specifies the code set to use for
5712
% text annotations. The only character encoding which may be specified
5713
% at this time is "UTF-8" for representing Unicode as a sequence of
5714
% bytes. Specify an empty string to set text encoding to the system's
5715
% default. Successful text annotation using Unicode may require fonts
5716
% designed to support Unicode.
5718
% The format of the DrawSetTextEncoding method is:
5720
% void DrawSetTextEncoding(DrawContext context, const char* encoding)
5722
% A description of each parameter follows:
5724
% o context: drawing context
5726
% o encoding: character string specifying text encoding
5729
MagickExport void DrawSetTextEncoding(DrawContext context, const char* encoding)
5731
assert(context != (DrawContext)NULL);
5732
assert(context->signature == MagickSignature);
5733
assert(encoding != (char *) NULL);
5735
if (context->filter_off || (CurrentContext->encoding == (char *) NULL) ||
5736
(LocaleCompare(CurrentContext->encoding,encoding) != 0))
5738
CloneString(&CurrentContext->encoding,encoding);
5740
MvgPrintf(context, "encoding '%s'\n", encoding);
5745
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5749
% D r a w G e t T e x t U n d e r C o l o r %
5753
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5755
% DrawGetTextUnderColor() returns the color of a background rectangle
5756
% to place under text annotations.
5758
% The format of the DrawGetTextUnderColor method is:
5760
% PixelPacket DrawGetTextUnderColor(DrawContext context)
5762
% A description of each parameter follows:
5764
% o context: drawing context
5767
MagickExport PixelPacket DrawGetTextUnderColor(DrawContext context)
5769
assert(context != (DrawContext)NULL);
5770
assert(context->signature == MagickSignature);
5772
return CurrentContext->undercolor;
5776
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5780
% D r a w S e t T e x t U n d e r C o l o r %
5784
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5786
% DrawSetTextUnderColor() specifies the color of a background rectangle
5787
% to place under text annotations.
5789
% The format of the DrawSetTextUnderColor method is:
5791
% void DrawSetTextUnderColor(DrawContext context,
5792
% const PixelPacket *under_color)
5794
% A description of each parameter follows:
5796
% o context: drawing context
5798
% o under_color: text under color
5801
MagickExport void DrawSetTextUnderColor(DrawContext context,
5802
const PixelPacket *under_color)
5804
assert(context != (DrawContext)NULL);
5805
assert(context->signature == MagickSignature);
5806
assert(under_color != (const PixelPacket *)NULL);
5808
if (context->filter_off || !(PixelPacketMatch(&CurrentContext->undercolor, under_color)))
5810
CurrentContext->undercolor = *under_color;
5811
MvgPrintf(context, "text-undercolor '");
5812
MvgAppendColor(context, under_color);
5813
MvgPrintf(context, "'\n");
5818
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5822
% D r a w S e t T e x t U n d e r C o l o r S t r i n g %
5826
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5828
% DrawSetTextUnderColorString() specifies the color of a background rectangle
5829
% to place under text annotations.
5831
% The format of the DrawSetTextUnderColorString method is:
5833
% void DrawSetTextUnderColorString(DrawContext context,
5834
% const char* under_color)
5836
% A description of each parameter follows:
5838
% o context: drawing context
5840
% o under_color: text under color
5843
MagickExport void DrawSetTextUnderColorString(DrawContext context,
5844
const char* under_color)
5849
if(QueryColorDatabase(under_color,&pixel_packet,&context->image->exception))
5850
DrawSetTextUnderColor(context,&pixel_packet);
5854
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5858
% D r a w T r a n s l a t e %
5862
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5864
% DrawTranslate() applies a translation to the current coordinate
5865
% system which moves the coordinate system origin to the specified
5868
% The format of the DrawTranslate method is:
5870
% void DrawTranslate(DrawContext context,
5871
% const double x, const double y)
5873
% A description of each parameter follows:
5875
% o context: drawing context
5877
% o x: new x ordinate for coordinate system origin
5879
% o y: new y ordinate for coordinate system origin
5882
MagickExport void DrawTranslate(DrawContext context,
5883
const double x, const double y)
5888
assert(context != (DrawContext)NULL);
5889
assert(context->signature == MagickSignature);
5891
IdentityAffine(&affine);
5894
AdjustAffine( context, &affine );
5896
MvgPrintf(context, "translate %.4g,%.4g\n", x, y);
5900
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5904
% D r a w S e t V i e w b o x %
5908
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5910
% DrawSetViewbox() sets the overall canvas size to be recorded with the
5911
% drawing vector data. Usually this will be specified using the same
5912
% size as the canvas image. When the vector data is saved to SVG or MVG
5913
% formats, the viewbox is use to specify the size of the canvas image that
5914
% a viewer will render the vector data on.
5916
% The format of the DrawSetViewbox method is:
5918
% void DrawSetViewbox(DrawContext context,
5919
% unsigned long x1, unsigned long y1,
5920
% unsigned long x2, unsigned long y2)
5922
% A description of each parameter follows:
5924
% o context: drawing context
5926
% o x1: left x ordinate
5928
% o y1: top y ordinate
5930
% o x2: right x ordinate
5932
% o y2: bottom y ordinate
5935
MagickExport void DrawSetViewbox(DrawContext context,
5936
unsigned long x1, unsigned long y1,
5937
unsigned long x2, unsigned long y2)
5939
assert(context != (DrawContext)NULL);
5940
assert(context->signature == MagickSignature);
5942
MvgPrintf(context, "viewbox %lu %lu %lu %lu\n", x1, y1, x2, y2);