cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | Summary of MVG Primitives and Syntax |
| 2 | ==================================== |
| 3 | |
| 4 | MVG ignores all white-space between commands. This allows |
| 5 | multiple MVG commands per line. It is common convention to |
| 6 | terminate each MVG command with a new line to make MVG easier |
| 7 | to edit and read. This syntax description uses indentation in |
| 8 | MVG sequences to aid with understanding. Indentation is |
| 9 | supported but is not required. |
| 10 | |
| 11 | Metafile wrapper syntax (to support stand-alone MVG files) |
| 12 | ---------------------------------------------------------- |
| 13 | |
| 14 | push graphic-context |
| 15 | viewbox 0 0 width height |
| 16 | [ any other MVG commands ] |
| 17 | pop graphic-context |
| 18 | |
| 19 | |
| 20 | Pattern syntax (saving and restoring context) |
| 21 | --------------------------------------------- |
| 22 | |
| 23 | push pattern id x,y width,height |
| 24 | push graphic-context |
| 25 | [ drawing commands ] |
| 26 | pop graphic-context |
| 27 | pop pattern |
| 28 | |
| 29 | an example is (%s is a identifier string) |
| 30 | |
| 31 | push defs |
| 32 | push pattern %s 10,10 20,20 |
| 33 | push graphic-context |
| 34 | fill red |
| 35 | rectangle 5,5 15,15 |
| 36 | pop graphic-context |
| 37 | push graphic-context |
| 38 | fill green |
| 39 | rectangle 10,10 20,20 |
| 40 | pop graphic-context |
| 41 | pop pattern |
| 42 | pop defs |
| 43 | |
| 44 | For image tiling use |
| 45 | |
| 46 | push pattern id x,y width,height |
| 47 | image Copy ... |
| 48 | pop pattern |
| 49 | |
| 50 | Note you can use the pattern for either the fill or stroke like |
| 51 | |
| 52 | stroke url(#%s) |
| 53 | |
| 54 | or |
| 55 | |
| 56 | fill url(#%s) |
| 57 | |
| 58 | Clip-path syntax |
| 59 | ---------------- |
| 60 | |
| 61 | The clip path defines a clipping area, where only the contained |
| 62 | area will be drawn upon. Areas outside of the clipping area are |
| 63 | masked. |
| 64 | |
| 65 | push defs |
| 66 | push clip-path %s |
| 67 | push graphic-context |
| 68 | rectangle 10,10 20,20 |
| 69 | pop graphic-context |
| 70 | pop clip-path |
| 71 | pop defs |
| 72 | clip-path url(#%s) |
| 73 | |
| 74 | Individual Drawing Primitives |
| 75 | ============================= |
| 76 | |
| 77 | affine sx,rx,ry,sy,tx,ty |
| 78 | arc x0,y0 x1,y1 a0,a1 |
| 79 | bezier x0,y0 ... xn,yn |
| 80 | circle originX,originY perimX,perimY |
| 81 | clip-path url(#%s) (%s is the name of the clip path) |
| 82 | clip-rule (evenodd|nonzero) |
| 83 | clip-units (userSpace|userSpaceOnUse|objectBoundingBox) |
| 84 | color x,y (point|replace|floodfill|filltoborder|reset) |
| 85 | decorate (none|underline|overline|line-through) |
| 86 | ellipse centerX,centerY radiusX,radiusY arcStart,arcEnd |
| 87 | fill colorspec |
| 88 | fill-opacity opacity[%] |
| 89 | fill-rule (evenodd|nonzero) |
| 90 | font fontname |
| 91 | font-family familyname (e.g. "helvetica") |
| 92 | font-size pointsize |
| 93 | font-stretch (all|normal|ultra-condensed|extra-condensed|condensed| |
| 94 | semi-condensed|semi-expanded|expanded|extra-expanded| |
| 95 | ultra-expanded) |
| 96 | font-style (all|normal|italic|oblique) |
| 97 | font-weight (all|normal|bold|100|200|300|400|500|600|700|800|900) |
| 98 | gradient-units (userSpace|userSpaceOnUse|objectBoundingBox) |
| 99 | gravity (NorthWest|North|NorthEast|West|Center|East|SouthWest| |
| 100 | South|SouthEast) |
| 101 | image (Add|Atop|Bumpmap|Clear|CopyBlue|CopyGreen|CopyOpacity|CopyRed| |
| 102 | Copy|Difference|In|Minus|Multiply|Out|Over|Plus|Subtract|Xor) |
| 103 | dest_x,dest_y dest_width,dest_height 'filename' |
| 104 | line startX,startY endX,endY |
| 105 | matte x,y (point|replace|floodfill|filltoborder|reset) |
| 106 | offset ??? |
| 107 | opacity value[%] |
| 108 | path 'SVG-compatible path arguments' |
| 109 | point x,y |
| 110 | polygon x1,y1, x2,y2, x3,y3, ..., xN,yN |
| 111 | polyline x1,y1, x2,y2, x3,y3, ..., xN,yN |
| 112 | pop clip-path |
| 113 | pop defs |
| 114 | pop gradient |
| 115 | pop graphic-context |
| 116 | pop pattern |
| 117 | push clip-path %s (%s is the name of the clip path) |
| 118 | push defs |
| 119 | push gradient id linear x1,y1 x2,y2 |
| 120 | push gradient id radial cx,cy fx,fy r |
| 121 | push graphic-context |
| 122 | push pattern id x,y width,height |
| 123 | rectangle upperLeftX,upperLeftY lowerRightX,lowerRightY |
| 124 | rotate angle |
| 125 | roundrectangle upperLeftX,upperLeftY lowerRightX,lowerRightY cornerWidth,cornerHeight |
| 126 | scale x,y |
| 127 | skewX angle |
| 128 | skewY angle |
| 129 | stop-color colorspec offset |
| 130 | stroke colorspec |
| 131 | stroke-antialias truth-value (0 or 1) |
| 132 | stroke-dasharray (none|comma-delimited-numeric-list) |
| 133 | stroke-dashoffset dashoffset |
| 134 | stroke-linecap (butt|round|square) |
| 135 | stroke-linejoin (butt|miter|round|square) |
| 136 | stroke-miterlimit limit |
| 137 | stroke-opacity opacity[%] |
| 138 | stroke-width linewidth |
| 139 | text x,y "some text" |
| 140 | text-antialias (0|1) |
| 141 | text-undercolor colorspec |
| 142 | translate x,y |
| 143 | viewbox x1 y1 x1 y2 (e.g. "viewbox 0 0 640 480") |
| 144 | |