File: //usr/share/doc/ImageMagick-6.2.8/www/magick-vector-graphics.html
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<style type="text/css"><!--
@import url("../www/magick.css");
//--></style>
<title>ImageMagick: Magick Vector Graphics</title>
<meta http-equiv="Content-Language" content="en-US"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="Reply-to" content="magick-users@imagemagick.org"/>
<meta name="Generator" content="PHP"/>
<meta name="Keywords" content="magick, vector, graphics, ImageMagick, PerlMagick, Magick++, Image, Magick"/>
<meta name="Description" content="ImageMagick (TM) is a free software suite to create, edit and compose bitmap images. It can read, convert and write images in a large variety of formats. Images can be cropped, colors can be changed, various effects can be applied, images can be rotated and combined, and text, lines, polygons, ellipses and Bézier curves can be added to images and stretched and rotated. ImageMagick is free software: it is delivered with full source code and can be freely used, copied, modified and distributed. Its license is compatible with the GPL. It runs on all major operating systems. Most of the functionality of ImageMagick can be used interactively from the command line; more often, however, the features are used from programs written in the programming languages Perl, C, C++, Python, PHP, Ruby or Java, for which ready-made ImageMagick interfaces (PerlMagick, Magick++, PythonMagick, MagickWand for PHP, RubyMagick, and JMagick) are available. This makes it possible to modify or create images automatically and dynamically. ImageMagick supports many image formats (over 90 major formats) including popular formats like TIFF, JPEG, PNG, PDF, PhotoCD, and GIF."/>
<meta name="Rating" content="GENERAL"/>
<meta name="Robots" content="INDEX, FOLLOW"/>
<meta name="Generator" content="ImageMagick Studio LLC"/>
<meta name="Author" content="ImageMagick Studio LLC"/>
<meta name="Revisit-after" content="2 DAYS"/>
<meta name="Resource-type" content="document"/>
<meta name="Copyright" content="Copyright (c) 1999-2006 ImageMagick Studio LLC"/>
<meta name="Distribution" content="Global"/>
<link rel="shortcut icon" href="/../images/wand.ico" type="image/x-icon"/>
</head>
<body id="www-imagemagick-org">
<table id="titlebar" style="width: 100%;background-color: #f5f5f5" cellpadding="0" cellspacing="0" border="0" summary="ImageMagick">
<tbody>
<tr valign="top">
<td align="left"><a href="../index.html"><img id="titlebar-west" src="../images/script.png" alt="[ImageMagick]" width="350" height="60" border="0" vspace="28" name="titlebar-west" /></a></td>
<td width="35%"><br /></td>
<td align="left"><a href="http://www.imagemagick.org/" target="817704634"><img id="titlebar-west" src="../images/sponsor.jpg" alt="[sponsor]" border="0" vspace="28" name="titlebar-west" /></a></td>
<td width="65%"><br /></td>
<td style="background-color: white" align="right"><a href="../index.html"><img src="../images/sprite.jpg" alt="" width="114" height="118" border="0" name="titlebar-east" /></a></td>
<td style="background-color: white" align="right"><a href="../index.html"><img id="titlebar-east" src="../images/logo.jpg" alt="" width="114" height="118" border="0" name="titlebar-east" /></a></td>
</tr>
</tbody>
</table>
<table style="width: 100%" border="0" cellpadding="0" cellspacing="0" summary="">
<tbody>
<tr valign="top" style="height: 100%;">
<td id="menu" width="1%" height="100%">
<p><a href="#main">Skip to page contents</a></p>
<span>[</span>
<a href="../index.html">About ImageMagick</a>
<a href="../www/command-line-tools.html">Command-line Tools</a>
<a href="../www/command-line-processing.html" class="sub">Processing</a>
<a href="../www/command-line-options.html" class="sub">Options</a>
<a href="../www/api.html">Program Interfaces</a>
<a href="../www/magick-wand.html" class="sub">MagickWand</a>
<a href="../www/magick-core.html" class="sub">MagickCore</a>
<a href="../www/perl-magick.html" class="sub">PerlMagick</a>
<a href="../www/architecture.html">Architecture</a>
<span>]</span><br /><span>[</span>
<a href="../www/install-source.html">Install from Source</a>
<a href="../www/install-source.html#unix" class="sub">Unix</a>
<a href="../www/install-source.html#windows" class="sub">Windows</a>
<a href="../www/binary-releases.html">Binary Releases</a>
<a href="../www/binary-releases.html#unix" class="sub">Unix</a>
<a href="../www/binary-releases.html#windows" class="sub">Windows</a>
<a href="../www/resources.html">Resources</a>
<span>]</span><br /><span>[</span>
<a href="../www/download.html">Download</a>
<span>]</span><br /><span>[</span>
<a href="../www/links.html">Links</a>
<span>]</span><br /><br /><span>[</span>
<a href="../www/sponsors.html">Sponsors</a>
<a href="http://www.desktopexchange.com/" class="sponsor" target="sponsor">Desktop Wallpaper</a><!-- 20060810 -->
<span>]</span>
</td>
<td id="main" valign="top">
<p class="navigation-index">[<a href="#intro">Introduction to Vector Graphics</a> | <a href="#overview">MVG Overview</a> | <a href="#primitives">Drawing Primitives</a>]</p>
<div style="margin: auto;">
<h2><a name="intro"></a>Introduction to Vector Graphics</h2></div>
</div>
<p>This specification defines the features and syntax for Magick Vector Graphics (MVG), a modularized language for describing two-dimensional vector and mixed vector/raster graphics in ImageMagick. You can use the language to draw from the
command line, from an MVG file, from an <a href="http://www.w3.org/TR/SVG/" target="636486104">SVG -- Scalable Vector Graphics</a> file or from one of the ImageMagick <a href="../www/api.html">program interfaces</a>. Use this command, for example, to render an arc:</p>
<pre class="text">
convert -size 100x60 xc:skyblue -fill white -stroke black \
-draw "path 'M 30,40 A 30,20 20 0,0 70,20 A 30,20 20 1,0 30,40 Z '" \
arc.png
</pre>
<p>and here is the results:</p>
<p class="image">
<a href="../images/arc.png"><img src="../images/arc.png" width="100" height="60" align="middle" alt="arc" /></a>
</p>
<p>When the drawing gets sufficiently complex, we recommend you assemble the graphic primitives into a MVG file. For our example, we use <a href="../www/source/piechart.mvg">piechart.mvg</a> to render a pie chart with this command:</p>
<pre class="text">
convert piechart.mvg piechart.png
</pre>
<p>which produces this rendering:</p>
<p class="image">
<a href="../images/piechart.png"><img src="../images/piechart.png" width="624" height="369" align="middle" alt="piechart" /></a>
</p>
<p>However, in general, MVG is sufficiently difficult to work with that you probably want to use a program to generate your graphics in the SVG format. ImageMagick automatically converts SVG to MVG and renders your image, for example, we render <a href="../www/source/piechart.svg">piechart.svg</a> with this command:
<pre class="text">
convert piechart.svg piechart.jpg
</pre>
<p>to produce the same pie chart we created with the the MVG language.</p>
<p>Drawing is available from many of the ImageMagick <a href="../www/api.html">program interfaces</a> as well. ImageMagick converts the drawing API calls to MVG and renders it. Here is example code written in the <a href="../www/magick-wand.html">MagickWand</a> language:
<pre class="code">
(void) PushDrawingWand(draw_wand);
{
const PointInfo points[6] =
{
{ 180,504 },
{ 282.7,578.6 },
{ 243.5,699.4 },
{ 116.5,699.4 },
{ 77.26,578.6 },
{ 180,504 }
};
DrawSetStrokeAntialias(draw_wand,True);
DrawSetStrokeWidth(draw_wand,9);
DrawSetStrokeLineCap(draw_wand,RoundCap);
DrawSetStrokeLineJoin(draw_wand,RoundJoin);
(void) DrawSetStrokeDashArray(draw_wand,0,(const double *)NULL);
(void) PixelSetColor(color,"#4000c2");
DrawSetStrokeColor(draw_wand,color);
DrawSetFillRule(draw_wand,EvenOddRule);
(void) PixelSetColor(color,"#800000");
DrawSetFillColor(draw_wand,color);
DrawPolygon(draw_wand,6,points);
}
(void) PopDrawingWand(draw_wand);
</pre>
<div style="margin: auto;">
<h2><a name="overview"></a>MVG Overview</h2></div>
</div>
<p>MVG ignores all white-space between commands. This allows multiple MVG commands per line. It is common convention to terminate each MVG command with a new line to make MVG easier to edit and read. This syntax description uses indentation in MVG sequences to aid with understanding. Indentation is supported but is not required.</p>
<p>Metafile wrapper syntax (to support stand-alone MVG files):</p>
<pre class="text">
push graphic-context
viewbox 0 0 width height
[ any other MVG commands ]
pop graphic-context
</pre>
<p>Pattern syntax (saving and restoring context):</p>
<pre class="text">
push pattern id x,y width,height
push graphic-context
[ drawing commands ]
pop graphic-context
pop pattern
</pre>
<p>an example is (%s is a identifier string):</p>
<pre class="text">
push defs
push pattern %s 10,10 20,20
push graphic-context
fill red
rectangle 5,5 15,15
pop graphic-context
push graphic-context
fill green
rectangle 10,10 20,20
pop graphic-context
pop pattern
pop defs
</pre>
<p>For image tiling use:</p>
<pre class="text">
push pattern id x,y width,height
image Copy ...
pop pattern
</pre>
<p>Note you can use the pattern for either the fill or stroke like:</p>
<pre class="text">
stroke url(#%s)
</pre>
<p>or</p>
<pre class="text">
fill url(#%s)
</pre>
<p>The clip path defines a clipping area, where only the contained area to be drawn upon. Areas outside of the clipping area are masked.</p>
<pre class="text">
push defs
push clip-path %s
push graphic-context
rectangle 10,10 20,20
pop graphic-context
pop clip-path
pop defs
clip-path url(#%s)
</pre>
<div style="margin: auto;">
<h2><a name="primitives"></a>Drawing Primitives</h2></div>
</div>
<p>Here is a complete description of the MVG drawing primitives:</p>
<ul>
<div style="margin: auto;">
<h4><a name="affine" id="affine"></a>affine <em class="option">s<sub>x</sub></em>,<em class="option">r<sub>x</sub></em>,<em class="option">r<sub>y</sub></em>,<em class="option">s<sub>y</sub></em>,<em class="option">t<sub>x</sub></em>,<em class="option">t<sub>y</sub></em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="arc" id="arc"></a>arc <em class="option">x<sub>0</sub></em>,<em class="option">y<sub>0</sub></em> <em class="option">x<sub>1</sub></em>,<em class="option">y<sub>1</sub></em> <em class="option">a<sub>0</sub></em>,<em class="option">a<sub>1</sub></em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="bezier" id="bezier"></a>bezier <em class="option">x<sub>0</sub></em>,<em class="option">y<sub>0</sub></em> ... <em class="option">x<sub>n</sub></em>,<em class="option">y<sub>n</sub></em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="circle" id="circle"></a>circle <em class="option">origin<sub>x</sub></em>,<em class="option">origin<sub>y</sub></em> <em class="option">perimeter<sub>x</sub></em>,<em class="option">perimeter<sub>y</sub></em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="clip-path" id="clip-path"></a>clip-path url(<em class="option">name</em>)</h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="clip-rule" id="clip-rule"></a>clip-rule <em class="option">rule</em></h4>
</div>
<p>Choose from these rule types:</p>
<pre class="text">
evenodd
nonzero
</pre>
<div style="margin: auto;">
<h4><a name="clip-units" id="clip-units"></a>clip-units <em class="option">units</em></h4>
</div>
<p>Choose from these unit types:</p>
<pre class="text">
userSpace
userSpaceOnUse
objectBoundingBox
</pre>
<div style="margin: auto;">
<h4><a name="color" id="color"></a>color <em class="option">x</em>,<em class="option">y</em> <em class="option">method</em></h4>
</div>
<p>Choose from these method types:</p>
<pre class="text">
point
replace
floodfill
filltoborder
reset
</pre>
<div style="margin: auto;">
<h4><a name="decorate" id="decorate"></a>decorate <em class="option">type</em></h4>
</div>
<p>Choose from these types of decorations:</p>
<pre class="text">
none
line-through
overline
underline
</pre>
<div style="margin: auto;">
<h4><a name="ellipse" id="ellipse"></a>ellipse <em class="option">center<sub>x</sub></em>,<em class="option">center<sub>y</sub></em> <em class="option">radius<sub>x</sub></em>,<em class="option">radius<sub>y</sub></em> <em class="option">arc<sub>start</sub></em>,<em class="option">arc<sub>stop</sub></em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="fill" id="fill"></a>fill <em class="option">color</em></h4>
</div>
<p>Choose from any of these <a href="../www/color.html" target="2114390313">colors</a>.</p>
<div style="margin: auto;">
<h4><a name="fill-opacity" id="fill-opacity"></a>fill-opacity <em class="option">opacity</em></h4>
</div>
<p>The opacity ranges from 0.0 (fully transparent) to 1.0 (fully opaque) or as a percentage (e.g. 50%).</p>
<div style="margin: auto;">
<h4><a name="fill-rule" id="fill-rule"></a>fill-rule <em class="option">rule</em></h4>
</div>
<p>Choose from these rule types:</p>
<pre class="text">
evenodd
nonzero
</pre>
<div style="margin: auto;">
<h4><a name="font" id="font"></a>font <em class="option">name</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="font-family" id="font-family"></a>font-family <em class="option">family</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="font-size" id="font-size"></a>font-size <em class="option">point-size</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="font-stretch" id="font-stretch"></a>font-stretch <em class="option">type</em></h4>
</div>
<p>Choose from these stretch types:</p>
<pre class="text">
all
normal
ultra-condensed
extra-condensed
condensed
semi-condensed
semi-expanded
expanded
extra-expanded
ultra-expanded
</pre>
<div style="margin: auto;">
<h4><a name="font-style" id="font-style"></a>font-style <em class="option">style</em></h4>
</div>
<p>Choose from these styles:</p>
<pre class="text">
all
normal
italic
oblique
</pre>
<div style="margin: auto;">
<h4><a name="font-weight" id="font-weight"></a>font-weight <em class="option">weight</em></h4>
</div>
<p>Choose from these weights:</p>
<pre class="text">
all
normal
bold
100
200
300
400
500
600
700
800
900
</pre>
<div style="margin: auto;">
<h4><a name="gradient-units" id="gradient-units"></a>gradient-units <em class="option">units</em></h4>
</div>
<p>Choose from these units:</p>
<pre class="text">
userSpace
userSpaceOnUse
objectBoundingBox
</pre>
<div style="margin: auto;">
<h4><a name="gravity" id="gravity"></a>gravity <em class="option">type</em></h4>
</div>
<p>Choose from these gravity types:</p>
<pre class="text">
NorthWest
North
NorthEast
West
Center
East
SouthWest
South
SouthEast
</pre>
<div style="margin: auto;">
<h4><a name="image" id="image"></a>image <em class="option">compose x,y width,height 'filename'</em></h4>
</div>
<p>Choose from these compose operations:</p>
<pre class="text">
Add
Atop
Bumpmap
Clear
CopyBlue
CopyGreen
CopyOpacity
CopyRed
Copy
Difference
In
Minus
Multiply
Out
Over
Plus
Subtract
Xor
</pre>
<div style="margin: auto;">
<h4><a name="line" id="line"></a>line <em class="option">x,y x<sub>1</sub>,y<sub>1</sub></em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="matte" id="matte"></a>font-style <em class="option">x,y method</em></h4>
</div>
<p>Choose from these methods:</p>
<pre class="text">
point
replace
floodfill
filltoborder
reset
</pre>
<div style="margin: auto;">
<h4><a name="offset" id="offset"></a>offset <em class="option">offset</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="opacity" id="opacity"></a>opacity <em class="option">opacity</em></h4>
</div>
<p>Use percent (e.g. 50%).</p>
<div style="margin: auto;">
<h4><a name="path" id="path"></a>path <em class="option">path</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="point" id="point"></a>point <em class="option">x,y</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="polygon" id="polygon"></a>polygon <em class="option">x,y x<sub>1</sub>,y<sub>1</sub>, ..., x<sub>n</sub>,y<sub>n</sub></em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="polyline" id="polyline"></a>polyline <em class="option">x,y x<sub>1</sub>,y<sub>1</sub>, ..., x<sub>n</sub>,y<sub>n</sub></em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="pop-clip-path" id="pop-clip-path"></a>pop clip-path</h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="pop-defs" id="pop-defs"></a>pop defs</h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="pop-gradient" id="pop-gradient"></a>pop gradient</h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="pop-graphic-context" id="pop-graphic-context"></a>pop graphic-context</h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="pop-pattern" id="pop-pattern"></a>pop pattern</h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="push" id="push"></a>push clip-path <em class="option">name</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="push-defs" id="push-defs"></a>push defs</h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="push-gradient-linear" id="push-gradient-linear"></a>push gradient <em class="option">id linear x,y x<sub>1</sub>,y<sub>1</sub></em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="push-gradient-radial" id="push-gradient-radial"></a>push gradient <em class="option">id radial x<sub>c</sub>,c<sub>y</sub> x<sub>f</sub>,y<sub>f</sub> radius</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="push-graphic-context" id="push-graphic-context"></a>push graphic-context</h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="push-pattern" id="push-pattern"></a>push pattern <em class="option">id radial x,y width,height</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="rectangle" id="rectangle"></a>rectangle <em class="option">x,y x<sub>1</sub>,y<sub>1</sub></em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="rotate" id="rotate"></a>rotate <em class="option">angle</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="roundrectangle" id="roundrectangle"></a>roundrectangle <em class="option">x,y x<sub>1</sub>,y<sub>1</sub> width,height</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="scale" id="scale"></a>scale <em class="option">x,y</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="skewX" id="skewX"></a>skewX <em class="option">angle</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="skewY" id="skewY"></a>skewX <em class="option">angle</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="stop-color" id="stop-color"></a>stop-color <em class="option">color offset</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="stroke" id="stroke"></a>stroke <em class="option">color</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="stroke-antialias" id="stroke-antialias"></a>stroke-antialias <em class="option">0 | 1</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="stroke-dasharray" id="stroke-dasharray"></a>stroke-dasharray <em class="option">none | numeric-list</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="stroke-dashoffset" id="stroke-dashoffset"></a>stroke-dashoffset <em class="option">offset</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="stroke-linecap" id="stroke-linecap"></a>stroke-linecap <em class="option">type</em></h4>
</div>
<p>Choose from these cap types:</p>
<pre class="text">
butt
round
square
</pre>
<div style="margin: auto;">
<h4><a name="stroke-linejoin" id="stroke-linejoin"></a>stroke-linejoin <em class="option">type</em></h4>
</div>
<p>Choose from these join types:</p>
<pre class="text">
bevel
miter
round
</pre>
<div style="margin: auto;">
<h4><a name="stroke-miterlimit" id="stroke-miterlimit"></a>stroke-miterlimit <em class="option">limit</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="stroke-opacity" id="stroke-opacity"></a>stroke-opacity <em class="option">opacity</em></h4>
</div>
<p>The opacity ranges from 0.0 (fully transparent) to 1.0 (fully opaque) or as a percentage (e.g. 50%).</p>
<div style="margin: auto;">
<h4><a name="stroke-width" id="stroke-width"></a>stroke-width <em class="option">width</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="text" id="text"></a>text <em class="option">"text"</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="text-antialias" id="text-antialias"></a>text-antialias <em class="option">0 | 1</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="text-undercolor" id="text-undercolor"></a>text-undercolor <em class="option">color</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="translate" id="translate"></a>translate <em class="option">x,y</em></h4>
</div>
<p></p>
<div style="margin: auto;">
<h4><a name="viewbox" id="viewbox"></a>viewbox <em class="option">x,y x<sub>1</sub>,y<sub>1</sub></em></h4>
</div>
</ul>
<p></p>
</td>
<td id="margin" width="1%" height="100%" valign="top" align="right"> </td>
</tr>
</tbody>
</table>
<div id="linkbar">
<a href="http://redux.imagemagick.org/discussion-server" target="2045139807">Discourse Server</a> |
<a href="../www/mailing-list.html">Mailing Lists</a> |
<a href="http://redux.imagemagick.org/gallery" target="715373221">Image Gallery</a> |
<a href="http://studio.webbyland.com/MagickStudio/scripts/MagickStudio.cgi" target="1679019451">ImageMagick Studio</a>
</div>
<div>
<span id="footer-west">© 1999-2006 ImageMagick Studio LLC</span>
</div>
<div style="clear: both; margin: 0; width: 100%; "></div>
</body>
</html>