|
|
|
|
|
SVG Basics - Path Element
|
|
Published
07/17/2006
|
SVG Viewer
|
|
|
|
|
|
SVG PathThe path element is the single most useful tag for creating professional looking SVG documents and it's the most difficult tag to hand-code in SVG. It is quite hard to visualize anything but the most simple of paths. | Attribute | Explanation | | d | A set of commands which define the path. (See below) | | pathLength | If present then the path will be scaled so that the computed path length of the points equals this value. A negative value is an error. (Note: Unsupported by Adobe's plugin) | | transform | A list of transformations. | | Presentation Attributes | Color, FillStroke, Graphics, Markers | Line Example
Example 1. A path made using lineto commands (Download) <path d="M100,10 L100,10 40,180 190,60 10,60 160,180 z" stroke="blue" fill="darkblue" stroke-width="4" /> Code 1. The path used in the above example.
Cubic Bezier Example Example 2. A path made using cubic curves. The control points are circled in red. (Download) <path d="M40,140 L40,100 10,100 C10,10 90,10 90, 100 L60,100 60,140 M140,50 C70,180 195,180 190,100 " stroke="darkgreen" stroke-width="4" fill="url(#hill)" /> Code 2. The path used in the above example. Quadratic Bezier Example Example 3. A path made using quadratic bezier curves. The control point is circled in red (click to view). (Download) <path id="playButton" d="M50,50 Q-30,100 50,150 100, 230 150,150 230,100 150,50 100,-30 50,50" stroke="darkblue" stroke-width="4" fill="url(#myFillGrad)" /> Code 3. The path used in the above example. Elliptical Arc Example <path d="M10,150 A15 15 180 0 1 70 140 A15 25 180 0 0 130 130 A15 55 180 0 1 190 120" stroke="lightgreen" stroke-width="4" fill="none" marker-mid="url(#marker2)" marker-end="url(#marker1)" /> Code 4. The path used in the above example. Placing text on a path is accomplished by defining a path and inside a 'text' element using a 'textPath' element to reference the path.
Example 5. Text on a path. The path is shown in red. (Download) <path id="path1" d="M25, 100 C10,10 175,10 175,100" /> Code 5. The path used in the above example.
|