Paths

Other topics

Remarks:

Detailed information on the SVG path element can be found in the W3C Recommendation for SVG.

Draw a diagonal blue line using the L path command

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <path d="M 10,10 L 100,50" stroke="blue" stroke-width="5" />
</svg>

Result:

enter image description here

Draw a horizontal orange line using the H drawing command

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <path d="M 10,10 H 200" stroke="orange" stroke-width="5" />
</svg>

Result:

enter image description here

Draw a red cross using l (relative line) path commands

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <path d="M 10,10 l 90,90 M 100,10 l -90,90" stroke="red" stroke-width="10" />
</svg>

Result:

enter image description here

Draw a vertical green line using the V path command

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <path d="M 10,10 V 200" stroke="green" stroke-width="5" />
</svg>

Result:

enter image description here

Parameters:

Attributes / parametersDescription
dDefines a sequence of drawing commands that create the shape. e.g. d="M 50,60 L50,60". Uppercase drawing commands designate absolute coordinates. Lowercase drawing commands designate relative coordinates.
(...)Drawing Commands
m/MMove current drawing position to XY d="M XY"
l/LDraw a line to X,Y d="L XY"
v/VDraw a vertical line to Y d="V Y"
h/HDraw a horizontal line to X d="H X"
a/ADraw an arc to X,Y with an implied radius of Rx and Ry and a rotation specified by X-axis-rotation. The large arc and sweep flags select which of the 4 possible arcs that satisfy these constraints should be drawn. d="A Rx Ry X-axis-rotation(degrees) large-arc-flag (0/1) sweep-flag(0/1) X,Y".
q/QDraw quadratic bezier curve to X,Y using control point X1Y1 d="X1Y1 X Y"
t/TDraw a shorthand quadratic bezier curve (the control point is calculated as a reflection of the control point of the previous q/Q drawing command through the current drawing position)
c/CDraw a cubic bezier curve to X,Y using control points X1,Y1 and X2,Y2 d="C X1Y1, X2Y2, XY"
s/SDraw a shorthand cubic bezier curve (first control point is calculated as a reflection of the second control point of the previous c/C drawing command through the current drawing position).
- z/ZClose the path by drawing a line to start of path (or pathsegment if another z has been used previously)
(...)(end of list)
pathLength(Optional) Allows the author to specify a nominal pathLength which will be used for calibration in other calculations, for example for text along a path
Stroke Parameterscommon among to all shape and drawing elements
strokeColor of path
stroke-widthWidth of path

Contributors

Topic Id: 2397

Example Ids: 7907,7908,7909,7910

This site is not affiliated with any of the contributors.