# ImageMagick DrawInfo Structure

The DrawInfo structure is used to support annotating an image using drawing commands.

Methods Supporting DrawInfo
Method | Description
GetDrawInfo() | Allocate new structure with defaults set.
CloneDrawInfo() | Copy existing structure, allocating new structure in the process.
DestroyDrawInfo() | Deallocate structure, including any members.
DrawImage() | Render primitives to image.

The members of the DrawInfo structure are shown in the following table. The structure is initialized to reasonable defaults by first initializing the equivalent members of ImageInfo, and then initializing the entire structure using GetDrawInfo().

DrawInfo Structure Members Supporting DrawImage()
Member | Type | Description
affine | AffineInfo | Coordinate transformation (rotation, scaling, and translation).
border_color | PixelPacket | Border color
box | PixelPacket | Text solid background color.
decorate | DecorationType | Text decoration type.
density | char * | Text rendering density in DPI (effects scaling font according to pointsize). E.g. "72x72"
fill | PixelPacket | Object internal fill (within outline) color.
font | char * | Font to use when rendering text.
gravity | GravityType | Text placement preference (e.g. NorthWestGravity).
linewidth | double | Stroke (outline) drawing width in pixels.
pointsize | double | Font size (also see density).
primitive | char * | Space or new-line delimited list of text drawing primitives (e.g "text 100,100 Cockatoo"). See the table Drawing Primitives for the available drawing primitives.
stroke | PixelPacket | Object stroke (outline) color.
stroke_antialias | unsigned int | Set to True (non-zero) to obtain anti-aliased stroke rendering.
text_antialias | unsigned int | Set to True (non-zero) to obtain anti-aliased text rendering.
tile | Image * | Image texture to draw with. Use an image containing a single color (e.g. a 1x1 image) to draw in a solid color.

### Drawing Primitives

The drawing primitives shown in the following table may be supplied as a space or new-line deliminted list to the primitive member. Primitives which set drawing options effect the results from subsequent drawing operations. See the 'push graphic-context' and 'pop graphic-context' primitives for a way to control the propogation of drawing options.

Drawing Primitives
Primitive | Arguments | Purpose
affine | sx,rx,ry,sy,tx,ty | Apply coordinate transformations to support scaling (s), rotation (r), and translation (t). Angles are specified in radians. Equivalent to SVG matrix command which supplies a transformation matrix.
angle | angle | Specify object drawing angle.
arc | startX,startY endX,endY startDegrees,endDegrees | Draw an arc.
bezier | x1,y1, x2,y2, x3,y3, ..., xN,yN | Draw a bezier curve.
circle | originX,originY perimX,perimY | Draw a circle.
color | x,y (point|replace|floodfill|filltoborder|reset) | Set color in image according to specified colorization rule.
decorate | (none|underline|overline|line-through) | Specify text decoration.
ellipse | originX,originY width,height arcStart,arcEnd | Draw an ellipse.
fill | colorspec | Specifiy object filling color.
fill-opacity | opacity | Specify object fill opacity.
font | fontname | Specify text drawing font.
gravity | (NorthWest|North|NorthEast|West|Center|East|SouthWest|South|SouthEast) | Specify text positioning gravity.
image | x,y width,height filename | Composite image at position, scaled to specified width and height, and specified filename. If width or height is zero, scaling is not performed.
line | startX,startY endX,endY | Draw a line.
matte | x,y (point|replace|floodfill|filltoborder|reset) | Set matte in image according to specified colorization rule.
opacity | fillOpacity strokeOpacity | Specify drawing fill and stroke opacities.
path | 'SVG-compatible path arguments' | Draw using SVG-compatible path drawing commands.
point | x,y | Set point to fill color.
pointsize | pointsize | Specify text drawing pointsize (scaled to density).
polygon | x1,y1, x2,y2, x3,y3, ..., xN,yN | Draw a polygon.
polyline | x1,y1, x2,y2, x3,y3, ..., xN,yN | Draw a polyline.
pop | graphic-context | Remove options set since previous "push graphic-context" command. Options revert to those in effect prior to pushing the graphic context.
push | graphic-context | Specify new graphic context.
rect | upperLeftX,upperLeftY lowerRightX,lowerRightY | Draw a rectangle.
rotate | angle | Specify coordiante space rotation. Subsequent objects are drawn with coordate space rotated by specified angle.
roundrectangle | centerX,centerY width,hight cornerWidth,cornerHeight | Draw a rectangle with rounded corners.
stroke | colorspec | Specify object stroke (outline) color.
stroke-antialias | stroke_antialias (0 or 1) | Specify if stroke should be antialiased or not.
stroke-dash | value | Specify pattern to be used when drawing stroke.
stroke-opacity | opacity | Specify opacity of stroke drawing color.
stroke-width | linewidth | Specify stroke (outline) width in pixels.
text | x,y "some text" | Draw text at position.
text-antialias | text_antialias (0 or 1) | Specify if rendered text is to be antialiased (blend edges).
scale | x,y | Specify scaling to be applied to coordintate space for subsequent drawing commands.
translate | x,y | Specify center of coordinate space to use for subsequent drawing commands.

Image manipulation software that works like magic.